Feb 21st, 2006, 03:25 AM
businessInterface of calling EJB from Spring
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.
Feb 21st, 2006, 08:38 AM
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.
Feb 21st, 2006, 08:02 PM
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!
Feb 21st, 2006, 08:48 PM
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.
Feb 21st, 2006, 10:08 PM
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 .... : <
Feb 23rd, 2006, 08:24 AM
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.
Feb 24th, 2006, 01:33 AM
then what does the attribuate "businessInterface" at the XML refer to then?
Feb 24th, 2006, 01:48 AM
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.