org.jboss.ejb
Class Container

java.lang.Object
  extended byorg.jboss.mx.util.JBossNotificationBroadcasterSupport
      extended byorg.jboss.system.ServiceMBeanSupport
          extended byorg.jboss.ejb.Container
All Implemented Interfaces:
ContainerMBean, javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, org.jboss.system.Service, org.jboss.system.ServiceMBean
Direct Known Subclasses:
EntityContainer, MessageDrivenContainer, StatefulSessionContainer, StatelessSessionContainer

public abstract class Container
extends org.jboss.system.ServiceMBeanSupport
implements ContainerMBean

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 EJBDeployer 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.96.2.25 $
Author:
Rickard �berg, Marc Fleury, Scott Stark., Bill Burke, David Jencks
See Also:
EJBDeployer

Nested Class Summary
protected  class Container.AbstractContainerInterceptor
          The base class for container interceptors.
 
Field Summary
static String BASE_EJB_CONTAINER_NAME
           
protected  Class beanClass
          This is the EnterpriseBean class
protected  ClassLoader classLoader
          This is the classloader of this container.
protected  long createCount
          The number of create invocations that have been made
static javax.management.ObjectName EJB_CONTAINER_QUERY_NAME
           
protected  EjbModule ejbModule
          This is the application that this container is a part of
protected  Class homeInterface
          This is the Home interface class
protected  InvocationStatistics invokeStats
          Time statistics for the invoke(Invocation) methods
protected  ClassLoader localClassLoader
          This is the local classloader of this container.
protected  Class localHomeInterface
          The local home interface class
protected  Class localInterface
          The local inteface class
protected  LocalProxyFactory localProxyFactory
          ???
protected  BeanLockManager lockManager
          This is the bean lock manager that is to be used
protected  Map marshalledInvocationMapping
          Maps for MarshalledInvocation mapping
protected  BeanMetaData metaData
          This is the new metadata.
protected  HashMap proxyFactories
           
protected  ThreadLocal proxyFactoryTL
          The Proxy factory is set in the Invocation.
protected  Class remoteInterface
          This is the Remote interface class
protected  long removeCount
          The number of create invocations that have been made
protected  RealmMapping rm
          This is the realm mapping
protected  Object securityProxy
          The custom security proxy used by the SecurityInterceptor
protected  AuthenticationManager sm
          This is the SecurityManager
protected  TransactionManager tm
          This is the TransactionManager
protected  ClassLoader webClassLoader
          The class loader for remote dynamic classloading
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.system.ServiceMBean
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
Container()
           
 
Method Summary
abstract  void addInterceptor(Interceptor in)
           
 void addProxyFactory(String invokerBinding, EJBProxyFactory factory)
           
 Object createBeanClassInstance()
          Returns a new instance of the bean class or a subclass of the bean class.
protected  void createService()
          The EJBDeployer calls this method.
protected  void destroyService()
          A default implementation of destroying the container service (no-op).
 Class getBeanClass()
          Returns the bean class instance of this container.
 BeanMetaData getBeanMetaData()
          Returns the metadata of this container.
 ClassLoader getClassLoader()
          Returns the classloader for this container.
 long getCreateCount()
          Gets the number of create invocations that have been made
 org.jboss.deployment.DeploymentInfo getDeploymentInfo()
          Gets the DeploymentInfo for this Container
 EjbModule getEjbModule()
          Gets the application deployment unit for this container.
 InvocationStatistics getInvokeStats()
          Gets the invocation statistics collection
 javax.management.ObjectName getJmxName()
          Build a JMX name using the pattern jboss.j2ee:service=EJB,jndiName=[jndiName] where the [jndiName] is either the bean remote home JNDI binding, or the local home JNDI binding if the bean has no remote interfaces.
 Class getLocalClass()
           
 ClassLoader getLocalClassLoader()
          Returns the local classloader for this container.
 Class getLocalHomeClass()
           
 BeanLockManager getLockManager()
           
 Set getMethodPermissions(Method m, InvocationType iface)
          Returns the permissions for a method.
 EJBProxyFactory getProxyFactory()
           
 RealmMapping getRealmMapping()
           
 long getRemoveCount()
          Gets the number of remove invocations that have been made
 AuthenticationManager getSecurityManager()
           
 Object getSecurityProxy()
           
 TransactionManager getTransactionManager()
          Returns this container's transaction manager.
 ClassLoader getWebClassLoader()
          Get the class loader for dynamic class loading via http.
abstract  Object internalInvoke(Invocation mi)
          This method is called when a method call comes in on an EJBObject.
abstract  Object internalInvokeHome(Invocation mi)
          This method is called when a method call comes in on the Home object.
 Object invoke(Invocation mi)
           
 boolean isCallByValue()
          Whether the bean is call by value
 EJBProxyFactory lookupProxyFactory(String binding)
           
 void setBeanMetaData(BeanMetaData metaData)
          Sets the meta data for this container.
 void setClassLoader(ClassLoader cl)
          Sets the class loader for this container.
 void setDeploymentInfo(org.jboss.deployment.DeploymentInfo di)
          Sets the DeploymentInfo of this Container
 void setEjbModule(EjbModule app)
          Sets the application deployment unit for this container.
 void setLocalClassLoader(ClassLoader cl)
          Sets the local class loader for this container.
 void setLockManager(BeanLockManager lockManager)
           
 void setProxyFactory(Object factory)
           
 void setRealmMapping(RealmMapping rm)
           
 void setSecurityManager(AuthenticationManager sm)
           
 void setSecurityProxy(Object proxy)
           
 void setTransactionManager(TransactionManager tm)
          Sets a transaction manager for this container.
 void setWebClassLoader(ClassLoader webClassLoader)
          Set the class loader for dynamic class loading via http.
protected  void startService()
          A default implementation of starting the container service.
protected  void stopService()
          A default implementation of stopping the container service (no-op).
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport
create, destroy, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, stop
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.system.ServiceMBean
getName, getState, getStateString, jbossInternalLifecycle
 
Methods inherited from interface org.jboss.system.Service
create, destroy, start, stop
 

Field Detail

BASE_EJB_CONTAINER_NAME

public static final String BASE_EJB_CONTAINER_NAME
See Also:
Constant Field Values

EJB_CONTAINER_QUERY_NAME

public static final javax.management.ObjectName EJB_CONTAINER_QUERY_NAME

ejbModule

protected EjbModule ejbModule
This is the application that this container is a part of


localClassLoader

protected ClassLoader localClassLoader
This is the local classloader of this container. Used for loading resources that must come from the local jar file for the container. NOT for loading classes!


classLoader

protected ClassLoader classLoader
This is the classloader of this container. All classes and resources that the bean uses will be loaded from here. By doing this we make the bean re-deployable


webClassLoader

protected ClassLoader webClassLoader
The class loader for remote dynamic classloading


metaData

protected BeanMetaData metaData
This is the new metadata. it includes information from both ejb-jar and jboss.xml the metadata for the application can be accessed trough metaData.getApplicationMetaData()


beanClass

protected Class beanClass
This is the EnterpriseBean class


homeInterface

protected Class homeInterface
This is the Home interface class


remoteInterface

protected Class remoteInterface
This is the Remote interface class


localHomeInterface

protected Class localHomeInterface
The local home interface class


localInterface

protected Class localInterface
The local inteface class


tm

protected TransactionManager tm
This is the TransactionManager


sm

protected AuthenticationManager sm
This is the SecurityManager


rm

protected RealmMapping rm
This is the realm mapping


securityProxy

protected Object securityProxy
The custom security proxy used by the SecurityInterceptor


lockManager

protected BeanLockManager lockManager
This is the bean lock manager that is to be used


localProxyFactory

protected LocalProxyFactory localProxyFactory
???


marshalledInvocationMapping

protected Map marshalledInvocationMapping
Maps for MarshalledInvocation mapping


proxyFactories

protected HashMap proxyFactories

proxyFactoryTL

protected ThreadLocal proxyFactoryTL
The Proxy factory is set in the Invocation. This TL is used for methods that do not have access to the Invocation.


createCount

protected long createCount
The number of create invocations that have been made


removeCount

protected long removeCount
The number of create invocations that have been made


invokeStats

protected InvocationStatistics invokeStats
Time statistics for the invoke(Invocation) methods

Constructor Detail

Container

public Container()
Method Detail

getLocalClass

public Class getLocalClass()

getLocalHomeClass

public Class getLocalHomeClass()

isCallByValue

public boolean isCallByValue()
Whether the bean is call by value

Returns:
true for call by value

setTransactionManager

public void setTransactionManager(TransactionManager tm)
Sets a transaction manager for this container.

Parameters:
tm -
See Also:
TransactionManager

getTransactionManager

public 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()

getLockManager

public BeanLockManager getLockManager()

setLockManager

public void setLockManager(BeanLockManager lockManager)

addProxyFactory

public void addProxyFactory(String invokerBinding,
                            EJBProxyFactory factory)

setRealmMapping

public void setRealmMapping(RealmMapping rm)

getRealmMapping

public RealmMapping getRealmMapping()

setSecurityProxy

public void setSecurityProxy(Object proxy)

getSecurityProxy

public Object getSecurityProxy()

getProxyFactory

public EJBProxyFactory getProxyFactory()

setProxyFactory

public void setProxyFactory(Object factory)

lookupProxyFactory

public EJBProxyFactory lookupProxyFactory(String binding)

getDeploymentInfo

public final org.jboss.deployment.DeploymentInfo getDeploymentInfo()
Gets the DeploymentInfo for this Container

Returns:
The DeploymentInfo for this Container

setDeploymentInfo

public final void setDeploymentInfo(org.jboss.deployment.DeploymentInfo di)
Sets the DeploymentInfo of this Container

Parameters:
di - The new DeploymentInfo to be used

setEjbModule

public void setEjbModule(EjbModule 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

getEjbModule

public EjbModule getEjbModule()
Gets the application deployment unit for this container. All the bean containers within the same application unit share the same instance.

Specified by:
getEjbModule in interface ContainerMBean

getCreateCount

public long getCreateCount()
Gets the number of create invocations that have been made

Specified by:
getCreateCount in interface ContainerMBean

getRemoveCount

public long getRemoveCount()
Gets the number of remove invocations that have been made

Specified by:
getRemoveCount in interface ContainerMBean

getInvokeStats

public InvocationStatistics getInvokeStats()
Gets the invocation statistics collection

Specified by:
getInvokeStats in interface ContainerMBean

setLocalClassLoader

public void setLocalClassLoader(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 ClassLoader getLocalClassLoader()
Returns the local classloader for this container.

Returns:
The local classloader for this container.

setClassLoader

public void setClassLoader(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 ClassLoader getClassLoader()
Returns the classloader for this container.

Returns:

getWebClassLoader

public ClassLoader getWebClassLoader()
Get the class loader for dynamic class loading via http.


setWebClassLoader

public void setWebClassLoader(ClassLoader webClassLoader)
Set the class loader for dynamic class loading via http.


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.

Specified by:
getBeanMetaData in interface ContainerMBean
Returns:
metaData;

getMethodPermissions

public Set getMethodPermissions(Method m,
                                InvocationType iface)
Returns the permissions for a method. (a set of roles)

Returns:
assemblyDescriptor;

getBeanClass

public Class getBeanClass()
Returns the bean class instance of this container.

Returns:
instance of the Enterprise bean class.

createBeanClassInstance

public Object createBeanClassInstance()
                               throws 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
Throws:
Exception
See Also:
Class.newInstance()

getJmxName

public javax.management.ObjectName getJmxName()
Build a JMX name using the pattern jboss.j2ee:service=EJB,jndiName=[jndiName] where the [jndiName] is either the bean remote home JNDI binding, or the local home JNDI binding if the bean has no remote interfaces.


createService

protected void createService()
                      throws Exception
The EJBDeployer calls this method. The EJBDeployer 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:
Exception - if loading the bean class failed (ClassNotFoundException) or setting up "java:" naming environment failed (DeploymentException)

startService

protected void startService()
                     throws Exception
A default implementation of starting the container service. The container registers it's dynamic MBean interface in the JMX base. The concrete container classes should override this method to introduce implementation specific start behaviour.

Throws:
Exception - An exception that occured during start

stopService

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

Throws:
Exception

destroyService

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

Throws:
Exception

internalInvokeHome

public abstract Object internalInvokeHome(Invocation mi)
                                   throws Exception
This method is called 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:
Exception

internalInvoke

public abstract Object internalInvoke(Invocation mi)
                               throws Exception
This method is called when a method call comes in on an EJBObject. The Container forwards this call to the interceptor chain for further processing.

Parameters:
mi - - the method invocation representation
Returns:
the result of the invocation
Throws:
Exception

addInterceptor

public abstract void addInterceptor(Interceptor in)

invoke

public Object invoke(Invocation mi)
              throws Exception
Specified by:
invoke in interface ContainerMBean
Parameters:
mi -
Returns:
Throws:
Exception


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.