Results 1 to 2 of 2

Thread: Load spring context in an EJB based application

  1. #1
    Join Date
    Jan 2010
    Posts
    5

    Default 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. #2
    Join Date
    Oct 2011
    Location
    Mumbai, India
    Posts
    213

    Default

    If i understand you correctly
    SpringBeanAutowiringInterceptor can solve your problem.

    This EJB interceptor can wire spring beans in your EJB

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •