Results 1 to 6 of 6

Thread: implementing EJB with Spring

  1. #1

    Default implementing EJB with Spring

    Hi,

    In our project we are using Spring in the business layer where several existing EJB's are remotely accessed.

    Now we have decided that we need to create a new EJB to provide a new service to our application so I was thinking of creating the new EJB with the use of Spring's AbstractStatelessSessionBean. But I was wondering if this is a good approach or if there are alternatives (not to use an EJB for example). FYI we are using Weblogic 8.1 which takes care of the transactions, security,...
    Any suggestions ?

    Thanks.

    Kristof

  2. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    Maybe you could deploy just a war-file with a ContextLoaderListener that initializes your spring application-context. There you can define your beans and provide different means of remoting (e.g. RMI, Http-invoker, Hessian) which can also be supported by spring.
    This way you do not have EJBs but can use all the J2EE services provided by your application server.

    Hope that helps,
    Andreas

  3. #3
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    EJB's are remotely accessed
    Spring is able to participate in WebLogic transactions (local to the server), but the transaction won't be propagated to the client as with EJB.

  4. #4
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    Quote Originally Posted by katentim
    Spring is able to participate in WebLogic transactions (local to the server), but the transaction won't be propagated to the client as with EJB.
    Are you referring to client-controlled transactions? As far as I know you need EJBs for that, indeed. However, I do not think that this feature is used very often. Transaction control normally belongs to business logic in the server.

    The main issue is, when connectivity to other platforms is relevant. IIOP based remoting with EJBs will then be the simplest choice.

    Regards,
    Andreas

  5. #5
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    Keep in mind you should architect your client code so that it works no matter how you call your business object. So if you use AbstractStatelessSessionBean, RMI, Hessian or Burlap or eliminate the remote call all together, they all should be based around the same interface.

    Does the EJB run on the same server as the web application? If so I can't see why you would want to even use remote calls. Spring can still provide transactions controlled by the Weblogic server.

    I'm not sure how much business object security Spring provides. Someone else will have to talk to that.

    Besides transactions and security, what kind of services do you expect to get out of EJBs? Distributed transactions? If so EJB is your only route. Pooling? Most stateless business objects do not require pooling since they are... well... stateless. I had rearchitected an EJB piece of code to use local business objects and all my EJBs were replaced with singleton business services and it worked really well.

  6. #6
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    Quote Originally Posted by Andreas Senft
    However, I do not think that this feature is used very often.
    Agreed. I was just alerting to the original poster just in case they are using it.

    Quote Originally Posted by wpoitras
    Distributed transactions? If so EJB is your only route.
    Spring can participate in distributed transactions.

    Quote Originally Posted by wpoitras
    Pooling? Most stateless business objects do not require pooling since they are... well... stateless.
    Agreed. However, if pooling is needed, you can do that with Spring as well.

Similar Threads

  1. Spring MVC Web Framework versus Struts
    By biguniverse in forum Web Flow
    Replies: 27
    Last Post: Aug 29th, 2012, 03:57 AM
  2. Replies: 5
    Last Post: Aug 9th, 2008, 05:30 AM
  3. A Spring Class Loader?
    By azzoti in forum Architecture
    Replies: 8
    Last Post: May 7th, 2005, 04:02 AM
  4. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM
  5. Replies: 2
    Last Post: Jan 21st, 2005, 04:17 AM

Posting Permissions

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