org.springframework.ejb.support
Class AbstractMessageDrivenBean

org.springframework.ejb.support.AbstractEnterpriseBean
  |
  +--org.springframework.ejb.support.AbstractMessageDrivenBean
Direct Known Subclasses:
AbstractJmsMessageDrivenBean

public abstract class AbstractMessageDrivenBean
extends AbstractEnterpriseBean
implements MessageDrivenBean

Convenient superclass for MDBs. Doesn't require JMS, as EJB 2.1 MDBs are no longer JMS-specific: see the AbstractJmsMessageDrivenBean subclass.

This class ensures that subclasses have access to the MessageDrivenContext provided by the EJB container, and implement a no argument ejbCreate() method as required by the EJB specification. This ejbCreate() method loads a BeanFactory, before invoking the onEjbCreate() method, which should contain subclass-specific initialization.

NB: We cannot use final methods to implement EJB API methods, as this violates the EJB specification. However, there should be no need to override the setMessageDrivenContext() or ejbCreate() methods.

Author:
Rod Johnson
Version: $Id: AbstractMessageDrivenBean.java,v 1.3 2003/11/18 15:04:08 colins Exp $

Fields inherited from class org.springframework.ejb.support.AbstractEnterpriseBean
BEAN_FACTORY_PATH_ENVIRONMENT_KEY

Method Summary
 voidejbCreate()
          Lifecycle method required by the EJB specification but not the MessageDrivenBean interface.
 voidsetMessageDrivenContext(MessageDrivenContext messageDrivenContext)
          Required lifecycle method.

Methods inherited from class org.springframework.ejb.support.AbstractEnterpriseBean
ejbRemove, loadBeanFactory, setBeanFactoryLocator, setBeanFactoryLocatorKey, unloadBeanFactory

Method Detail

ejbCreate

public void ejbCreate()
Lifecycle method required by the EJB specification but not the MessageDrivenBean interface.

This implementation loads the BeanFactory. Don't override it (although it can't be made final): code your initialization in onEjbCreate(), which is called when the BeanFactory is available.

Unfortunately we can't load the BeanFactory in setSessionContext(), as ResourceManager access isn't permitted and the BeanFactory may require it.


setMessageDrivenContext

public void setMessageDrivenContext(MessageDrivenContext messageDrivenContext)
Required lifecycle method. Sets the MessageDriven context.
Parameters:
messageDrivenContext - MessageDrivenContext