|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.tzavellas.dyndelegate.DynamicDelegateFactory
public class DynamicDelegateFactory
A Dynamic Delegate for Session Beans.
This class dynamically creates a Business Delegate
for a Session EJB. The delegate will implement the specified interface.
When a method is called on the delegate the corresponding method
on the client interface of bean will be invoked. Any exception that
may be thrown from the invocation will be converted and re-thrown
according to the ThrowableConverter
of this class.
To use this class your EJBs must implement the Business Interface EJB design pattern (see the EJB Design Patterns book by Floyd Marinescu). In this pattern your EJB's bean class and client interface (local or remote), both implement a common "Business Interface" that defines the business methods.
When creating a dynamic delegate for an EJB, supply as the delegate interface the Business Interface of your bean. The business interface usually does not throw any EJB specific exceptions (like RemoteException and EJBException) and does not have any dependency on the EJB APIs.
This work is based on the "EJB best practices: The dynamic delegate"
article by Brett McLaughlin and on the Spring Framework EJB Access
classes found at the org.springframework.ejb.access
package.
ThrowableConverter
,
EJBHomeFactory
,
EJB best practices: The dynamic delegate,
The Business Interface design pattern,
Spring FrameworkConstructor Summary | |
---|---|
DynamicDelegateFactory()
Construct a DynamicDelegateFactory with an EJBExceptionConverter and a SimpleEJBHomeFactory. |
|
DynamicDelegateFactory(ThrowableConverter exceptionConverter,
EJBHomeFactory homeFactory)
Construct a DynamicDelegateFactory using the specified
ThrowableConverter and EJBHomeFactory . |
Method Summary | |
---|---|
protected Object |
createDelegate(String jndiName,
Class homeInterface,
Class businnessInterface,
Object[] createArgs,
boolean isRemote)
Dynamically create a Business Delegate. |
Object |
createLocalDelegate(String jndiName,
Class homeInterface,
Class businnessInterface)
Dynamically create a Business Delegate for an EJB with local access. |
Object |
createLocalDelegate(String jndiName,
Class homeInterface,
Class businnessInterface,
Object[] createArgs)
Dynamically create a Business Delegate for an EJB with local access. |
Object |
createRemoteDelegate(String jndiName,
Class homeInterface,
Class businnessInterface)
Dynamically create a Business Delegate for an EJB with remote access. |
Object |
createRemoteDelegate(String jndiName,
Class homeInterface,
Class businnessInterface,
Object[] createArgs)
Dynamically create a Business Delegate for an EJB with remote access. |
Object |
getBean(Object delegate)
Get the EJB that the specified Business Delegate proxies. |
void |
remove(Object delegate)
Remove the EJB behind the specified dynamic delegate object. |
void |
setExceptionConverter(ThrowableConverter exceptionConverter)
Set the ThrowableConverter to use with this factory. |
void |
setHomeFactory(EJBHomeFactory homeFactory)
Set the EJBHomeFactory to use with this factory. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DynamicDelegateFactory(ThrowableConverter exceptionConverter, EJBHomeFactory homeFactory)
DynamicDelegateFactory
using the specified
ThrowableConverter
and EJBHomeFactory
.
ThrowableConverter
,
EJBHomeFactory
public DynamicDelegateFactory()
EJBExceptionConverter
,
SimpleEJBHomeFactory
Method Detail |
---|
public void setExceptionConverter(ThrowableConverter exceptionConverter)
ThrowableConverter
to use with this factory.
public void setHomeFactory(EJBHomeFactory homeFactory)
EJBHomeFactory
to use with this factory.
public Object createRemoteDelegate(String jndiName, Class homeInterface, Class businnessInterface)
jndiName
- the JNDI name to lookup the EJB.homeInterface
- the class of the home interface of the EJB that
the created delegate will proxybusinnessInterface
- the interface that the created delegate
will implement
public Object createRemoteDelegate(String jndiName, Class homeInterface, Class businnessInterface, Object[] createArgs)
jndiName
- the JNDI name to lookup the EJB.homeInterface
- the class of the home interface of the EJB that
the created delegate will proxybusinnessInterface
- the interface that the created delegate
will implementcreateArgs
- the arguments of the create method in the EJB's
home interface
public Object createLocalDelegate(String jndiName, Class homeInterface, Class businnessInterface)
jndiName
- the JNDI name to lookup the EJB.homeInterface
- the class of the home interface of the EJB that
the created delegate will proxybusinnessInterface
- the interface that the created delegate
will implement
public Object createLocalDelegate(String jndiName, Class homeInterface, Class businnessInterface, Object[] createArgs)
jndiName
- the JNDI name to lookup the EJB.homeInterface
- the class of the home interface of the EJB that
the created delegate will proxybusinnessInterface
- the interface that the created delegate
will implementcreateArgs
- the arguments of the create method in the EJB's
home interface
protected Object createDelegate(String jndiName, Class homeInterface, Class businnessInterface, Object[] createArgs, boolean isRemote)
jndiName
- the JNDI name to lookup the EJB.homeInterface
- the class of the home interface of the EJB that
the created delegate will proxybusinnessInterface
- the interface that the created delegate
will implementcreateArgs
- the arguments of the create method in the EJB's
home interfaceisRemote
- the access of the EJB (remote or local)
public Object getBean(Object delegate) throws IllegalArgumentException
delegate
- a dynamic Business Delegate object generated with
this class.
IllegalArgumentException
- if the parameter is not a dynamic
delegate generated with this class.public void remove(Object delegate) throws IllegalArgumentException
Since this method calls remove()
on the bean's client
interface, you cannot invoke methods on the specified delegate object
after this method is invoked.
delegate
- the delegate that proxies the bean that we want to
remove.
IllegalArgumentException
- if the parameter is not a dynamic
delegate generated with this class.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |