@Deprecated public abstract class AbstractStatelessSessionBean extends AbstractSessionBean
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.
Modifier and Type | Field and Description |
---|---|
protected Log |
logger
Deprecated.
Logger available to subclasses
|
BEAN_FACTORY_PATH_ENVIRONMENT_KEY
Constructor and Description |
---|
AbstractStatelessSessionBean()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
ejbActivate()
Deprecated.
This method always throws an exception, as it should not be invoked by the EJB container.
|
void |
ejbCreate()
Deprecated.
This implementation loads the BeanFactory.
|
void |
ejbPassivate()
Deprecated.
This method always throws an exception, as it should not be invoked by the EJB container.
|
protected abstract void |
onEjbCreate()
Deprecated.
Subclasses must implement this method to do any initialization
they would otherwise have done in an
ejbCreate() method. |
getSessionContext, setSessionContext
ejbRemove, getBeanFactory, onEjbRemove, setBeanFactoryLocator, setBeanFactoryLocatorKey
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
ejbRemove
protected final Log logger
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
EJBException
SessionBean.ejbActivate()
public void ejbPassivate() throws EJBException
EJBException
SessionBean.ejbPassivate()