站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss 4.0.1 sp1 server API Documentation 英文版文档

Container (JBoss Server API) - JBoss 4.0.1 sp1 server API Documentation 英文版文档


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:
AllowedOperationsFlags, ContainerMBean, javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, org.jboss.system.Service, org.jboss.system.ServiceMBean
Direct Known Subclasses:
EntityContainer, MessageDrivenContainer, SessionContainer

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

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.162.2.3 $
Author:
Rickard 锟絙erg, Marc Fleury, Scott Stark., Bill Burke, David Jencks, Christoph G. Jung
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 static Method EJB_TIMEOUT
          A reference to TimedObject.ejbTimeout(javax.ejb.Timer).
protected  EjbModule ejbModule
          This is the application that this container is a part of
protected static Method EJBOBJECT_REMOVE
           
protected  Class homeInterface
          This is the Home interface class
protected  InvocationStatistics invokeStats
          Time statistics for the invoke(Invocation) methods
protected  String jaccContextID
          The JACC context id for the container
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.
static javax.management.ObjectName ORB_NAME
           
protected  HashMap proxyFactories
          HashMap for the invoker bindings
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
 
Fields inherited from interface org.jboss.ejb.AllowedOperationsFlags
IN_AFTER_BEGIN, IN_AFTER_COMPLETION, IN_BEFORE_COMPLETION, IN_BUSINESS_METHOD, IN_EJB_ACTIVATE, IN_EJB_CREATE, IN_EJB_FIND, IN_EJB_HOME, IN_EJB_LOAD, IN_EJB_PASSIVATE, IN_EJB_POST_CREATE, IN_EJB_REMOVE, IN_EJB_STORE, IN_EJB_TIMEOUT, IN_INTERCEPTOR_METHOD, IN_SERVICE_ENDPOINT_METHOD, IN_SET_ENTITY_CONTEXT, IN_SET_MESSAGE_DRIVEN_CONTEXT, IN_SET_SESSION_CONTEXT, IN_UNSET_ENTITY_CONTEXT, NOT_ALLOWED
 
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.
 Context getEnvContext()
          Get the components environment context
 Class getHomeClass()
          this actually should be called remotehome, but for interface compliance purposes we keep it like that
 InvocationStatistics getInvokeStats()
          Gets the invocation statistics collection
 String getJaccContextID()
           
 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()
           
 MessageDestinationMetaData getMessageDestination(String link)
           
 Set getMethodPermissions(Method m, InvocationType iface)
          Returns the permissions for a method.
 EJBProxyFactory getProxyFactory()
           
 RealmMapping getRealmMapping()
           
 Class getRemoteClass()
           
 long getRemoveCount()
          Gets the number of remove invocations that have been made
 AuthenticationManager getSecurityManager()
           
 Object getSecurityProxy()
           
 javax.ejb.TimerService getTimerService(Object pKey)
          Creates the single Timer Servic for this container if not already created
 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)
          The detached invoker operation.
 boolean isCallByValue()
          Whether the bean is call by value
 EJBProxyFactory lookupProxyFactory(String binding)
           
 void removeTimerService(Object pKey)
          Removes Timer Servic for this container
 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 setJaccContextID(String id)
           
 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

ORB_NAME

public static final javax.management.ObjectName ORB_NAME

EJB_CONTAINER_QUERY_NAME

public static final javax.management.ObjectName EJB_CONTAINER_QUERY_NAME

EJBOBJECT_REMOVE

protected static final Method EJBOBJECT_REMOVE

EJB_TIMEOUT

protected static final Method EJB_TIMEOUT
A reference to TimedObject.ejbTimeout(javax.ejb.Timer).


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
HashMap for the invoker bindings


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


jaccContextID

protected String jaccContextID
The JACC context id for the container

Constructor Detail

Container

public Container()
Method Detail

getLocalClass

public Class getLocalClass()

getLocalHomeClass

public Class getLocalHomeClass()

getRemoteClass

public Class getRemoteClass()

getHomeClass

public Class getHomeClass()
this actually should be called remotehome, but for interface compliance purposes we keep it like that


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

getJaccContextID

public String getJaccContextID()

setJaccContextID

public void setJaccContextID(String id)

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 -

getEnvContext

public Context getEnvContext()
                      throws NamingException
Get the components environment context

Specified by:
getEnvContext in interface ContainerMBean
Returns:
Environment Context
Throws:
NamingException

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.


getTimerService

public javax.ejb.TimerService getTimerService(Object pKey)
                                       throws IllegalStateException
Creates the single Timer Servic for this container if not already created

Specified by:
getTimerService in interface ContainerMBean
Parameters:
pKey - Bean id
Returns:
Container Timer Service
Throws:
IllegalStateException - If the type of EJB is not allowed to use the timer service
See Also:
EJBContext.getTimerService()

removeTimerService

public void removeTimerService(Object pKey)
                        throws IllegalStateException
Removes Timer Servic for this container

Specified by:
removeTimerService in interface ContainerMBean
Parameters:
pKey - Bean id
Throws:
IllegalStateException - If the type of EJB is not allowed to use the timer service

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. todo implement the service lifecycle methods in an xmbean interceptor so non lifecycle managed ops are blocked when mbean is not started.

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.

Throws:
Exception

addInterceptor

public abstract void addInterceptor(Interceptor in)

invoke

public Object invoke(Invocation mi)
              throws Exception
The detached invoker operation.

Specified by:
invoke in interface ContainerMBean
Parameters:
mi - - the method invocation context
Returns:
the value of the ejb invocation
Throws:
Exception - on error

getMessageDestination

public MessageDestinationMetaData getMessageDestination(String link)


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