org.openejb.core
Class DeploymentInfo

java.lang.Object
  extended by org.openejb.core.DeploymentInfo
All Implemented Interfaces:
DeploymentInfo

public class DeploymentInfo
extends java.lang.Object
implements DeploymentInfo

Contains all the information needed by the container for a particular deployment. Some of this information is generic, but this class is largely becoming a dumping ground for information specific to individual containers. This class should be abstracted and subclassed in the individual container packages. The container should be required to provide its own DeploymentInfo implementation, possibly returning it to the assembler and OpenEJB in general via a new accessor method.

Version:
$Revision: 2112 $ $Date: 2005-08-26 14:28:34 -0700 (Fri, 26 Aug 2005) $
Author:
Richard Monson-Haefel, David Blevins

Field Summary
 
Fields inherited from interface org.openejb.DeploymentInfo
AC_CREATE_EJBHOME, BMP_ENTITY, CMP_ENTITY, MESSAGE_DRIVEN, STATEFUL, STATELESS, TX_MANDITORY, TX_NEVER, TX_NOT_SUPPORTED, TX_REQUIRED, TX_REQUIRES_NEW, TX_SUPPORTS
 
Constructor Summary
DeploymentInfo(DeploymentContext context, java.lang.Class homeClass, java.lang.Class remoteClass, java.lang.Class localHomeClass, java.lang.Class localClass, java.lang.Class beanClass, java.lang.Class pkClass, byte componentType)
          Constructs a DeploymentInfo object to represent the specified bean's deployment information.
 
Method Summary
 void addQuery(java.lang.reflect.Method queryMethod, java.lang.String queryString)
          This method maps a query method (ejbFind) to a query string.
 void addSecurityRoleReference(java.lang.String securityRoleReference, java.lang.String[] physicalRoles)
          Adds a security-role-ref to physical role mapping.
 void appendMethodPermissions(java.lang.reflect.Method m, java.lang.String[] roleNames)
          Appends a Method and a list of authorized roles to the internal list of mehtod permissions.
 java.lang.Object convertIfLocalReference(java.lang.reflect.Method businessMethod, java.lang.Object returnValue)
          Business methods that return EJBHome or EJBObject references to local beans (beans in the same container system) must have the return value converted to a ProxyInfo object, so that the server can provide the client with a proper remote reference.
protected  java.lang.String extractHomeBeanMethodName(java.lang.String methodName)
           
 java.lang.String[] getAuthorizedRoles(java.lang.reflect.Method method)
          Gets the roles that are authorised to execute this method.
 java.lang.String[] getAuthorizedRoles(java.lang.String action)
           
 java.lang.Class getBeanClass()
          Gets the bean's class definition.
 java.lang.String[] getCmrFields()
          Returns the names of the bean's container-managed fields.
 byte getComponentType()
          Gets the type of this bean component.
 Container getContainer()
          Gets the the container that this deployed bean is in.
 java.lang.reflect.Method getCreateMethod()
          Used for stateless session beans only
 java.lang.Object getDeploymentID()
          Gets the id of this bean deployment.
 javax.ejb.EJBContext getEJBContext()
          Gets the EJBContext this container manager will expose to the Containers it manages.
 javax.ejb.EJBHome getEJBHome()
          Gets the EJBHome object of this bean deployment.
 javax.ejb.EJBLocalHome getEJBLocalHome()
           
 java.lang.Class getHomeInterface()
          Gets the home interface for the bean deployment.
 javax.naming.Context getJndiEnc()
          Gets the JNDI namespace for the bean's environment.
 KeyGenerator getKeyGenerator()
           
 java.lang.Class getLocalHomeInterface()
           
 java.lang.Class getLocalInterface()
           
 java.lang.reflect.Method getMatchingBeanMethod(java.lang.reflect.Method interfaceMethod)
          Returns a method in the bean class that matches the method passed in.
 java.lang.reflect.Method getMatchingPostCreateMethod(java.lang.reflect.Method createMethod)
          Used for entity beans only.
 java.lang.String[] getPhysicalRole(java.lang.String securityRoleReference)
          Beans can test to see if the current principal is a member of a specified role using the method EJBContext.isPrincipalInRole(String roleName).
 java.lang.Class getPrimaryKeyClass()
          Gets the Class type of the primary key for this bean deployment.
 java.lang.reflect.Field getPrimaryKeyField()
          Gets the Field of the CMP entity bean class which corresponds to the simple primary key.
 java.lang.String getQuery(java.lang.reflect.Method queryMethod)
          This method retrieves the query string associated with the query method.
 java.lang.Class getRemoteInterface()
          Gets the remote interface for the bean deployment.
 byte getTransactionAttribute(java.lang.reflect.Method method)
          Gets the transaction attribute that must be applied to this method when executing.
 TransactionPolicy getTransactionPolicy(java.lang.reflect.Method method)
           
 boolean isBeanManagedTransaction()
          Returns true if this bean deployment has chosen bean-managed transaction demarcation.
 boolean isReentrant()
          Returns true if the bean deployment allows reenterace.
 void setBeanManagedTransaction(boolean value)
          Sets this bean deployment to container-managed or bean-managed transaction demarcation.
 void setCmrFields(java.lang.String[] cmrFields)
           
 void setContainer(Container cont)
          Container must have its Container set explicitly by the Assembler to avoid a chicken and egg problem: Which is created first the container or the DeploymentInfo This assembler will invoke this method when needed.
 void setIsReentrant(boolean reentrant)
           
 void setKeyGenerator(KeyGenerator keyGenerator)
           
 void setMethodTransactionAttribute(java.lang.reflect.Method method, java.lang.String transAttribute)
          Sets the transaction attribute of the method in the bean's class.
 void setPrimKeyField(java.lang.String fieldName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeploymentInfo

public DeploymentInfo(DeploymentContext context,
                      java.lang.Class homeClass,
                      java.lang.Class remoteClass,
                      java.lang.Class localHomeClass,
                      java.lang.Class localClass,
                      java.lang.Class beanClass,
                      java.lang.Class pkClass,
                      byte componentType)
               throws SystemException
Constructs a DeploymentInfo object to represent the specified bean's deployment information.

Parameters:
did - the id of this bean deployment
homeClass - the bean's home interface definition
remoteClass - the bean's remote interface definition
beanClass - the bean's class definition
pkClass - the bean's primary key class
componentType - one of the component type constants defined in org.openejb.DeploymentInfo
Throws:
SystemException
See Also:
Container.getContainerID(), DeploymentInfo.STATEFUL, DeploymentInfo.STATELESS, DeploymentInfo.BMP_ENTITY, DeploymentInfo.CMP_ENTITY
Method Detail

setContainer

public void setContainer(Container cont)
Container must have its Container set explicitly by the Assembler to avoid a chicken and egg problem: Which is created first the container or the DeploymentInfo This assembler will invoke this method when needed. The Container must be set before the bean is ready to process requests.

Parameters:
cont -

getComponentType

public byte getComponentType()
Gets the type of this bean component. Will return a STATEFUL, STATELESS, BMP_ENTITY or CMP_ENTITY.

Specified by:
getComponentType in interface DeploymentInfo
Returns:
Returns STATEFUL, STATELESS, BMP_ENTITY or CMP_ENTITY.
See Also:
DeploymentInfo.STATEFUL, DeploymentInfo.STATELESS, DeploymentInfo.BMP_ENTITY, DeploymentInfo.CMP_ENTITY, DeploymentInfo.MESSAGE_DRIVEN

getTransactionAttribute

public byte getTransactionAttribute(java.lang.reflect.Method method)
Gets the transaction attribute that must be applied to this method when executing. The type can be anyone of TX_NEVER, TX_NOT_SUPPORTED, TX_SUPPORTS, TX_MANDITORY, TX_REQUIRED, TX_REQUIRES_NEW,

Specified by:
getTransactionAttribute in interface DeploymentInfo
Parameters:
method - the bean's method for which transaction attribute information is needed
Returns:
the transaction constant that states the method's transaction attribute
See Also:
DeploymentInfo.TX_NEVER, DeploymentInfo.TX_NOT_SUPPORTED, DeploymentInfo.TX_SUPPORTS, DeploymentInfo.TX_MANDITORY, DeploymentInfo.TX_REQUIRED, DeploymentInfo.TX_REQUIRES_NEW

getTransactionPolicy

public TransactionPolicy getTransactionPolicy(java.lang.reflect.Method method)

getAuthorizedRoles

public java.lang.String[] getAuthorizedRoles(java.lang.reflect.Method method)
Gets the roles that are authorised to execute this method. Used primarily by the container to check the caller's rights to access and execute the specifed method.

Specified by:
getAuthorizedRoles in interface DeploymentInfo
Parameters:
method - the bean's method for which security information is needed
Returns:
a String array of the roles that are authorised to execute this method
See Also:
SecurityService.isCallerAuthorized(java.lang.Object, java.lang.String[])

getAuthorizedRoles

public java.lang.String[] getAuthorizedRoles(java.lang.String action)
Specified by:
getAuthorizedRoles in interface DeploymentInfo

getContainer

public Container getContainer()
Gets the the container that this deployed bean is in.

Specified by:
getContainer in interface DeploymentInfo
Returns:
the the deployment's container.
See Also:
Container.getContainerID()

getDeploymentID

public java.lang.Object getDeploymentID()
Gets the id of this bean deployment.

Specified by:
getDeploymentID in interface DeploymentInfo
Returns:
the id of of this bean deployment

isBeanManagedTransaction

public boolean isBeanManagedTransaction()
Returns true if this bean deployment has chosen bean-managed transaction demarcation. Returns false if the continer will be managing the bean's transactions.

Specified by:
isBeanManagedTransaction in interface DeploymentInfo
Returns:
Returns true if this bean deployment is managing its own transactions.

getHomeInterface

public java.lang.Class getHomeInterface()
Gets the home interface for the bean deployment. Used primarily by Servers integrating OpenEJB into their platform. Aids in implementing the bean's home interface.

Specified by:
getHomeInterface in interface DeploymentInfo
Returns:
a Class object of the bean's home interface
See Also:
EJBHome

getRemoteInterface

public java.lang.Class getRemoteInterface()
Gets the remote interface for the bean deployment. Used primarily by Servers integrating OpenEJB into their platform. Aids in implementing the bean's remote interface.

Specified by:
getRemoteInterface in interface DeploymentInfo
Returns:
a Class object of the bean's remote interface
See Also:
EJBObject

getLocalHomeInterface

public java.lang.Class getLocalHomeInterface()
Specified by:
getLocalHomeInterface in interface DeploymentInfo

getLocalInterface

public java.lang.Class getLocalInterface()
Specified by:
getLocalInterface in interface DeploymentInfo

getBeanClass

public java.lang.Class getBeanClass()
Gets the bean's class definition. Used primarily by containers to instantiate new instances of a bean.

Specified by:
getBeanClass in interface DeploymentInfo
Returns:
a Class object of the bean's class definition
See Also:
EnterpriseBean

getPrimaryKeyClass

public java.lang.Class getPrimaryKeyClass()
Gets the Class type of the primary key for this bean deployment. Returns null if the bean is a type that does not need a primary key.

Specified by:
getPrimaryKeyClass in interface DeploymentInfo
Returns:
the Class type of the bean's primary key or null if the bean doesn't need a primary key

getEJBHome

public javax.ejb.EJBHome getEJBHome()
Gets the EJBHome object of this bean deployment.

Returns:
the javax.ejb.EJBHome object
See Also:
EJBHome

getEJBLocalHome

public javax.ejb.EJBLocalHome getEJBLocalHome()

setBeanManagedTransaction

public void setBeanManagedTransaction(boolean value)
Sets this bean deployment to container-managed or bean-managed transaction demarcation.

Parameters:
value - true if this bean is managing transaction, false if the container should manage them

getJndiEnc

public javax.naming.Context getJndiEnc()
Gets the JNDI namespace for the bean's environment. This will be the ony namespace that the bean will be able to access using the java: URL in the JNDI. Used primarily by the IntraVM naming server to get a bean's environemtn naming context when the bean performs a lookup using the "java:" URL.

See Also:
Context

isReentrant

public boolean isReentrant()
Returns true if the bean deployment allows reenterace.

Specified by:
isReentrant in interface DeploymentInfo
Returns:
boolean

setIsReentrant

public void setIsReentrant(boolean reentrant)

convertIfLocalReference

public java.lang.Object convertIfLocalReference(java.lang.reflect.Method businessMethod,
                                                java.lang.Object returnValue)
Business methods that return EJBHome or EJBObject references to local beans (beans in the same container system) must have the return value converted to a ProxyInfo object, so that the server can provide the client with a proper remote reference. Local remote references are implemented using the org.openejb.core.ivm.BaseEjbProxyHandler types, which should not be returned to the client. Non-local remote references are assumed to be serializable and valid return types for the clients. If the reference is a local remote reference, then a subtype of ProxyInfo is returned. The subtype is a org.openejb.core.ivm.SpecialProxyInfo. This class type is useful when the calling server is the IntraVM server. Instead of creating a new remote ref from the proxy the IntraVM takes a short cut and reuses the original local remote reference -- they are thread safe with no synchronization. This method is based on a method map (methodWithRemoteReturnTypes) which is constructed in the createMethodMap( ) method of this class. See Section 2.2.1.2.5 Remote References of the OpenEJB 1.1 specification.

Parameters:
businessMethod -
returnValue -
Returns:
Object

getMatchingBeanMethod

public java.lang.reflect.Method getMatchingBeanMethod(java.lang.reflect.Method interfaceMethod)
Returns a method in the bean class that matches the method passed in. Used to map the methods from the home or remote interface to the methods in the bean class. This is needed because the java.lang.reflect.Method object passed into the container by the server is declared by a remote or home interface. Since the bean class is not required to implement either of these interfaces, the matching method on the bean class may be a different java.lang.reflect.Method object. Invoking a the remote or home interface Method object on the bean class will not work if the bean doesn't implement the Method's interface. This method provide the container with the proper Method object. The mapping is performed at assembly time by the createMethodMap( ) declared in this class.

Parameters:
interfaceMethod - the Method of the home or remote interface
Returns:
the Method in the bean class that maps to the method specified

appendMethodPermissions

public void appendMethodPermissions(java.lang.reflect.Method m,
                                    java.lang.String[] roleNames)
Appends a Method and a list of authorized roles to the internal list of mehtod permissions.

Parameters:
m - the Method the roles map to
roleNames - the roles that are authorized to execute the specified method
See Also:
Method

getPhysicalRole

public java.lang.String[] getPhysicalRole(java.lang.String securityRoleReference)
Beans can test to see if the current principal is a member of a specified role using the method EJBContext.isPrincipalInRole(String roleName). The role name used is a logical role name specified by the bean provider. When the bean is packaged this role name must be declared in the security-role-ref and linked to a security-role element in the deployment descriptor. In OpenEJB the security-role element is also assigned a physical role, ased on the target environment. Its this physical role that must be mapped to the security-role-reference used by the bean provider.

The org.openejb.core.CoreContext uses this method to obtain the physical role mapped to the logical role used by the bean.

Parameters:
securityRoleReference - the role used by the bean code; the security-role-ref
Returns:
the physical role in the target environment that is mapped to the security-
See Also:
addSecurityRoleReference(java.lang.String, java.lang.String[])

addSecurityRoleReference

public void addSecurityRoleReference(java.lang.String securityRoleReference,
                                     java.lang.String[] physicalRoles)
Adds a security-role-ref to physical role mapping. The security-role-ref is used to test the caller's membership in a particular role at runtime.

Parameters:
securityRoleReference - the role used by the bean code; the security-role-ref
physicalRoles -
See Also:
getPhysicalRole(String)

getEJBContext

public javax.ejb.EJBContext getEJBContext()
Gets the EJBContext this container manager will expose to the Containers it manages.

Returns:
an EJBContext that containers can give to beans.
See Also:
"javax.ejb.EJBContext"

setMethodTransactionAttribute

public void setMethodTransactionAttribute(java.lang.reflect.Method method,
                                          java.lang.String transAttribute)
Sets the transaction attribute of the method in the bean's class. There are six valid transaction attributes: "Supports", "RequiresNew", "Manditory", "NotSupported", "Required", and "Never".

Parameters:
method - the Method the specified transaction attribute applies to.
transAttribute - one of "Supports", "RequiresNew", "Manditory", "NotSupported", "Required", or "Never".
See Also:
Method

extractHomeBeanMethodName

protected java.lang.String extractHomeBeanMethodName(java.lang.String methodName)

getCreateMethod

public java.lang.reflect.Method getCreateMethod()
Used for stateless session beans only

Returns:
Method

getMatchingPostCreateMethod

public java.lang.reflect.Method getMatchingPostCreateMethod(java.lang.reflect.Method createMethod)
Used for entity beans only.

Parameters:
createMethod -
Returns:
Method

getPrimaryKeyField

public java.lang.reflect.Field getPrimaryKeyField()
Gets the Field of the CMP entity bean class which corresponds to the simple primary key. Entity beans that have complex primary keys (keys with several fields) will not have a primkey-field.

Useful for Container-Managed Persistence (CMP) Entity beans with Simple Primary Keys.

Specified by:
getPrimaryKeyField in interface DeploymentInfo
Returns:
the EntityBean field that corresponds to the simple primary key. return null if the bean is not a CMP Entity bean with a simple Primary key

setPrimKeyField

public void setPrimKeyField(java.lang.String fieldName)
                     throws java.lang.NoSuchFieldException
Throws:
java.lang.NoSuchFieldException

getCmrFields

public java.lang.String[] getCmrFields()
Returns the names of the bean's container-managed fields. Used for container-managed persistence only.

Returns:
String[]

setCmrFields

public void setCmrFields(java.lang.String[] cmrFields)

getKeyGenerator

public KeyGenerator getKeyGenerator()

setKeyGenerator

public void setKeyGenerator(KeyGenerator keyGenerator)

addQuery

public void addQuery(java.lang.reflect.Method queryMethod,
                     java.lang.String queryString)
This method maps a query method (ejbFind) to a query string.

Each query method, ejbFind or ejbSelect(EJB 2.0), can be mapped to query string which describes the behavior of the method. For example, with the Castor JDO CMP container for EJB 1.1, every ejbFind method for each Deployment maps to a specific OQL statement which Castor JDO uses to access the object cache.

Parameters:
queryMethod -
queryString -

getQuery

public java.lang.String getQuery(java.lang.reflect.Method queryMethod)
This method retrieves the query string associated with the query method.

Each query method, ejbFind or ejbSelect(EJB 2.0), can be mapped to query string which describes the behavior of the method. For example, with the Castor JDO CMP container for EJB 1.1, every ejbFind method for each Deployment maps to a specific OQL statement which Castor JDO uses to access the object cache.

Parameters:
queryMethod -
Returns:
String


Copyright © 1999-2011 OpenEJB. All Rights Reserved.