FileDocCategorySizeDatePackage
Container.javaAPI DocGlassfish v2 API12378Fri May 04 22:32:54 BST 2007com.sun.ejb

Container

public interface Container
A Container stores EJB instances and is responsible for the lifecycle, state management, concurrency, transactions, security, naming, resource management, etc. It does the above by interposing actions before and after invocations on EJBs. It uses the ProtocolManager, SecurityManager, TransactionManager, NamingManager for help with the above responsibilities. There are four types of Containers: StatefulSessionContainer, StatelessSessionContainer, EntityContainer, and MessageBeanContainer. Note: the term "Container" here refers to an instance of one of the above container classes. In the EJB spec "container" refers to a process or JVM which hosts EJB instances.

There is one instance of the Container for each EJB type (deployment desc). When a JAR is deployed on the EJB server, a Container instance is created for each EJB declared in the ejb-jar.xml for the EJB JAR.

The Container interface provides methods called from other parts of the RI as well as from generated EJBHome/EJBObject implementations.

Fields Summary
public int
TX_NOT_INITIALIZED
public int
TX_NOT_SUPPORTED
public int
TX_BEAN_MANAGED
public int
TX_REQUIRED
public int
TX_SUPPORTS
public int
TX_REQUIRES_NEW
public int
TX_MANDATORY
public int
TX_NEVER
public String[]
txAttrStrings
public int
SEC_NOT_INITIALIZED
public int
SEC_UNCHECKED
public int
SEC_EXCLUDED
public int
SEC_CHECKED
public String[]
secAttrStrings
Constructors Summary
Methods Summary
public voidassertValidLocalObject(java.lang.Object o)
Verify that a given object is an EJBLocalObject of an ejb from this ejb container. The given object must be an EJBLocalObject and have the same ejb type ( meaning same ejb-jar and same ejb-name ) as this container. Note that for entity beans this equality check is independent of primary key.

exception
EJBException Thrown when the assertion fails.

public voidassertValidRemoteObject(java.lang.Object o)
Verify that a given object is an EJBObject of an ejb from this ejb container. The given object must be an EJBObject and have the same ejb type ( meaning same ejb-jar and same ejb-name ) as this container. Note that for entity beans this equality check is independent of primary key.

exception
EJBException Thrown when the assertion fails.

public booleanauthorize(Invocation inv)
Go through ejb container to do ejb security manager authorization.

public voiddoAfterApplicationDeploy()
Called after all the components in the container's application have deployed successfully. Allows containers to delay public access to their resources until the end of the deployment process.

public voiddoAfterBegin(com.sun.enterprise.ComponentInvocation ci)
Called from the TM when an EJB with Bean-Managed transactions starts a tx

public voidexternalPostInvoke()
Performs post external invocation cleanup such as restoring the original class loader. Called by releaseTargetObject() and web service inv

public voidexternalPreInvoke()
Performs pre external invocation setup such as setting application context class loader. Called by getTargetObject() and web service inv

public java.lang.ClassLoadergetClassLoader()

return
the classloader of this container instance.

public java.lang.StringgetComponentId()
Called from NamingManagerImpl during java:comp/env lookup.

public EJBHomegetEJBHome()

return
the EJBHome object reference for this container instance.

public EJBLocalObjectgetEJBLocalObjectForPrimaryKey(java.lang.Object pkey, EJBContext ctx)
Obtain an Entity EJBLocalObject corresponding to the primary key. Used by the PersistenceManager.

public EJBLocalObjectgetEJBLocalObjectForPrimaryKey(java.lang.Object pkey)

public EJBMetaDatagetEJBMetaData()

return
the MetaData for this EJB type.

public EJBObjectgetEJBObjectForPrimaryKey(java.lang.Object pkey)
Obtain an Entity EJBObject corresponding to the primary key. Used by the PersistenceManager.

public com.sun.enterprise.deployment.EjbDescriptorgetEjbDescriptor()

return
the EjbDescriptor containing deployment information for the EJB type corresponding to this Container instance.

public java.lang.ObjectgetJaccEjb(Invocation inv)
Used by Invocation during JACC EnterpriseBean policy handler request for target EnterpriseBean instance.

return
EnterpriseBean instance or null if not applicable for this invocation.

public com.sun.enterprise.SecurityManagergetSecurityManager()

return
A SecurityManager object for this container.

public java.rmi.RemotegetTargetObject(byte[] instanceKey, java.lang.String remoteBusinessIntf)
Return the EJBObject/EJBHome for the given instanceKey.

param
remoteHomeView True if this invocation is for the RemoteHome view of the bean. False if for the RemoteBusiness view. Called from the ProtocolManager when a remote invocation arrives.

public voidonReady()
Called when server instance is Ready

public voidonShutdown()
Called when server instance is shuting down

public voidonTermination()
Called when server instance is terminating. This method is the last one called during server shutdown.

public voidpostCreate(Invocation inv, java.lang.Object primaryKey)
Called by the EJB(Local)Home after invoking ejbCreate on an EntityBean. After this postCreate the EJB(Local)Home can call ejbPostCreate on the EntityBean.

param
primaryKey the value returned from ejbCreate.

public java.lang.ObjectpostFind(Invocation inv, java.lang.Object primaryKeys, java.lang.Object[] findParams)
Called by the EJB(Local)Home after invoking ejbFind* on an EntityBean.

param
primaryKeys the primaryKey or collection of primaryKeys (Collection/Enumeration) returned from ejbFind.
param
findParams the parameters to the ejbFind method.
return
an EJBObject reference or Collection/Enumeration of EJBObjects.

public voidpostInvoke(Invocation inv)
Called by the EJB(Local)Object/EJB(Local)Home after an invocation on a bean.

public voidpreInvoke(Invocation inv)
Called by the EJB(Local)Object/EJB(Local)Home before an invocation on a bean.

public voidpreSelect()
Notification from persistence manager than an ejbSelect query is about to be invoked on a bean of the ejb type for this container. This allows the ejb container to perform the same set of actions as take place before a finder method, such as calling ejbStore on bean instances. (See EJB 2.1, Section 10.5.3 ejbFind,ejbStore)

exception
javax.ejb.EJBException Thrown if an error occurs during the preSelect actions performed by the container. If thrown, the remaining select query steps should be aborted and an EJBException should be propagated back to the application code.

public voidreleaseTargetObject(java.rmi.Remote remoteObj)
Release the EJBObject/EJBHome object. Called from the ProtocolManager after a remote invocation completes.

public voidremoveBeanUnchecked(EJBLocalObject bean)
Remove a bean. Used by the PersistenceManager.

public voidremoveBeanUnchecked(java.lang.Object pkey)
Remove a bean given primary key. Used by the PersistenceManager.

public voidsetStartedState()
Start servicing invocations for EJB instances in this Container.

public voidsetStoppedState()
Stop servicing invocations for EJB instances in this Container. Subsequent EJB invocations will receive exceptions. Invocations already in progress will be allowed to complete eventually.

public voidsetUndeployedState()
Stop servicing invocations for EJB instances in this Container as the container is being undeployed. No new EJB invocations will be accepted from now on. Invocations already in progress will be allowed to complete eventually.

public voidundeploy()
Called from EJB JarManager when an application is undeployed.

public booleanuserTransactionMethodsAllowed(com.sun.enterprise.ComponentInvocation inv)
EJB spec makes a distinction between access to the UserTransaction object itself and access to its methods. getUserTransaction covers the first check and this method covers the second. It is called by the UserTransaction implementation to verify access.

public voidwebServicePostInvoke(Invocation inv)
Called by webservice code to do ejb invocation post processing.