org.objectweb.jonas_ejb.container
Class JContainer

java.lang.Object
  extended by org.objectweb.jonas_ejb.container.JContainer
All Implemented Interfaces:
Container

public class JContainer
extends java.lang.Object
implements Container

This class represents an EJB container. A container is where an enterprise Bean object lives. All beans from a same ejb-jar file are installed in a single container. For each EJB installed, the container provides a factory and makes it available in the JNDI name space. The JContainer basically manages a set of BeanFactory objects.

Author:
Philippe Coq, Jeff Mesnil (Security), Christophe Ney (Making easier Enhydra integration), Philippe Durieux (New architecture for local interfaces), Florent Benoit (Ear service, ejb-link, JACC security), Ludovic Bert (Ear service, ejb-link), Benjamin Bonnet (max size for thread pool)

Field Summary
static java.lang.String DEFAULT_FACTORY_CLASS_NAME
          This class is the default factory class name used for the Entity bean.
 
Constructor Summary
JContainer(java.lang.String name, java.lang.String extFileName, java.lang.String file, java.lang.ClassLoader ld)
          constructor
 
Method Summary
 BeanFactory addBean(BeanDesc dd)
          Adds beans in container.
protected  void checkSecurity(java.lang.String ejbName, EJBInvocation ejbInv, boolean inRunAs)
          Check Security.
 BeanFactory getBeanFactory(java.lang.String ejbName)
          Get the bean factory for the given bean.
 int getBeanNb()
           
 java.lang.ClassLoader getClassLoader()
           
 ContainerNaming getContainerNaming()
          used internally by all the EJB Container classes.
 java.lang.String getContextId()
          Gets the context ID of this container (for jacc)
 java.util.Set getDataSourceDependence(java.lang.String dsName)
          Management method used by the EJBServiceImpl MBean.
 java.lang.String getEarFileName()
          get the name of the ear application containing this container.
 int getEntityBMPNb()
           
 int getEntityCMPNb()
           
 java.lang.String getExternalFileName()
           
 java.lang.String getFileName()
           
 java.util.Set getJmsConnectionFactoryDependence(java.lang.String cfName)
          Management method used by the EJBServiceImpl MBean.
 java.util.Set getJmsDestinationDependence(java.lang.String destName)
          Management method used by the EJBServiceImpl MBean.
 JmsManager getJmsManager()
          used internally by all the EJB Container classes.
 java.util.Set getMailFactoryDependence(java.lang.String mfName)
          Management method used by the EJBServiceImpl MBean.
 int getMessageDrivenNb()
           
 java.lang.String getName()
           
 PermissionManager getPermissionManager()
          Gets the permission manager
 PrincipalFactory getPrincipalFactory()
           
 int getStatefulSessionNb()
           
 int getStatelessSessionNb()
           
 java.lang.String getTmpDirName()
           
 org.objectweb.transaction.jta.TransactionManager getTransactionManager()
          return the Transaction Manager used internally by all the EJB Container classes.
 javax.resource.spi.work.WorkManager getWorkManager()
           
 boolean isInEarCase()
          Return true if only if this ejbjar is in an ear file.
 java.lang.String[] listBeanNames()
           
 void registerBF(BeanFactory bf)
          register a BeanFactory
 void registerBFS(BeanFactory bf)
          register a BeanFactory for Sync
 void remove()
          Remove the JOnAS container and unregister all beans.
 void setBeanEnvironment(javax.naming.Context ctx, BeanDesc dd)
          Set the bean environment
 void setContainerNaming(ContainerNaming naming)
          set the ContainerNaming object Called by the EJB Server when starting the service.
 void setEarFileName(java.lang.String fileName)
          set the name of the ear application containing this container.
 void setJmsManager(JmsManager jms)
          set the JmsManager object Called by the EJB Server when starting ths service.
 void setPermissionManager(PermissionManager permissionManager)
          Set the permission manager object
 void setPrincipalFactory(PrincipalFactory pf)
          Set the PrincipalFactory.
 void setSecurity(boolean b)
          Set the security flag to enable or disable security
 void setSwapTime(int t)
          Take into account the swapping time for the bean.
 void setTransactionManager(org.objectweb.transaction.jta.TransactionManager tm)
          set the Transaction Manager.
 void setWorkManager(javax.resource.spi.work.WorkManager wm)
          set the Work Manager.
 void storeAll(javax.transaction.Transaction tx)
          Try to store all entity bean instances modified in the transaction this method has been introduced to fix bug #305711 it's, may be, bad for performance
 void syncAll(boolean store, boolean passivate)
          Try to passivate all entity bean instances
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FACTORY_CLASS_NAME

public static final java.lang.String DEFAULT_FACTORY_CLASS_NAME
This class is the default factory class name used for the Entity bean.

See Also:
Constant Field Values
Constructor Detail

JContainer

public JContainer(java.lang.String name,
                  java.lang.String extFileName,
                  java.lang.String file,
                  java.lang.ClassLoader ld)
constructor

Parameters:
name - name of the container.
extFileName - external file name
file - file name (.jar or .xml)
ld - the class loader to be used
Method Detail

getTmpDirName

public java.lang.String getTmpDirName()

addBean

public BeanFactory addBean(BeanDesc dd)
Adds beans in container. This method is not part of JContainer interface, although it is used by JOnAS Server, because we don't want to get all BeanDesc classes (jonas_ejb.deployment.api) LATER: Replace this by setDeploymentDesc ?

Parameters:
dd - The Bean Deployment Descriptor
Returns:
The bean factory created for this bean.
Throws:
javax.ejb.EJBException

checkSecurity

protected void checkSecurity(java.lang.String ejbName,
                             EJBInvocation ejbInv,
                             boolean inRunAs)
Check Security. No control for Message Driven Beans

Parameters:
ejbName - name of the EJB of which do control
ejbInv - object containing security signature of the method, args of method, etc
inRunAs - bean calling this method is running in run-as mode or not ?

getBeanFactory

public BeanFactory getBeanFactory(java.lang.String ejbName)
Get the bean factory for the given bean.

Specified by:
getBeanFactory in interface Container
Parameters:
ejbName - the name of the bean
Returns:
the bean factory for this bean

getBeanNb

public int getBeanNb()
Returns:
total Number of Beans

getClassLoader

public java.lang.ClassLoader getClassLoader()
Specified by:
getClassLoader in interface Container
Returns:
the classloader used for this Container

getContainerNaming

public ContainerNaming getContainerNaming()
used internally by all the EJB Container classes.

Specified by:
getContainerNaming in interface Container
Returns:
the ContainerNaming object

getDataSourceDependence

public java.util.Set getDataSourceDependence(java.lang.String dsName)
Management method used by the EJBServiceImpl MBean. Determine which are the ejbs using a given data source.

Parameters:
dsName - JNDI name of the data source
Returns:
a set of Properties describing the beans that use the data source

getEarFileName

public java.lang.String getEarFileName()
get the name of the ear application containing this container.

Specified by:
getEarFileName in interface Container
Returns:
the name of the ear application containing this container.

getEntityBMPNb

public int getEntityBMPNb()
Returns:
int Number of BMP type currently in this container

getEntityCMPNb

public int getEntityCMPNb()
Returns:
int Number of CMP type currently in this container

getFileName

public java.lang.String getFileName()
Specified by:
getFileName in interface Container
Returns:
the file name of the container (.xml or .jar)

getExternalFileName

public java.lang.String getExternalFileName()
Specified by:
getExternalFileName in interface Container
Returns:
the external file name of the container

getJmsConnectionFactoryDependence

public java.util.Set getJmsConnectionFactoryDependence(java.lang.String cfName)
Management method used by the EJBServiceImpl MBean. Determine which are the ejbs using a JMS Connection Factory.

Parameters:
cfName - JNDI name of a JMS Connection Factory.
Returns:
a set of Properties describing the beans that use the JMS Connection Factory.

getJmsDestinationDependence

public java.util.Set getJmsDestinationDependence(java.lang.String destName)
Management method used by the EJBServiceImpl MBean. Determine which are the beans using a JMS destination.

Parameters:
destName - JNDI name of a JMS destination
Returns:
a set of Properties describing the ejbs that use the JMS destination.

getJmsManager

public JmsManager getJmsManager()
used internally by all the EJB Container classes.

Specified by:
getJmsManager in interface Container
Returns:
the JmsManager object

getMailFactoryDependence

public java.util.Set getMailFactoryDependence(java.lang.String mfName)
Management method used by the EJBServiceImpl MBean. Determine which are the ejbs using a Mail Factory.

Parameters:
mfName - JNDI name of a Mail Factory.
Returns:
a set of Properties describing the beans that use the given Mail Factory.

getMessageDrivenNb

public int getMessageDrivenNb()
Returns:
int Number of MDB type currently in this container

getName

public java.lang.String getName()
Specified by:
getName in interface Container
Returns:
name of this Container

getPermissionManager

public PermissionManager getPermissionManager()
Gets the permission manager

Specified by:
getPermissionManager in interface Container
Returns:
the permission manager

getPrincipalFactory

public PrincipalFactory getPrincipalFactory()
Specified by:
getPrincipalFactory in interface Container
Returns:
the PrincipalFactory of the Container

getStatefulSessionNb

public int getStatefulSessionNb()
Returns:
int Number of SBF type currently in this container

getStatelessSessionNb

public int getStatelessSessionNb()
Returns:
int Number of SBL type currently in this container

getTransactionManager

public org.objectweb.transaction.jta.TransactionManager getTransactionManager()
return the Transaction Manager used internally by all the EJB Container classes.

Specified by:
getTransactionManager in interface Container
Returns:
the Transaction Manager

isInEarCase

public boolean isInEarCase()
Return true if only if this ejbjar is in an ear file.

Returns:
true if only if this ejbjar is in an ear file.

listBeanNames

public java.lang.String[] listBeanNames()
Specified by:
listBeanNames in interface Container
Returns:
List of beans hosted in this Container

registerBF

public void registerBF(BeanFactory bf)
register a BeanFactory

Parameters:
bf - The Bean Factory to be registered

registerBFS

public void registerBFS(BeanFactory bf)
register a BeanFactory for Sync

Parameters:
bf - The Bean Factory to be registered

remove

public void remove()
Remove the JOnAS container and unregister all beans.

Specified by:
remove in interface Container

setBeanEnvironment

public void setBeanEnvironment(javax.naming.Context ctx,
                               BeanDesc dd)
                        throws javax.naming.NamingException
Set the bean environment

Parameters:
ctx - Context for this bean
dd - Bean Deployment Descriptor
Throws:
javax.naming.NamingException - if could not rebind objects

setContainerNaming

public void setContainerNaming(ContainerNaming naming)
set the ContainerNaming object Called by the EJB Server when starting the service.

Specified by:
setContainerNaming in interface Container
Parameters:
naming - the ContainerNaming object

setEarFileName

public void setEarFileName(java.lang.String fileName)
set the name of the ear application containing this container.

Specified by:
setEarFileName in interface Container
Parameters:
fileName - the name of the ear application containing this container.

setJmsManager

public void setJmsManager(JmsManager jms)
set the JmsManager object Called by the EJB Server when starting ths service.

Specified by:
setJmsManager in interface Container
Parameters:
jms - the JmsManager

setPermissionManager

public void setPermissionManager(PermissionManager permissionManager)
Set the permission manager object

Specified by:
setPermissionManager in interface Container
Parameters:
permissionManager - permission manager object

setPrincipalFactory

public void setPrincipalFactory(PrincipalFactory pf)
Set the PrincipalFactory. This factory can be JOnAS Server dependant. The Container makes no assumption on how to get the Principal.

Specified by:
setPrincipalFactory in interface Container
Parameters:
pf - the PrincipalFactory

setSecurity

public void setSecurity(boolean b)
Set the security flag to enable or disable security

Specified by:
setSecurity in interface Container
Parameters:
b - true or false to enable/disable security

setSwapTime

public void setSwapTime(int t)
Take into account the swapping time for the bean.

Parameters:
t - time in seconds (t = 0 no time out)

setWorkManager

public void setWorkManager(javax.resource.spi.work.WorkManager wm)
set the Work Manager. Called by the EJB Server when starting the service.

Parameters:
wm - the Work Manager.

getWorkManager

public javax.resource.spi.work.WorkManager getWorkManager()
Returns:
the WorkManager unique instance

setTransactionManager

public void setTransactionManager(org.objectweb.transaction.jta.TransactionManager tm)
set the Transaction Manager. Called by the EJB Server when starting the service.

Specified by:
setTransactionManager in interface Container
Parameters:
tm - the Transaction Manager.

syncAll

public void syncAll(boolean store,
                    boolean passivate)
Try to passivate all entity bean instances

Specified by:
syncAll in interface Container
Parameters:
store - True if store even if passivationTimeout not reached
passivate - true if bean instances will be released after having been written on storage.

getContextId

public java.lang.String getContextId()
Gets the context ID of this container (for jacc)

Specified by:
getContextId in interface Container
Returns:
contextID used for JACC

storeAll

public void storeAll(javax.transaction.Transaction tx)
Try to store all entity bean instances modified in the transaction this method has been introduced to fix bug #305711 it's, may be, bad for performance

Parameters:
tx -