File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Application Frameworks and the fly likes Object injection to EJB using Spring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Object injection to EJB using Spring" Watch "Object injection to EJB using Spring" New topic

Object injection to EJB using Spring

John Groller

Joined: May 08, 2008
Posts: 5
I'm not sure I understand enough to even ask the question coherently, but here it goes...

Here at work, we are required to use Spring to "inject" our objects into our Stateless Session Beans. We have a base class in our internal framework that we are supposed to extend for all beans that are "configurable using Spring".

I'm familiar with the configuration xml file, and how you list out all the beans in it... but I'm having trouble connecting the dots.

A "Hello World!" type explanation for this would be perfect.
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Well, I would suggest looking at that base class. Does it just hold a reference to the ApplicationContext and you are then required to call getBeans() on it yourself to access your Spring Beans. This is probably the implementation. And it probably would be best in the EJB lifecycle method that gets called when the EJB instance is first created. So most likely ejbCreate.

But know that the way you do this is specific to your company and whoever implemented your companies base class, and this is not a Spring class that you are extending, based on what you posted.

Spring does have an AbstractStatelessSessionBean class that you can extend, but it doesn't sound like you guys decided to go that architect/design route. Let us know if it is otherwise.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Object injection to EJB using Spring
It's not a secret anymore!