|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.ejb.support.AbstractStatelessSessionBean
public abstract class AbstractStatelessSessionBean
Convenient superclass for stateless session beans (SLSBs), minimizing the work involved in implementing an SLSB and preventing common errors. Note that SLSBs are the most useful kind of EJB.
As the ejbActivate() and ejbPassivate() methods cannot be invoked on SLSBs, these methods are implemented to throw an exception and should not be overriden by subclasses. (Unfortunately the EJB specification forbids enforcing this by making EJB lifecycle methods final.)
There should be no need to override the setSessionContext()
or ejbCreate()
lifecycle methods.
Subclasses are left to implement the onEjbCreate()
method
to do whatever initialization they wish to do after their BeanFactory has
already been loaded, and is available from the getBeanFactory()
method.
This class provides the no-arg ejbCreate()
method required
by the EJB specification, but not the SessionBean interface, eliminating
a common cause of EJB deployment failure.
Field Summary | |
---|---|
static String |
BEAN_FACTORY_PATH_ENVIRONMENT_KEY
|
protected Log |
logger
Logger available to subclasses |
Constructor Summary | |
---|---|
AbstractStatelessSessionBean()
|
Method Summary | |
---|---|
void |
ejbActivate()
|
void |
ejbCreate()
This implementation loads the BeanFactory. |
void |
ejbPassivate()
|
void |
ejbRemove()
EJB lifecycle method, implemented to invoke onEjbRemote and unload the BeanFactory afterwards. |
protected BeanFactory |
getBeanFactory()
May be called after ejbCreate(). |
SessionContext |
getSessionContext()
Convenience method for subclasses. |
protected abstract void |
onEjbCreate()
Subclasses must implement this method to do any initialization they would otherwise have done in an ejbCreate() method. |
protected void |
onEjbRemove()
Subclasses must implement this method to do any initialization they would otherwise have done in an ejbRemove() method. |
void |
setBeanFactoryLocator(BeanFactoryLocator beanFactoryLocator)
Set the BeanFactoryLocator to use for this EJB. |
void |
setBeanFactoryLocatorKey(String factoryKey)
Set the bean factory locator key. |
void |
setSessionContext(SessionContext sessionContext)
Set the session context. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.ejb.SessionBean |
---|
ejbRemove |
Field Detail |
---|
protected final Log logger
public static final String BEAN_FACTORY_PATH_ENVIRONMENT_KEY
Constructor Detail |
---|
public AbstractStatelessSessionBean()
Method Detail |
---|
public void ejbCreate() throws CreateException
Don't override it (although it can't be made final): code your own initialization in onEjbCreate(), which is called when the BeanFactory is available.
Unfortunately we can't load the BeanFactory in setSessionContext(), as resource manager access isn't permitted there - but the BeanFactory may require it.
CreateException
protected abstract void onEjbCreate() throws CreateException
ejbCreate()
method.
In contrast to ejbCreate
, the BeanFactory will have been loaded here.
The same restrictions apply to the work of this method as
to an ejbCreate()
method.
CreateException
public void ejbActivate() throws EJBException
public void ejbPassivate() throws EJBException
public void setSessionContext(SessionContext sessionContext)
If overriding this method, be sure to invoke this form of it first.
setSessionContext
in interface SessionBean
sessionContext
- the SessionContext for this EJBpublic final SessionContext getSessionContext()
getSessionContext
in interface SmartSessionBean
setSessionContext
methodpublic void setBeanFactoryLocator(BeanFactoryLocator beanFactoryLocator)
Can be invoked before loadBeanFactory, for example in constructor or setSessionContext if you want to override the default locator.
Note that the BeanFactory is automatically loaded by the ejbCreate implementations of AbstractStatelessSessionBean and AbstractMessageDriverBean but needs to be explicitly loaded in custom AbstractStatefulSessionBean ejbCreate methods.
public void setBeanFactoryLocatorKey(String factoryKey)
In case of the default BeanFactoryLocator implementation, ContextJndiBeanFactoryLocator, this is the JNDI path. The default value of this property is "java:comp/env/ejb/BeanFactoryPath".
Can be invoked before loadBeanFactory, for example in constructor or setSessionContext if you want to override the default locator key.
BEAN_FACTORY_PATH_ENVIRONMENT_KEY
protected BeanFactory getBeanFactory()
public void ejbRemove()
Don't override it (although it can't be made final): code your shutdown in onEjbRemove.
onEjbRemove()
protected void onEjbRemove()
This implementation is empty, to be overridden in subclasses. The same restrictions apply to the work of this method as to an ejbRemove() method.
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |