30.3.2. Container Plug-in Framework

The JBoss EJB container uses a framework pattern that allows one to change implementations of various aspects of the container behavior. The container itself does not perform any significant work other than connecting the various behavioral components together. Implementations of the behavioral components are referred to as plug-ins, because you can plug in a new implementation by changing a container configuration. Examples of plug-in behavior you may want to change include persistence management, object pooling, object caching, container invokers and interceptors. There are four subclasses of the org.jboss.ejb.Container class, each one implementing a particular bean type:
  • org.jboss.ejb.EntityContainer: handles javax.ejb.EntityBean types
  • org.jboss.ejb.StatelessSessionContainer: handles Stateless javax.ejb.SessionBean types
  • org.jboss.ejb.StatefulSessionContainer: handles Stateful javax.ejb.SessionBean types
  • org.jboss.ejb.MessageDrivenContainer handles javax.ejb.MessageDrivenBean types
The EJB containers delegate much of their behavior to components known as container plug-ins. The interfaces that make up the container plug-in points include the following:
  • org.jboss.ejb.ContainerPlugin
  • org.jboss.ejb.ContainerInvoker
  • org.jboss.ejb.Interceptor
  • org.jboss.ejb.InstancePool
  • org.jboss.ejb.InstanceCache
  • org.jboss.ejb.EntityPersistanceManager
  • org.jboss.ejb.EntityPersistanceStore
  • org.jboss.ejb.StatefulSessionPersistenceManager
The container's main responsibility is to manage its plug-ins. This means ensuring that the plug-ins have all the information they need to implement their functionality.

30.3.2.1. org.jboss.ejb.ContainerPlugin

The ContainerPlugin interface is the parent interface of all container plug-in interfaces. It provides a callback that allows a container to provide each of its plug-ins a pointer to the container the plug-in is working on behalf of. The ContainerPlugin interface is given below.

Example 30.4. The org.jboss.ejb.ContainerPlugin interface

public interface ContainerPlugin
    extends Service, AllowedOperationsFlags
{
    /** co
     * This callback is set by the container so that the plugin
     * may access its container
     *
     * @param con the container which owns the plugin
     */
    public void setContainer(Container con);
}