org.objectweb.speedo.runtime
Class BasicJormFactory

org.objectweb.speedo.runtime.BasicJormFactory
All Implemented Interfaces:
JormFactory

public class BasicJormFactory
implements JormFactory

This class manages both naming sorts used in Speedo (Container id and user id). The container id (long, long) management is delegated to a polymorphId manager (PolymorphIdMgrImpl) whereas the user id is directly managed by this class. In JDO the binder instance can be used also as PNamingContext because all classes in a class hierarchy must have the same identifier strucutre. Then it is not necessary to use intermediates PNamingContext. Then a PName is always valid inside a PBinder.

Author:
S.Chassande-Barrioz

Field Summary
static java.lang.String BASID_BINDER_CLASS_NAME
           
protected  org.objectweb.perseus.cache.api.CacheManager cache
           
static java.lang.String CACHE_MANAGER_BINDING
           
static java.lang.String CID_BINDER_CLASS_NAME
           
static java.lang.String CID_PNM_CLASS_NAME
           
protected  org.objectweb.jorm.facility.naming.polymorphid.PolymorphIdMgrImpl cIdManager
          The manager of the naming used by the container (long, long).
static boolean CODING_ONLY
           
protected  org.objectweb.util.monolog.api.Logger logger
           
static java.lang.String LOGGER_FACTORY_BINDING
           
static java.lang.String LOGGER_NAME
           
protected  org.objectweb.util.monolog.api.LoggerFactory loggerFactory
           
protected  org.objectweb.jorm.api.PMapper mapper
          The mapper is used to map and find the Jorm classes.
static java.lang.String MAPPER_BINDING
           
protected  java.util.Map uIdBinders
          It contains the association between a class name and its binder.
 
Constructor Summary
BasicJormFactory()
          builds the BasicJormFactory and instanciate the polymorphid manager and the hosting structure for the binder referencemet.
 
Method Summary
 void addFcBinding(java.lang.String s, java.lang.Object o)
           
 org.objectweb.jorm.naming.api.PName decode(java.lang.Object oid)
          It retrieves a PName since a representation of an identifier.
 java.lang.Object encode(org.objectweb.jorm.naming.api.PName pn)
          It retrieves a representation of an identifier since a PName.
protected  org.objectweb.jorm.naming.api.PNameManager findPNameManager(java.lang.String pnmcn, java.lang.String clName)
           
 org.objectweb.jorm.facility.naming.polymorphid.PolymorphIdMgrImpl getcIdManager()
           
 java.lang.Object getFcBindings(java.lang.String s)
           
 org.objectweb.jorm.naming.api.PBinder getPBinder(SpeedoProxy sp)
           
 org.objectweb.jorm.naming.api.PBinder getPBinder(java.lang.String classname)
          This Method is a shortcut to the getPBinder(SpeedoProxy) method.
 org.objectweb.jorm.api.PClassMapping getPClassMapping(SpeedoProxy sp)
          Retrieves a PClassMapping instance managing a SpeedoProxy.
 org.objectweb.jorm.api.PClassMapping getPClassMapping(java.lang.String classname)
          This Method is a shortcut to the getPClassMapping(SpeedoProxy) method.
 org.objectweb.jorm.naming.api.PNamingContext getPNamingContext(SpeedoProxy sp)
           
 org.objectweb.jorm.naming.api.PNamingContext getPNamingContext(java.lang.String classname)
          This Method is a shortcut to the getPNamingContext(SpeedoProxy) method.
 void removeFcBinding(java.lang.String s, java.lang.Object serverItf)
           
 

Field Detail

MAPPER_BINDING

public static final java.lang.String MAPPER_BINDING

LOGGER_FACTORY_BINDING

public static final java.lang.String LOGGER_FACTORY_BINDING

CACHE_MANAGER_BINDING

public static final java.lang.String CACHE_MANAGER_BINDING

LOGGER_NAME

public static final java.lang.String LOGGER_NAME

CID_BINDER_CLASS_NAME

public static final java.lang.String CID_BINDER_CLASS_NAME

CID_PNM_CLASS_NAME

public static final java.lang.String CID_PNM_CLASS_NAME

BASID_BINDER_CLASS_NAME

public static final java.lang.String BASID_BINDER_CLASS_NAME

CODING_ONLY

public static final boolean CODING_ONLY

mapper

protected org.objectweb.jorm.api.PMapper mapper
The mapper is used to map and find the Jorm classes.

loggerFactory

protected org.objectweb.util.monolog.api.LoggerFactory loggerFactory

cache

protected org.objectweb.perseus.cache.api.CacheManager cache

cIdManager

protected org.objectweb.jorm.facility.naming.polymorphid.PolymorphIdMgrImpl cIdManager
The manager of the naming used by the container (long, long). It provides PBinder, PNamingContext since a class name.

uIdBinders

protected java.util.Map uIdBinders
It contains the association between a class name and its binder. This map contains only the binders which manage user pname structures.

logger

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

BasicJormFactory

public BasicJormFactory()
builds the BasicJormFactory and instanciate the polymorphid manager and the hosting structure for the binder referencemet.
Method Detail

getcIdManager

public org.objectweb.jorm.facility.naming.polymorphid.PolymorphIdMgrImpl getcIdManager()

getFcBindings

public java.lang.Object getFcBindings(java.lang.String s)

addFcBinding

public void addFcBinding(java.lang.String s,
                         java.lang.Object o)

removeFcBinding

public void removeFcBinding(java.lang.String s,
                            java.lang.Object serverItf)

getPBinder

public org.objectweb.jorm.naming.api.PBinder getPBinder(SpeedoProxy sp)
                                                 throws org.objectweb.jorm.api.PException
Specified by:
getPBinder in interface JormFactory
Returns:
the PBinder instance which manages the identifer of the SpeedoProxy instance

getPBinder

public org.objectweb.jorm.naming.api.PBinder getPBinder(java.lang.String classname)
                                                 throws org.objectweb.jorm.api.PException
This Method is a shortcut to the getPBinder(SpeedoProxy) method. It only does the instanciation of the classname (Class.ForName(classsName).newInstance()) and call the getPBinder(SpeedoProxy) method with the created instance. Then if an instance is availlable it is better to use the other method.
Specified by:
getPBinder in interface JormFactory
Parameters:
classname - the Jorm class name managed by the wanted PBinder
Returns:
the PBinder instance to use for the given jorm class name
Throws:
PException -  

getPClassMapping

public org.objectweb.jorm.api.PClassMapping getPClassMapping(SpeedoProxy sp)
                                                      throws org.objectweb.jorm.api.PException
Retrieves a PClassMapping instance managing a SpeedoProxy. If the PClassMapping does not already exist then it is created, configured and mapped in the PMapper. The PClassMapping configuration contains the PBinder assignement, the PNamingContext assignement for each reference, and the GenClassMapping assignement. The assigned GenClassMapping must also be configured. In other hand the PClassMapping of referenced class is not configured now. Only the PNamingContext is needed.
Specified by:
getPClassMapping in interface JormFactory
Parameters:
sp - is the SpeedoProxy instance which the PClassMapping is required
Returns:
the PClassMapping which manages a SpeedoProxy
Throws:
PException -  

getPClassMapping

public org.objectweb.jorm.api.PClassMapping getPClassMapping(java.lang.String classname)
                                                      throws org.objectweb.jorm.api.PException
This Method is a shortcut to the getPClassMapping(SpeedoProxy) method. It only does the instanciation of the classname (Class.ForName(classsName).newInstance()) and call the getPClassMapping(SpeedoProxy) method with the created instance. Then if an instance is availlable it is better to use the other method. Retrieves a PClassMapping instance managing a jorm class. If the PClassMapping does not already exist then it is created, configured and mapped in the PMapper. The PClassMapping configuration contains the PBinder assignement, the PNamingContext assignement for each reference, and the GenClassMapping assignement. The assigned GenClassMapping must also be configured. In other hand the PClassMapping of referenced class is not configured now. Only the PNamingContext is needed.
Specified by:
getPClassMapping in interface JormFactory
Parameters:
classname - is the class name of the jorm class which the PClassMapping is required
Returns:
the PClassMapping which manages a SpeedoProxy
Throws:
PException -  

getPNamingContext

public org.objectweb.jorm.naming.api.PNamingContext getPNamingContext(SpeedoProxy sp)
                                                               throws org.objectweb.jorm.api.PException
Specified by:
getPNamingContext in interface JormFactory
Returns:
the PNamingContext instance which manages a reference to the SpeedoProxy instance

getPNamingContext

public org.objectweb.jorm.naming.api.PNamingContext getPNamingContext(java.lang.String classname)
                                                               throws org.objectweb.jorm.api.PException
This Method is a shortcut to the getPNamingContext(SpeedoProxy) method. It only does the instanciation of the classname (Class.ForName(classsName).newInstance()) and call the getPNamingContext(SpeedoProxy) method with the created instance. Then if an instance is availlable it is better to use the other method.
Specified by:
getPNamingContext in interface JormFactory
Parameters:
classname - the Jorm class name managed by the wanted PNamingContext
Returns:
the PNamingContext instance to use for the given jorm class name
Throws:
PException -  

decode

public org.objectweb.jorm.naming.api.PName decode(java.lang.Object oid)
                                           throws org.objectweb.jorm.api.PException
It retrieves a PName since a representation of an identifier. The representation can be a PName which the PNamingContext reference must be checked and updated if needed. The identifier representation can be also an encode version of a PName. The coding format depends on the implementation.
Specified by:
decode in interface JormFactory
Parameters:
oid - is the identifier representation
Returns:
a PName matching the oid representation and valid in a PNameManager
Throws:
PException - if the oid does not represent a managed identifier representation.

encode

public java.lang.Object encode(org.objectweb.jorm.naming.api.PName pn)
                        throws org.objectweb.jorm.api.PException
It retrieves a representation of an identifier since a PName.
Specified by:
encode in interface JormFactory
Parameters:
pn - is the pname to encode
Returns:
an identifier representation
Throws:
PException - if the pname is malformed (null for example).

findPNameManager

protected org.objectweb.jorm.naming.api.PNameManager findPNameManager(java.lang.String pnmcn,
                                                                      java.lang.String clName)
                                                               throws org.objectweb.jorm.api.PException