org.objectweb.easybeans.container
Class JContainer3

java.lang.Object
  extended by org.objectweb.easybeans.container.JContainer3
All Implemented Interfaces:
EZBContainer

public class JContainer3
extends java.lang.Object
implements EZBContainer

Defines an EJB3 container.

Author:
Florent Benoit

Field Summary
private  java.io.File archive
          Archive used by this container.
private  boolean available
          Container available.
private  java.util.List<EZBContainerLifeCycleCallback> callbacksLifeCycle
          Callbacks.
private  java.lang.ClassLoader classLoader
          Classloader use to manage this archive.
private  Deployment deployment
          Deployment for the managed archive.
private  java.util.Map<java.lang.String,Factory> factories
          Map of managed ejb3 factories.
private  java.lang.String id
          Id of this container.
private static JLog logger
          Logger.
private  PersistenceUnitManager persistenceUnitManager
          Persistence manager object which manages all persistence-unit associated to this container.
 
Constructor Summary
JContainer3(java.io.File archive)
          Build a new container on the given archive.
 
Method Summary
private  void bindItf(java.lang.String itf, java.lang.reflect.InvocationHandler handler, ClassAnnotationMetadata bean, java.lang.String mode)
          Bind into registry interfaces for a bean making them available from clients.
 java.io.File getArchive()
          Gets the archive used by this container.
 java.lang.ClassLoader getClassLoader()
          Gets the classloader.
private  EZBContainerCallbackInfo getContainer3CallbackInfo()
          Gets information on the container that can be given to container callbacks.
 Factory getFactory(java.lang.String factoryName)
          Gets a factory with its given name.
 java.lang.String getId()
          Gets the id of this container.
 java.lang.String getName()
          Gets the name of this container.
 PersistenceUnitManager getPersistenceUnitManager()
          Gets the persistence manager object which manages all persistence-unit associated to this container.
 boolean isAvailable()
          Check if the container is available or not.
static java.lang.String jndiNameEncode(java.lang.String beanClassName, java.lang.String itfName, java.lang.String mode)
          Encode a given name by prefixing it with given mode.
 void setClassLoader(java.lang.ClassLoader classLoader)
          Sets the classloader.
 void setPersistenceUnitManager(PersistenceUnitManager persistenceUnitManager)
          Sets the persistence manager object which manages all persistence-unit associated to this container.
 void start()
          Start this container.
 void stop()
          Stop this container.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static JLog logger
Logger.


id

private java.lang.String id
Id of this container.


archive

private java.io.File archive
Archive used by this container.


classLoader

private java.lang.ClassLoader classLoader
Classloader use to manage this archive.


deployment

private Deployment deployment
Deployment for the managed archive.


available

private boolean available
Container available.


factories

private java.util.Map<java.lang.String,Factory> factories
Map of managed ejb3 factories.


persistenceUnitManager

private PersistenceUnitManager persistenceUnitManager
Persistence manager object which manages all persistence-unit associated to this container.


callbacksLifeCycle

private java.util.List<EZBContainerLifeCycleCallback> callbacksLifeCycle
Callbacks.

Constructor Detail

JContainer3

public JContainer3(java.io.File archive)
Build a new container on the given archive.

Parameters:
archive - the archive (jar file or exploded).
Method Detail

getId

public java.lang.String getId()
Gets the id of this container.

Specified by:
getId in interface EZBContainer
Returns:
string id.

start

public void start()
           throws EZBContainerException
Start this container.

Specified by:
start in interface EZBContainer
Throws:
EZBContainerException - if starting fails.

stop

public void stop()
Stop this container.

Specified by:
stop in interface EZBContainer

getContainer3CallbackInfo

private EZBContainerCallbackInfo getContainer3CallbackInfo()
Gets information on the container that can be given to container callbacks.

Returns:
information on the managed container.

bindItf

private void bindItf(java.lang.String itf,
                     java.lang.reflect.InvocationHandler handler,
                     ClassAnnotationMetadata bean,
                     java.lang.String mode)
              throws EZBContainerException
Bind into registry interfaces for a bean making them available from clients.

Parameters:
itf - the name of the interface that object will have.
handler - object which will be called on the client side.
bean - the bean class associated to given interface.
mode - Local, Remote, etc
Throws:
EZBContainerException - if interface cannot be loaded or if the bind fails

getFactory

public Factory getFactory(java.lang.String factoryName)
Gets a factory with its given name.

Specified by:
getFactory in interface EZBContainer
Parameters:
factoryName - the factory name.
Returns:
the factory found or null.

getName

public java.lang.String getName()
Gets the name of this container.

Specified by:
getName in interface EZBContainer
Returns:
the name.

getClassLoader

public java.lang.ClassLoader getClassLoader()
Gets the classloader.

Specified by:
getClassLoader in interface EZBContainer
Returns:
classloader of the container

getArchive

public java.io.File getArchive()
Gets the archive used by this container. It can be a .jar file or a directory.

Specified by:
getArchive in interface EZBContainer
Returns:
the archive.

isAvailable

public boolean isAvailable()
Check if the container is available or not.

Specified by:
isAvailable in interface EZBContainer
Returns:
true if the container is available.

getPersistenceUnitManager

public PersistenceUnitManager getPersistenceUnitManager()
Gets the persistence manager object which manages all persistence-unit associated to this container.

Specified by:
getPersistenceUnitManager in interface EZBContainer
Returns:
persistence unit manager object

jndiNameEncode

public static java.lang.String jndiNameEncode(java.lang.String beanClassName,
                                              java.lang.String itfName,
                                              java.lang.String mode)
Encode a given name by prefixing it with given mode.

Parameters:
beanClassName - name of the bean class.
itfName - name of the interface.
mode - local/remote, etc
Returns:
encoded jndi Name

setClassLoader

public void setClassLoader(java.lang.ClassLoader classLoader)
Sets the classloader.

Specified by:
setClassLoader in interface EZBContainer
Parameters:
classLoader - to be used by the container

setPersistenceUnitManager

public void setPersistenceUnitManager(PersistenceUnitManager persistenceUnitManager)
Sets the persistence manager object which manages all persistence-unit associated to this container.

Specified by:
setPersistenceUnitManager in interface EZBContainer
Parameters:
persistenceUnitManager - persistence unit manager object to set.