org.objectweb.jonas_ejb.deployment.api
Class BeanDesc

java.lang.Object
  extended by org.objectweb.jonas_lib.deployment.api.DescriptionGroupDesc
      extended by org.objectweb.jonas_lib.deployment.api.JndiEnvRefsGroupDesc
          extended by org.objectweb.jonas_ejb.deployment.api.BeanDesc
All Implemented Interfaces:
DescriptionGroup, JndiEnvRefsGroup
Direct Known Subclasses:
EntityDesc, MessageDrivenDesc, SessionDesc

public abstract class BeanDesc
extends JndiEnvRefsGroupDesc

Class to hold meta-information related to any enterprise-beans

Author:
Christophe Ney [cney@batisseurs.com] : Initial developer, Helene Joanin, Jeff Mesnil, Philippe Coq, Florent Benoit & Ludovic Bert : ejb_link

Field Summary
protected static int BEAN_TRANSACTION_TYPE
          Bean transaction type
protected  java.lang.String beanIdentification
          bean identification string
protected  BeanFactory bf
          BeanFactory when the bean has been loaded.
protected  int cacheMax
          Maximum Bean Cache size
protected  java.lang.String clusterHomeDistributor
          Cluster - velocity template of the CMI class for the Home interface
protected  java.lang.String clusterRemoteDistributor
          Cluster - velocity template of the CMI class for the Remote interface
protected  boolean clusterReplicated
          Cluster - true if the bean has to be replicated
protected static int CONTAINER_TRANSACTION_TYPE
          Container transaction type
protected  DeploymentDesc deploymentDesc
          DeploymentDesc parent of this BeanDesc
protected  java.lang.String derivedBeanName
          Bean classname
protected  java.util.Properties ejb10EnvProps
          EJB 1.0 Environment as Properties
protected  java.lang.Class ejbClass
          Bean Class
protected  java.lang.String ejbName
          name of the Bean
protected  java.lang.String ejbTimeoutSignature
           
protected  java.lang.String fullDerivedBeanName
          Bean fully qualified classname
static java.lang.String GENERATED_PREFIX
          Package prefix for generated files
protected  java.lang.Class home
          Home Class
protected  java.lang.String jndiLocalName
          JNDI local name of the Bean
protected  java.lang.String jndiName
          JNDI name of the Bean
protected  java.lang.Class local
          Local Class
protected  java.lang.Class localhome
          LocalHome Class
protected  org.objectweb.util.monolog.api.Logger logger
          logger
protected  int poolMin
          Minimum Bean Pool size
protected  java.lang.Class remote
          Remote Class
protected  java.util.List securityRoleRefDescList
          List of SecurityRoleRefDesc for JACC
protected  int timerTxAttribute
           
protected static java.lang.String[] TRANS
           
 
Fields inherited from class org.objectweb.jonas_lib.deployment.api.DescriptionGroupDesc
description, displayName, largeIcon, smallIcon
 
Constructor Summary
BeanDesc(java.lang.ClassLoader classLoader, CommonEjb ejb, JonasCommonEjb jonasEjb, AssemblyDescriptor asd, JLinkedList jMDRList, java.lang.String fileName)
          Constructor to be used by parent node
 
Method Summary
protected  int addEJBMethodDesc(int len)
          Permit Methods addition from subtypes Protected method that need to be overridden in subclasses
protected  MethodDesc addMethodDesc(java.lang.reflect.Method meth, java.lang.Class classDef)
          Add a new method descriptor to the bean
 void check()
          Check that the bean descriptor is valid
 void checkRemoteException(java.lang.reflect.Method m, boolean shouldThrow)
          Check if method throws RemoteException (or not).
 void checkRunAsMapping()
          Check that the runAs role mapping is correct
protected abstract  void checkTxAttribute(MethodDesc md)
          Check that trans-attribute is valid for a bean's method.
 void checkValidTypesForRmi(java.lang.reflect.Method m)
          Check if argument and return types are valid types for RMI-IIOP.
 BeanFactory getBeanFactory()
           
 int getCacheMax()
           
 java.lang.String getClusterHomeDistributor()
           
 java.lang.String getClusterRemoteDistributor()
           
 DeploymentDesc getDeploymentDesc()
           
 java.lang.String getDerivedBeanName()
           
 java.util.Properties getEjb10Environment()
          Get bean's EJB 1.0 environment properties.
 java.lang.Class getEjbClass()
          Get bean's class.
 java.lang.String getEjbName()
          Get the enterprise bean's name.
 java.lang.String getEjbTimeoutSignature()
           
 java.lang.String getFullDerivedBeanName()
           
 java.lang.String getFullWrpHandleName()
           
 java.lang.String getFullWrpHomeName()
           
 java.lang.String getFullWrpLocalHomeName()
           
 java.lang.String getFullWrpLocalName()
           
 java.lang.String getFullWrpRemoteName()
           
protected  java.lang.String getHashCodeForIdentifier()
          Gets an hashcode for this bean Return hashcode for jndiname + jndi localname
 java.lang.Class getHomeClass()
          Get bean's home interface.
 java.lang.String getIdentifier()
          Build a valid java identifier for the bean.
 java.lang.String getJndiLocalName()
          Get the name to associate with the enterprise Bean in the JNDI name space for local access (inside the same JOnAS Server)
 java.lang.String getJndiName()
          Get the name to associate with the enterprise Bean in the JNDI name space.
 java.lang.Class getLocalClass()
          Get bean's local interface.
 java.lang.Class getLocalHomeClass()
          Get bean's local home interface.
 MethodDesc getMethodDesc(int index)
          get a MethodDesc from its index.
 MethodDesc getMethodDesc(java.lang.reflect.Method method)
          Get descriptor attached to a given method.
 java.util.Iterator getMethodDescIterator()
          get an iterator for all MethodDesc of the bean.
protected  java.lang.Class getParentClass(java.lang.String intfType)
          Returns the parent Class for a method given an interface type.
 int getPoolMin()
           
 java.lang.Class getRemoteClass()
          Get bean's remote interface.
 java.lang.String getRunAsPrincipalName()
           
 java.lang.String getRunAsRole()
           
 org.objectweb.carol.util.csiv2.SasComponent getSasComponent()
           
 java.util.List getSecurityRoleRefDescList()
          Gets the security-role-ref of the beans can access to the EJBRoleRefPermission and role-link.
 int getTimerTxAttribute()
           
 java.lang.String getWrpHandleName()
           
 java.lang.String getWrpHomeName()
           
 java.lang.String getWrpLocalHomeName()
           
 java.lang.String getWrpLocalName()
           
 java.lang.String getWrpRemoteName()
           
 boolean hasDefinedLocalInterface()
           
 boolean isClusterReplicated()
           
protected  void loadExtraClasses(CommonEjb ce, java.lang.ClassLoader loader)
          Permit classes loading from subtypes.
protected  MethodDesc newMethodDescInstance(java.lang.reflect.Method meth, java.lang.Class classDef, int index)
          MethodDesc constructor factory method to ovewrite
 void setBeanFactory(BeanFactory factory)
          Set the BeanFactory, when the bean is loaded in container.
 void setClusterReplicated(boolean replicated)
          Set the cluster replicated attribute
 void setDeploymentDesc(DeploymentDesc deploymentDesc)
          Set the parent deployment descriptor
 void setSasComponent(org.objectweb.carol.util.csiv2.SasComponent sasComponent)
           
 java.lang.String toString()
          String representation of the object for test purpose
protected  void verifyRoleName(AssemblyDescriptor asd)
          Check that there are always corresponding role-name element in security-role and method-permission elements.
 
Methods inherited from class org.objectweb.jonas_lib.deployment.api.JndiEnvRefsGroupDesc
getEjbLocalRefDesc, getEjbRefDesc, getEnvEntryDesc, getMessageDestinationRefDesc, getResourceEnvRefDesc, getResourceRefDesc, getServiceRefDesc
 
Methods inherited from class org.objectweb.jonas_lib.deployment.api.DescriptionGroupDesc
getDescription, getDisplayName, getLargeIcon, getSAXMsg, getSmallIcon
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BEAN_TRANSACTION_TYPE

protected static final int BEAN_TRANSACTION_TYPE
Bean transaction type

See Also:
Constant Field Values

CONTAINER_TRANSACTION_TYPE

protected static final int CONTAINER_TRANSACTION_TYPE
Container transaction type

See Also:
Constant Field Values

TRANS

protected static final java.lang.String[] TRANS

GENERATED_PREFIX

public static final java.lang.String GENERATED_PREFIX
Package prefix for generated files

See Also:
Constant Field Values

ejbName

protected java.lang.String ejbName
name of the Bean


jndiName

protected java.lang.String jndiName
JNDI name of the Bean


jndiLocalName

protected java.lang.String jndiLocalName
JNDI local name of the Bean


home

protected java.lang.Class home
Home Class


remote

protected java.lang.Class remote
Remote Class


localhome

protected java.lang.Class localhome
LocalHome Class


local

protected java.lang.Class local
Local Class


ejbClass

protected java.lang.Class ejbClass
Bean Class


beanIdentification

protected java.lang.String beanIdentification
bean identification string


ejb10EnvProps

protected java.util.Properties ejb10EnvProps
EJB 1.0 Environment as Properties


logger

protected org.objectweb.util.monolog.api.Logger logger
logger


securityRoleRefDescList

protected java.util.List securityRoleRefDescList
List of SecurityRoleRefDesc for JACC


deploymentDesc

protected DeploymentDesc deploymentDesc
DeploymentDesc parent of this BeanDesc


fullDerivedBeanName

protected java.lang.String fullDerivedBeanName
Bean fully qualified classname


derivedBeanName

protected java.lang.String derivedBeanName
Bean classname


poolMin

protected int poolMin
Minimum Bean Pool size


cacheMax

protected int cacheMax
Maximum Bean Cache size


timerTxAttribute

protected int timerTxAttribute

ejbTimeoutSignature

protected java.lang.String ejbTimeoutSignature

bf

protected BeanFactory bf
BeanFactory when the bean has been loaded.


clusterHomeDistributor

protected java.lang.String clusterHomeDistributor
Cluster - velocity template of the CMI class for the Home interface


clusterRemoteDistributor

protected java.lang.String clusterRemoteDistributor
Cluster - velocity template of the CMI class for the Remote interface


clusterReplicated

protected boolean clusterReplicated
Cluster - true if the bean has to be replicated

Constructor Detail

BeanDesc

public BeanDesc(java.lang.ClassLoader classLoader,
                CommonEjb ejb,
                JonasCommonEjb jonasEjb,
                AssemblyDescriptor asd,
                JLinkedList jMDRList,
                java.lang.String fileName)
         throws DeploymentDescException
Constructor to be used by parent node

Parameters:
classLoader - ClassLoader used to load Bean's classes
ejb - XML Element from standard Deployment Descriptor
jonasEjb - XML Element from jonas specific Deployment Descriptor
asd - XML Element for the AssemblyDescriptor
fileName - jar filename
Throws:
DeploymentDescException - when BeanDesc cannot be instanciated (class loading problem, ...)
Method Detail

loadExtraClasses

protected void loadExtraClasses(CommonEjb ce,
                                java.lang.ClassLoader loader)
                         throws DeploymentDescException
Permit classes loading from subtypes. (needed for Stateless Session Beans with service-endpoints). Needs to be overridden in subtypes.

Parameters:
ce - XML Element representing EJB Descriptor
loader - ClassLoader used to load classes
Throws:
DeploymentDescException - when a class cannot be loaded

addEJBMethodDesc

protected int addEJBMethodDesc(int len)
                        throws DeploymentDescException
Permit Methods addition from subtypes Protected method that need to be overridden in subclasses

Parameters:
len - method array length
Returns:
new len value
Throws:
DeploymentDescException - when java reflection cannot be used on classes

getParentClass

protected java.lang.Class getParentClass(java.lang.String intfType)
                                  throws DeploymentDescException
Returns the parent Class for a method given an interface type.

Parameters:
intfType - type of the interface (Home/Remote/LocalHome/Local or ServiceEndpoint)
Returns:
the parent class for a method given an interface type
Throws:
DeploymentDescException - when intfType is unknown

getHashCodeForIdentifier

protected java.lang.String getHashCodeForIdentifier()
Gets an hashcode for this bean Return hashcode for jndiname + jndi localname

Returns:
a string for hashcode for jndiname + jndi localname

getIdentifier

public java.lang.String getIdentifier()
Build a valid java identifier for the bean.

Returns:
Returns a valid java identifier from the bean.

checkRemoteException

public void checkRemoteException(java.lang.reflect.Method m,
                                 boolean shouldThrow)
                          throws DeploymentDescException
Check if method throws RemoteException (or not).

Parameters:
m - the method to examine
shouldThrow - boolean value indicating if the method should or shouldn't throw RemoteException
Throws:
DeploymentDescException - thrown for non-valid method

checkValidTypesForRmi

public void checkValidTypesForRmi(java.lang.reflect.Method m)
Check if argument and return types are valid types for RMI-IIOP. (Primitive types, remote objects, or non-remote objects that implement the java.io.Serializable interface) Only a warning is logging if it's not the case.

Parameters:
m - the methode to examine

check

public void check()
           throws DeploymentDescException
Check that the bean descriptor is valid

Throws:
DeploymentDescException - thrown for non-valid bean

checkRunAsMapping

public void checkRunAsMapping()
                       throws DeploymentDescException
Check that the runAs role mapping is correct

Throws:
DeploymentDescException - if role mapping is incorrect

checkTxAttribute

protected abstract void checkTxAttribute(MethodDesc md)
                                  throws DeploymentDescException
Check that trans-attribute is valid for a bean's method.

Parameters:
md - MethodDesc to check
Throws:
DeploymentDescException - When MethodDesc is not valid

verifyRoleName

protected void verifyRoleName(AssemblyDescriptor asd)
                       throws DeploymentDescException
Check that there are always corresponding role-name element in security-role and method-permission elements.

Parameters:
asd - the AssemblyDescriptor used to check bean's role names
Throws:
DeploymentDescException - When verification fails

getEjbName

public java.lang.String getEjbName()
Get the enterprise bean's name.

Returns:
Name of the bean

getJndiName

public java.lang.String getJndiName()
Get the name to associate with the enterprise Bean in the JNDI name space. Invoking this method is disallowed for message driven bean. (This information is JOnAS specific). Used by Server

Returns:
Jndi name of the bean

getJndiLocalName

public java.lang.String getJndiLocalName()
Get the name to associate with the enterprise Bean in the JNDI name space for local access (inside the same JOnAS Server)

Returns:
Jndi local name of the bean

getHomeClass

public java.lang.Class getHomeClass()
Get bean's home interface. Invoking this method is disallowed for message driven bean. Used by GenIC and Server

Returns:
Class for the home interface or null

getRemoteClass

public java.lang.Class getRemoteClass()
Get bean's remote interface. Invoking this method is disallowed for message driven bean. Used by GenIC and Server

Returns:
Class for the remote interface or null

getLocalHomeClass

public java.lang.Class getLocalHomeClass()
Get bean's local home interface. Invoking this method is disallowed for message driven bean. Used by GenIC and Server

Returns:
Class for the home interface or null

getLocalClass

public java.lang.Class getLocalClass()
Get bean's local interface. Invoking this method is disallowed for message driven bean. Used by GenIC and Server

Returns:
Class for the Local interface or null

getEjbClass

public java.lang.Class getEjbClass()
Get bean's class. Used by GenIC and Server

Returns:
Class for the bean

getEjb10Environment

public java.util.Properties getEjb10Environment()
Get bean's EJB 1.0 environment properties.

Returns:
Returns the bean's EJB 1.0 environment properties

getMethodDesc

public MethodDesc getMethodDesc(java.lang.reflect.Method method)
Get descriptor attached to a given method. Used by GenIC and JMdbEndpointFactory

Parameters:
method - Method from the Home/Remote/MessageListener interface
Returns:
The method descriptor (never returns null)

getMethodDescIterator

public java.util.Iterator getMethodDescIterator()
get an iterator for all MethodDesc of the bean.

Returns:
Returns an iterator for all MethodDesc of the bean

getMethodDesc

public MethodDesc getMethodDesc(int index)
get a MethodDesc from its index.

Parameters:
index - MethodDesc index
Returns:
Returns a MethodDesc from its index

getSecurityRoleRefDescList

public java.util.List getSecurityRoleRefDescList()
Gets the security-role-ref of the beans can access to the EJBRoleRefPermission and role-link.

Returns:
the security-role-ref of the beans

getPoolMin

public int getPoolMin()
Returns:
min size of the pool

getCacheMax

public int getCacheMax()
Returns:
max size of the cache

getRunAsRole

public java.lang.String getRunAsRole()
Returns:
the run-as role name

getTimerTxAttribute

public int getTimerTxAttribute()
Returns:
the transaction attribute for the ejbTimeout method

getEjbTimeoutSignature

public java.lang.String getEjbTimeoutSignature()
Returns:
the security signature for the ejbTimeout method

getBeanFactory

public BeanFactory getBeanFactory()
Returns:
the BeanFactory, if the bean has been loaded.

setBeanFactory

public void setBeanFactory(BeanFactory factory)
Set the BeanFactory, when the bean is loaded in container.

Parameters:
factory - The bean factory

toString

public java.lang.String toString()
String representation of the object for test purpose

Specified by:
toString in interface DescriptionGroup
Specified by:
toString in class DescriptionGroupDesc
Returns:
String representation of this object

newMethodDescInstance

protected MethodDesc newMethodDescInstance(java.lang.reflect.Method meth,
                                           java.lang.Class classDef,
                                           int index)
MethodDesc constructor factory method to ovewrite

Parameters:
meth - the method to be wrapped into a MethodDesc instance
index - index of the method inside the MethodDesc List
Returns:
Returns a new MethodDesc (or subclass)

addMethodDesc

protected MethodDesc addMethodDesc(java.lang.reflect.Method meth,
                                   java.lang.Class classDef)
Add a new method descriptor to the bean

Parameters:
meth - method to add inside MethodDescs list
Returns:
the constructed MethodDesc

getFullWrpRemoteName

public java.lang.String getFullWrpRemoteName()
Returns:
Returns the full name of the wrapper class for the bean

getFullWrpLocalName

public java.lang.String getFullWrpLocalName()
Returns:
Returns the full name of the wrapper class for the bean

getWrpRemoteName

public java.lang.String getWrpRemoteName()
Returns:
Returns the name of the wrapper class for the bean

getWrpLocalName

public java.lang.String getWrpLocalName()
Returns:
Returns the name of the wrapper class for the bean

getFullWrpHandleName

public java.lang.String getFullWrpHandleName()
Returns:
Returns the full name of the Handle class for the bean

getWrpHandleName

public java.lang.String getWrpHandleName()
Returns:
Returns the name of the Handle class for the bean

getFullWrpHomeName

public java.lang.String getFullWrpHomeName()
Returns:
Returns the full name of the wrapper home class for the bean

getFullWrpLocalHomeName

public java.lang.String getFullWrpLocalHomeName()
Returns:
Returns the full name of the wrapper local home class for the bean

getWrpHomeName

public java.lang.String getWrpHomeName()
Returns:
Returns the name of the wrapper home class for the bean

getWrpLocalHomeName

public java.lang.String getWrpLocalHomeName()
Returns:
Returns the name of the wrapper local home class for the bean

getFullDerivedBeanName

public java.lang.String getFullDerivedBeanName()
Returns:
Returns the full name of the derived class of the bean

getDerivedBeanName

public java.lang.String getDerivedBeanName()
Returns:
Returns the name of the derived class of the bean

getDeploymentDesc

public DeploymentDesc getDeploymentDesc()
Returns:
Returns the parent deployment descriptor

setDeploymentDesc

public void setDeploymentDesc(DeploymentDesc deploymentDesc)
Set the parent deployment descriptor

Parameters:
deploymentDesc - parent DeploymentDesc

getRunAsPrincipalName

public java.lang.String getRunAsPrincipalName()
Returns:
the runAs principal name.

hasDefinedLocalInterface

public boolean hasDefinedLocalInterface()
Returns:
true if local interface has been defined in the DD

getSasComponent

public org.objectweb.carol.util.csiv2.SasComponent getSasComponent()
Returns:
the sasComponent.

setSasComponent

public void setSasComponent(org.objectweb.carol.util.csiv2.SasComponent sasComponent)
Parameters:
sasComponent - The sasComponent to set.

getClusterHomeDistributor

public java.lang.String getClusterHomeDistributor()
Returns:
the velocity template of the cluster Distributor class for the home interface

getClusterRemoteDistributor

public java.lang.String getClusterRemoteDistributor()
Returns:
the velocity template of the cluster Distributor class for the remote interface

isClusterReplicated

public boolean isClusterReplicated()
Returns:
true if the bean has to be replicated over the cluster

setClusterReplicated

public void setClusterReplicated(boolean replicated)
Set the cluster replicated attribute

Parameters:
replicated - true if the replicated mode is enabled