AbstractEnterpriseBean (Spring Framework 3.2.1.RELEASE API)
Date: 2013-01-24

org.springframework.ejb.support

## Class AbstractEnterpriseBean

- java.lang.Object
- - org.springframework.ejb.support.AbstractEnterpriseBean

- All Implemented Interfaces:
    Serializable, EnterpriseBean
  Direct Known Subclasses:
    AbstractMessageDrivenBean, AbstractSessionBean

  Deprecated.
  as of Spring 3.2, in favor of implementing EJBs in EJB 3 style

      @Deprecated
      public abstract class AbstractEnterpriseBean
      extends Object
      implements EnterpriseBean

  Base class for Spring-based EJB 2.x beans. Not intended for direct subclassing: Extend `AbstractStatelessSessionBean`, `AbstractStatefulSessionBean` or `AbstractMessageDrivenBean` instead.

  Provides a standard way of loading a Spring BeanFactory. Subclasses act as a facade, with the business logic deferred to beans in the BeanFactory. Default is to use a `ContextJndiBeanFactoryLocator`, which will initialize an XML ApplicationContext from the class path (based on a JNDI name specified). For a different locator strategy, `setBeanFactoryLocator` may be called (before your EJB's `ejbCreate` method is invoked, e.g. in `setSessionContext`). For use of a shared ApplicationContext between multiple EJBs, where the container class loader setup supports this visibility, you may instead use a `ContextSingletonBeanFactoryLocator`. Alternatively, `setBeanFactoryLocator(org.springframework.beans.factory.access.BeanFactoryLocator)` may be called with a custom implementation of the `BeanFactoryLocator` interface.

  Note that we cannot use `final` for our implementation of EJB lifecycle methods, as this would violate the EJB specification.

  Author:
    Rod Johnson, Colin Sampaleanu, Juergen Hoeller
  See Also:
    `ContextJndiBeanFactoryLocator`, `ContextSingletonBeanFactoryLocator`, Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `BEAN_FACTORY_PATH_ENVIRONMENT_KEY` Deprecated.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractEnterpriseBean()` Deprecated.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `ejbRemove()` Deprecated. EJB lifecycle method, implemented to invoke `onEjbRemove()` and unload the BeanFactory afterwards.
    `protected BeanFactory` | `getBeanFactory()` Deprecated. May be called after `ejbCreate()`.
    `protected void` | `onEjbRemove()` Deprecated. Subclasses must implement this method to do any initialization they would otherwise have done in an `ejbRemove()` method.
    `void` | `setBeanFactoryLocator(BeanFactoryLocator beanFactoryLocator)` Deprecated. Set the BeanFactoryLocator to use for this EJB.
    `void` | `setBeanFactoryLocatorKey(String factoryKey)` Deprecated. Set the bean factory locator key.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### BEAN_FACTORY_PATH_ENVIRONMENT_KEY

          public static final String BEAN_FACTORY_PATH_ENVIRONMENT_KEY

      Deprecated.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### AbstractEnterpriseBean

          public AbstractEnterpriseBean()

      Deprecated.

  - ### Method Detail

    - #### setBeanFactoryLocator

          public void setBeanFactoryLocator(BeanFactoryLocator beanFactoryLocator)

      Deprecated.
      Set the BeanFactoryLocator to use for this EJB. Default is a ContextJndiBeanFactoryLocator.

      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.

      See Also:
        `AbstractStatelessSessionBean.ejbCreate()`, `AbstractMessageDrivenBean.ejbCreate()`, `AbstractStatefulSessionBean.loadBeanFactory()`, `ContextJndiBeanFactoryLocator`

    - #### setBeanFactoryLocatorKey

          public void setBeanFactoryLocatorKey(String factoryKey)

      Deprecated.
      Set the bean factory locator key.

      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 the constructor or `setSessionContext` if you want to override the default locator key.

      See Also:
        `BEAN_FACTORY_PATH_ENVIRONMENT_KEY`

    - #### getBeanFactory

          protected BeanFactory getBeanFactory()

      Deprecated.
      May be called after `ejbCreate()`.
      Returns:
        the bean factory

    - #### ejbRemove

          public void ejbRemove()

      Deprecated.
      EJB lifecycle method, implemented to invoke `onEjbRemove()` and unload the BeanFactory afterwards.

      Don't override it (although it can't be made final): code your shutdown in `onEjbRemove()`.

    - #### onEjbRemove

          protected void onEjbRemove()

      Deprecated.
      Subclasses must implement this method to do any initialization they would otherwise have done in an `ejbRemove()` method. The BeanFactory will be unloaded afterwards.

      This implementation is empty, to be overridden in subclasses. The same restrictions apply to the work of this method as to an `ejbRemove()` method.