org.objectweb.jonas_ejb.container
Class JContainer

java.lang.Object
  extended byorg.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.
 java.lang.String fileName
           
 java.lang.String myname
           
 JStatefulPool statefulSessionPool
           
 
Constructor Summary
JContainer(java.lang.String name, 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, java.lang.String methodSignature)
          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.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 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 getMaxThreadPoolSize()
          get the MaxThread pool size.
 int getMessageDrivenNb()
           
 java.lang.String getName()
           
 PermissionManager getPermissionManager()
          Gets the permission manager
 PrincipalFactory getPrincipalFactory()
           
 int getStatefulSessionNb()
           
 int getStatelessSessionNb()
           
 long getSwapTime()
           
 javax.transaction.TransactionManager getTransactionManager()
          return the Transaction Manager used internally by all the EJB Container classes.
 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 setMaxThreadPoolSize(int sz)
          set the MaxThread pool size.
 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 setThreadPoolSize(int sz)
          set the Thread pool size.
 void setTransactionManager(javax.transaction.TransactionManager tm)
          set the Transaction Manager.
 void syncAll(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

myname

public java.lang.String myname

fileName

public java.lang.String fileName

statefulSessionPool

public JStatefulPool statefulSessionPool
Constructor Detail

JContainer

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

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

listBeanNames

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

getName

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

getFileName

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

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

getClassLoader

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

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

getPrincipalFactory

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

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

getContainerNaming

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

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

setThreadPoolSize

public void setThreadPoolSize(int sz)
set the Thread pool size.

Specified by:
setThreadPoolSize in interface Container
Parameters:
sz - number of threads in the pool.

setMaxThreadPoolSize

public void setMaxThreadPoolSize(int sz)
set the MaxThread pool size.

Specified by:
setMaxThreadPoolSize in interface Container
Parameters:
sz - number max of threads in the pool.

getMaxThreadPoolSize

public int getMaxThreadPoolSize()
get the MaxThread pool size.

Specified by:
getMaxThreadPoolSize in interface Container
Returns:
number max of threads in the pool.

syncAll

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

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

setTransactionManager

public void setTransactionManager(javax.transaction.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.

getTransactionManager

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

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

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

getJmsManager

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

Specified by:
getJmsManager in interface Container
Returns:
the JmsManager 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.

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.

remove

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

Specified by:
remove in interface Container

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

getBeanFactory

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

Parameters:
ejbName - the name of the bean
Returns:
the bean factory for this bean

getBeanNb

public int getBeanNb()
Returns:
total Number of Beans

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

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

getMessageDrivenNb

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

getSwapTime

public long getSwapTime()
Returns:
passivation time out for this container in milliseconds

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

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.

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.

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.

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

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)

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

checkSecurity

protected void checkSecurity(java.lang.String ejbName,
                             java.lang.String methodSignature)
Check Security. No control for Message Driven Beans

Parameters:
ejbName - name of the EJB of which do control
methodSignature - The method security signature

setPermissionManager

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

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

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.

getPermissionManager

public PermissionManager getPermissionManager()
Gets the permission manager

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