Results 1 to 8 of 8

Thread: businessInterface of calling EJB from Spring

  1. #1
    Join Date
    Feb 2006
    Posts
    19

    Default businessInterface of calling EJB from Spring

    hi,

    i want to know the class specified at "businessInterface" at the xml configuration should be newly created by me or reference to another file.

    the following is an example and i'm not sure the class stated at the businessInterface attribute referring to a new java class or from existing EJB file.

    if it's a new java class, another rules/guideline for that interface class?

    <bean id="paymentService" class="org.springframework.ejb.
    access.LocalStatelessSessionProxyFactoryBean"
    lazy-init="true">
    <property name="jndiName">
    <value>payService</value>
    </property>
    <property name="businessInterface">
    <value>com.springinaction.payment.PaymentService </value>
    </property>
    </bean>

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

    Default

    Take a loot at my posts in this thread

    Basically you create your business interface by hand and then generate the EJB interface (and home) using XDoclet. If you do that part by hand as well, you would have to create two interfaces, one business and one remote.
    Bill

  3. #3
    Join Date
    Feb 2006
    Posts
    19

    Default

    Am i correct that if the EJB is developed by third-party,

    1. i need to ask them for the EJB Home interface
    2. based on their interface, i create my own Business Interface which should be specified at xml configuration file's businessInterface?
    3. finally, create two standard spring java files, XXXBean.java and XXXFactoryBean.java to encapulate the business.

    therefore, at this situation, only need to write 3 java files then.

    thanks a lot!

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

    Default

    BTW, you don't NEED to write a business interface. If you are using a 3rd party library that is designed as a remote object, you might consider using it as such. When I find it useful to use a business interface is when I have the ability to choose how I call it (using EJB, RMI, other remote strategy or as a local class). So if your 3rd party library isn't offering you that flexibility, it may be extra work.

    I guess it depends on how you like to write your client code. If you don't like to put try/catch for RemoteException for every call, then using a non-EJB business interface will make it cleaner.
    Bill

  5. #5
    Join Date
    Feb 2006
    Posts
    19

    Default

    thanks!

    indeed, i still want to have the flexibilty as one day we may not use that 3rd EJB, we may implement in our own EJB or POJO and etc.

    therefore, want to have a better architecture with Spring at the design and first stage.

    at this consideration, am i required to have it? if possible, please state specifically, sorry that i'm quite new at this scenario and don't have a very clear picture even read the reference manual .... : <

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

    Default

    You are not required to have a business interface. What having a business interface gives you is it removes the RemoteException from the signature of a remote bean. You can still catch a remote exception. Spring just converts the one from EJB interface into an unchecked one.

    By keeping your business object agnostic to its actual transport (in this case EJB) then when you change the implementation (like converting remote EJB to local object or another remoting strategy) you don't have to change your client code.
    Bill

  7. #7
    Join Date
    Feb 2006
    Posts
    19

    Default

    then what does the attribuate "businessInterface" at the XML refer to then?

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

    Default

    It is the interface the created proxy implements. Either it is your business interface (if you have one) or it is the remote interface itself.

    Regards,
    Andreas

Posting Permissions

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