org.ow2.jonas.lib.ejb21
Class JContainer

java.lang.Object
  extended by org.ow2.jonas.lib.ejb21.JContainer
All Implemented Interfaces:
Container

public class JContainer
extends 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), eyindanga (add life cycle dispatcher)

Field Summary
static String DEFAULT_FACTORY_CLASS_NAME
          This class is the default factory class name used for the Entity bean.
 
Constructor Summary
JContainer(String name, String extFileName, String file, ClassLoader ld, DeploymentDesc dd, CmiService cmiService, HaService haService, IJAXRPCService jaxrpService, MBeanServer jmxserver, ResourceService resService)
          constructor
 
Method Summary
 BeanFactory addBean(BeanDesc dd)
          Adds beans in container.
protected  void checkSecurity(String ejbName, EJBInvocation ejbInv, boolean inRunAs)
          Check Security.
 BeanFactory getBeanFactory(String ejbName)
          Get the bean factory for the given bean.
 int getBeanNb()
           
 ClassLoader getClassLoader()
           
 CmiService getCmiService()
           
 JComponentContextFactory getComponentContextFactory()
          
 JNamingManager getContainerNaming()
          used internally by all the EJB Container classes.
 String getContextId()
          Gets the context ID of this container (for jacc)
 Set<Properties> getDataSourceDependence(String dsName)
          Management method used by the EJBServiceImpl MBean.
 String getEarFileName()
          get the name of the ear application containing this container.
 int getEntityBMPNb()
           
 int getEntityCMPNb()
           
 String getExternalFileName()
           
 String getFileName()
           
 HaService getHaService()
           
 String getJavaEEApplicationName()
          Gets the Java EE Application Name of this container.
 Set<Properties> getJmsConnectionFactoryDependence(String cfName)
          Management method used by the EJBServiceImpl MBean.
 Set<Properties> getJmsDestinationDependence(String destName)
          Management method used by the EJBServiceImpl MBean.
 JmsManager getJmsManager()
          used internally by all the EJB Container classes.
 RdbMappingBuilder getJormMapping()
           
 org.ow2.util.event.api.IEventDispatcher getLifeCycleDispatcher()
           
 Set<Properties> getMailFactoryDependence(String mfName)
          Management method used by the EJBServiceImpl MBean.
 int getMessageDrivenNb()
           
 String getName()
           
 PermissionManager getPermissionManager()
          Gets the permission manager
 PrincipalFactory getPrincipalFactory()
           
 int getStatefulSessionNb()
           
 int getStatelessSessionNb()
           
 String getTmpDirName()
           
 TransactionManager getTransactionManager()
          return the Transaction Manager used internally by all the EJB Container classes.
 WorkManager getWorkManager()
           
 boolean isInEarCase()
          Return true if only if this ejbjar is in an ear file.
 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(Context ctx, BeanDesc dd)
          Set the bean environment
 void setComponentContextFactory(JComponentContextFactory factory)
          Set the JComponentContextFactory instance.
 void setContainerNaming(JNamingManager naming)
          set the ContainerNaming object Called by the EJB Server when starting the service.
 void setEarFileName(String fileName)
          set the name of the ear application containing this container.
 void setJavaEEApplicationName(String javaEEApplicationName)
          Sets the Java EE Application Name of this container.
 void setJmsManager(JmsManager jms)
          set the JmsManager object Called by the EJB Server when starting ths service.
 void setLifeCycleDispatcher(org.ow2.util.event.api.IEventDispatcher lifeCycleDispatcher)
           
 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(TransactionManager tm)
          set the Transaction Manager.
 void setWorkManager(WorkManager wm)
          set the Work Manager.
 void storeAll(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 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(String name,
                  String extFileName,
                  String file,
                  ClassLoader ld,
                  DeploymentDesc dd,
                  CmiService cmiService,
                  HaService haService,
                  IJAXRPCService jaxrpService,
                  MBeanServer jmxserver,
                  ResourceService resService)
constructor

Parameters:
name - name of the container.
extFileName - external file name
file - file name (.jar or .xml)
ld - the class loader to be used
cmiService - the reference on CMI service (can be null)
haService - the reference on HA service (can be null)
Method Detail

getTmpDirName

public String getTmpDirName()

getJormMapping

public RdbMappingBuilder getJormMapping()

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:
EJBException

checkSecurity

protected void checkSecurity(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(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 ClassLoader getClassLoader()
Specified by:
getClassLoader in interface Container
Returns:
the classloader used for this Container

getContainerNaming

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

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

getDataSourceDependence

public Set<Properties> getDataSourceDependence(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 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 String getFileName()
Specified by:
getFileName in interface Container
Returns:
the file name of the container (.xml or .jar)

getExternalFileName

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

getJmsConnectionFactoryDependence

public Set<Properties> getJmsConnectionFactoryDependence(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 Set<Properties> getJmsDestinationDependence(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 Set<Properties> getMailFactoryDependence(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 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 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 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(Context ctx,
                               BeanDesc dd)
                        throws NamingException
Set the bean environment

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

setContainerNaming

public void setContainerNaming(JNamingManager 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(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(WorkManager wm)
set the Work Manager. Called by the EJB Server when starting the service.

Parameters:
wm - the Work Manager.

getWorkManager

public WorkManager getWorkManager()
Returns:
the WorkManager unique instance

setTransactionManager

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

getComponentContextFactory

public JComponentContextFactory getComponentContextFactory()

Specified by:
getComponentContextFactory in interface Container
Returns:
the JComponentContextFactory object.

setComponentContextFactory

public void setComponentContextFactory(JComponentContextFactory factory)
Set the JComponentContextFactory instance.

Specified by:
setComponentContextFactory in interface Container
Parameters:
factory - the JComponentContextFactory instance

getHaService

public HaService getHaService()
Returns:
the reference on CMI service

getCmiService

public CmiService getCmiService()
Returns:
the reference on HA service

getJavaEEApplicationName

public String getJavaEEApplicationName()
Gets the Java EE Application Name of this container.

Specified by:
getJavaEEApplicationName in interface Container
Returns:
the Java EE Application name if there is one

setJavaEEApplicationName

public void setJavaEEApplicationName(String javaEEApplicationName)
Sets the Java EE Application Name of this container.

Specified by:
setJavaEEApplicationName in interface Container
Parameters:
javaEEApplicationName - the Java EE Application name

getLifeCycleDispatcher

public org.ow2.util.event.api.IEventDispatcher getLifeCycleDispatcher()
Returns:
the lifeCycleDispatcher

setLifeCycleDispatcher

public void setLifeCycleDispatcher(org.ow2.util.event.api.IEventDispatcher lifeCycleDispatcher)
Parameters:
lifeCycleDispatcher - the lifeCycleDispatcher to set


Copyright © 2010 OW2 Consortium. All Rights Reserved.