Announcement Announcement Module
Collapse
No announcement yet.
Load spring context in an EJB based application Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Load spring context in an EJB based application

    The following is the situation :

    I have a business layer, that is an EJB project. In fact, there is only one EJB that is created. This EJB is responsible to expose the service classes to other layers, that calls the EJB. I want to introduce spring (to use DI feature) in this layer.

    My concern is, what is the best way to load the spring context in this business layer, so that the spring context does not get loaded again and again, whenever the EJB gets called ?

    (In a Web project, there is an advantage rather to configure the spring context in contextLoaderListener, and it gets loaded once only when the application gets started)

    I have thought of including spring in the same layer because :

    Configure the dependencies of all DAO and service classes and inject them wherever necessary.
    To use spring support for hibernate in the business layer.
    Ease of Unit testing, by injecting the properties into classes and simulating the same. Don't need to run the other layers again and again, to test my business classes/methods.
    To be able to use AOP (Aspect Oriented Programming) for Logging and method level auditing.

    Kindly help me suggesting the best way, to load the spring context in an EJB project. I also want to know , if there are any alternatives if I can load the same in the app server (I am using Web sphere app server).

    Thanks and Regards,

    Jitendriya Dash

  • #2
    If i understand you correctly
    SpringBeanAutowiringInterceptor can solve your problem.

    This EJB interceptor can wire spring beans in your EJB

    Comment

    Working...
    X