## org.jboss.ejb
Class Container

    java.lang.Object
      |
      +--org.jboss.ejb.Container

Direct Known Subclasses:
  EntityContainer, MessageDrivenContainer, StatefulSessionContainer, StatelessSessionContainer

public abstract class Container
extends java.lang.Object

This is the base class for all EJB-containers in JBoss. A Container functions as the central hub of all metadata and plugins. Through this the container plugins can get hold of the other plugins and any metadata they need. The ContainerFactory creates instances of subclasses of this class and calls the appropriate initialization methods. A Container does not perform any significant work, but instead delegates to the plugins to provide for all kinds of algorithmic functionality.

Version:
  $Revision: 1.44.2.10 $
Author:
  Rickard Öberg (rickard.oberg@telkel.com), Marc Fleury, Scott.Stark@jboss.org
See Also:
  `ContainerFactory`

Field Summary
`protected Application` `application`
`protected java.lang.Class` `beanClass`
`protected java.lang.ClassLoader` `classLoader`
`protected java.lang.ClassLoader` `localClassLoader`
`protected LocalContainerInvoker` `localContainerInvoker`
`protected java.lang.Class` `localHomeInterface`
`protected java.lang.Class` `localInterface`
`protected BeanLockManager` `lockManager` This is the bean lock manager that is to be used
`protected Logger` `log` Instance logger.
`protected BeanMetaData` `metaData`
`protected RealmMapping` `rm`
`protected java.lang.Object` `securityProxy` The custom security proxy used by the SecurityInterceptor
`protected AuthenticationManager` `sm`
`protected javax.transaction.TransactionManager` `tm`

Constructor Summary
`Container()`

Method Summary
`abstract void` `addInterceptor(Interceptor in)`
`java.lang.Object` `createBeanClassInstance()` Returns a new instance of the bean class or a subclass of the bean class.
`void` `destroy()` A default implementation of destroying the container service (no-op).
`Application` `getApplication()` Returns the application for this container.
`java.lang.Class` `getBeanClass()` Returns the bean class instance of this container.
`BeanMetaData` `getBeanMetaData()` Returns the metadata of this container.
`java.lang.ClassLoader` `getClassLoader()` Returns the classloader for this container.
`java.lang.Class` `getLocalClass()`
`java.lang.ClassLoader` `getLocalClassLoader()` Returns the local classloader for this container.
`java.lang.Class` `getLocalHomeClass()`
`BeanLockManager` `getLockManager()`
`java.util.Set` `getMethodPermissions(java.lang.reflect.Method m, boolean home)` Returns the permissions for a method.
`RealmMapping` `getRealmMapping()`
`AuthenticationManager` `getSecurityManager()`
`java.lang.Object` `getSecurityProxy()`
`javax.transaction.TransactionManager` `getTransactionManager()` Returns this container's transaction manager.
`void` `init()` The ContainerFactory calls this method.
`abstract java.lang.Object` `invoke(MethodInvocation mi)` This method is called by the ContainerInvoker when a method call comes in on an EJBObject.
`abstract java.lang.Object` `invokeHome(MethodInvocation mi)` This method is called by the ContainerInvoker when a method call comes in on the Home object.
`void` `setApplication(Application app)` Sets the application deployment unit for this container.
`void` `setBeanMetaData(BeanMetaData metaData)` Sets the meta data for this container.
`void` `setClassLoader(java.lang.ClassLoader cl)` Sets the class loader for this container.
`void` `setLocalClassLoader(java.lang.ClassLoader cl)` Sets the local class loader for this container.
`void` `setLockManager(BeanLockManager lockManager)`
`void` `setRealmMapping(RealmMapping rm)`
`void` `setSecurityManager(AuthenticationManager sm)`
`void` `setSecurityProxy(java.lang.Object proxy)`
`void` `setTransactionManager(javax.transaction.TransactionManager tm)` Sets a transaction manager for this container.
`void` `start()` A default implementation of starting the container service (no-op).
`void` `stop()` A default implementation of stopping the container service (no-op).

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### log

    protected Logger log

  Instance logger.

### application

    protected Application application

### localClassLoader

    protected java.lang.ClassLoader localClassLoader

### classLoader

    protected java.lang.ClassLoader classLoader

### metaData

    protected BeanMetaData metaData

### beanClass

    protected java.lang.Class beanClass

### tm

    protected javax.transaction.TransactionManager tm

### sm

    protected AuthenticationManager sm

### rm

    protected RealmMapping rm

### securityProxy

    protected java.lang.Object securityProxy

  The custom security proxy used by the SecurityInterceptor

### localContainerInvoker

    protected LocalContainerInvoker localContainerInvoker

### localHomeInterface

    protected java.lang.Class localHomeInterface

### localInterface

    protected java.lang.Class localInterface

### lockManager

    protected BeanLockManager lockManager

  This is the bean lock manager that is to be used

Constructor Detail

### Container

    public Container()

Method Detail

### getLockManager

    public BeanLockManager getLockManager()

### setLockManager

    public void setLockManager(BeanLockManager lockManager)

### getLocalClass

    public java.lang.Class getLocalClass()

### getLocalHomeClass

    public java.lang.Class getLocalHomeClass()

### createBeanClassInstance

    public java.lang.Object createBeanClassInstance()
                                             throws java.lang.Exception

  Returns a new instance of the bean class or a subclass of the bean class. This factory style method is speciffically used by a container to supply an implementation of the abstract accessors in EJB2.0, but could be usefull in other situations. This method should ALWAYS be used instead of getBeanClass().newInstance();
  Returns:
    the new instance
  See Also:
    `Class.newInstance()`

### setTransactionManager

    public void setTransactionManager(javax.transaction.TransactionManager tm)

  Sets a transaction manager for this container.
  Parameters:
    `tm` -
  See Also:
    `TransactionManager`

### getTransactionManager

    public javax.transaction.TransactionManager getTransactionManager()

  Returns this container's transaction manager.
  Returns:
    a concrete instance of javax.transaction.TransactionManager

### setSecurityManager

    public void setSecurityManager(AuthenticationManager sm)

### getSecurityManager

    public AuthenticationManager getSecurityManager()

### setRealmMapping

    public void setRealmMapping(RealmMapping rm)

### getRealmMapping

    public RealmMapping getRealmMapping()

### setSecurityProxy

    public void setSecurityProxy(java.lang.Object proxy)

### getSecurityProxy

    public java.lang.Object getSecurityProxy()

### setApplication

    public void setApplication(Application app)

  Sets the application deployment unit for this container. All the bean containers within the same application unit share the same instance.
  Parameters:
    `app` - application for this container

### getApplication

    public Application getApplication()

  Returns the application for this container.
  Returns:

### setLocalClassLoader

    public void setLocalClassLoader(java.lang.ClassLoader cl)

  Sets the local class loader for this container. Used for loading resources from the local jar file for this container. NOT for loading classes!
  Parameters:
    `cl` -

### getLocalClassLoader

    public java.lang.ClassLoader getLocalClassLoader()

  Returns the local classloader for this container.
  Returns:

### setClassLoader

    public void setClassLoader(java.lang.ClassLoader cl)

  Sets the class loader for this container. All the classes and resources used by the bean in this container will use this classloader.
  Parameters:
    `cl` -

### getClassLoader

    public java.lang.ClassLoader getClassLoader()

  Returns the classloader for this container.
  Returns:

### setBeanMetaData

    public void setBeanMetaData(BeanMetaData metaData)

  Sets the meta data for this container. The meta data consists of the properties found in the XML descriptors.
  Parameters:
    `metaData` -

### getBeanMetaData

    public BeanMetaData getBeanMetaData()

  Returns the metadata of this container.
  Returns:
    metaData;

### getMethodPermissions

    public java.util.Set getMethodPermissions(java.lang.reflect.Method m,
                                              boolean home)

  Returns the permissions for a method. (a set of roles)
  Returns:
    assemblyDescriptor;

### getBeanClass

    public java.lang.Class getBeanClass()

  Returns the bean class instance of this container.
  Returns:
    instance of the Enterprise bean class

### init

    public void init()
              throws java.lang.Exception

  The ContainerFactory calls this method. The ContainerFactory has set all the plugins and interceptors that this bean requires and now proceeds to initialize the chain. The method looks for the standard classes in the URL, sets up the naming environment of the bean. The concrete container classes should override this method to introduce implementation specific initialization behaviour.
  Throws:
    `java.lang.Exception` - if loading the bean class failed (ClassNotFoundException) or setting up "java:" naming environment failed (DeploymentException)

### start

    public void start()
               throws java.lang.Exception

  A default implementation of starting the container service (no-op). The concrete container classes should override this method to introduce implementation specific start behaviour.
  Throws:
    `java.lang.Exception` - an exception that occured during start

### stop

    public void stop()

  A default implementation of stopping the container service (no-op). The concrete container classes should override this method to introduce implementation specific stop behaviour.

### destroy

    public void destroy()

  A default implementation of destroying the container service (no-op). The concrete container classes should override this method to introduce implementation specific destroy behaviour.

### invokeHome

    public abstract java.lang.Object invokeHome(MethodInvocation mi)
                                         throws java.lang.Exception

  This method is called by the ContainerInvoker when a method call comes in on the Home object. The Container forwards this call to the interceptor chain for further processing.
  Parameters:
    `mi` - the object holding all info about this invocation
  Returns:
    the result of the home invocation
  Throws:
    `java.lang.Exception` -

### invoke

    public abstract java.lang.Object invoke(MethodInvocation mi)
                                     throws java.lang.Exception

  This method is called by the ContainerInvoker when a method call comes in on an EJBObject. The Container forwards this call to the interceptor chain for further processing.
  Parameters:
    `id` - the id of the object being invoked. May be null if stateless
    `method` - the method being invoked
    `args` - the parameters
  Returns:
    the result of the invocation
  Throws:
    `java.lang.Exception` -

### addInterceptor

    public abstract void addInterceptor(Interceptor in)

Copyright © 2000 The JBoss Organization. All Rights Reserved.