org.objectweb.speedo.mapper.lib
Class BasicJormFactory

java.lang.Object
  extended byorg.objectweb.speedo.mapper.lib.BasicJormFactory
All Implemented Interfaces:
JormFactory, JormFactoryAttributes

public class BasicJormFactory
extends java.lang.Object
implements JormFactory, JormFactoryAttributes

This class manages the initialization and the naming, of persistent class. The type of naming supported depends on the NamingManager registered into the NamingManagerFactory

Author:
S.Chassande-Barrioz
See Also:
NamingManager

Field Summary
protected  java.util.Map binders
          key = String class name value = PBinder binder of the class
protected  CacheManager cache
          The cache to assign to the binders
static java.lang.String CACHE_MANAGER_BINDING
          fractal binding name to the cache manager
protected  java.util.Map cn2pcm
          temporaly variable use in the recursive algorithm
protected  Logger logger
           
protected  PMapper mapper
          The mapper is used to map and find the Jorm classes.
static java.lang.String MAPPER_BINDING
          fractal binding name to the mapper
protected  java.util.Map pnamingContexts
          key = String class name value = PNamingContext pnc of the class
 
Fields inherited from interface org.objectweb.speedo.mapper.api.JormFactoryAttributes
CREATE_IF_REQUIRED, DELETE_DATA, DO_NOTHING, FORCE_CREATE
 
Constructor Summary
BasicJormFactory()
          builds the BasicJormFactory and the hosting structure for the binder list.
 
Method Summary
 void bindFc(java.lang.String s, java.lang.Object o)
           
 boolean codingSupported(int codingtype)
           
 PName decode(byte[] en)
           
 PName decodeAbstract(java.lang.Object oid, java.lang.Object context)
           
 PName decodeBigDecimal(java.math.BigDecimal en)
           
 PName decodeBigInteger(java.math.BigInteger en)
           
 PName decodeByte(byte en)
           
 PName decodeChar(char en)
           
 PName decodeCharArray(char[] en)
           
 PName decodeDate(java.util.Date en)
           
 PName decodeInt(int en)
           
 PName decodeLong(long en)
           
 PName decodeObyte(java.lang.Byte en)
           
 PName decodeOchar(java.lang.Character en)
           
 PName decodeOint(java.lang.Integer en)
           
 PName decodeOlong(java.lang.Long en)
           
 PName decodeOshort(java.lang.Short en)
           
 PName decodeShort(short en)
           
 PName decodeString(java.lang.String en)
           
 byte[] encode(PName pn)
           
 java.lang.Object encodeAbstract(PName pn)
           
 java.math.BigDecimal encodeBigDecimal(PName pn)
           
 java.math.BigInteger encodeBigInteger(PName pn)
           
 byte encodeByte(PName pn)
           
 char encodeChar(PName pn)
           
 char[] encodeCharArray(PName pn)
           
 java.util.Date encodeDate(PName pn)
           
 int encodeInt(PName pn)
           
 long encodeLong(PName pn)
           
 java.lang.Byte encodeObyte(PName pn)
           
 java.lang.Character encodeOchar(PName pn)
           
 java.lang.Integer encodeOint(PName pn)
           
 java.lang.Long encodeOlong(PName pn)
           
 java.lang.Short encodeOshort(PName pn)
           
 short encodeShort(PName pn)
           
 java.lang.String encodeString(PName pn)
           
 PBinder findPBinder(java.lang.String className, java.lang.ClassLoader classLoader, java.lang.String hints)
          Retrieves a PBinder managing a given persistent class.
protected  PNameManager findPNameManager(java.lang.String className, java.lang.ClassLoader classLoader, java.lang.String hints)
          Retrieves a PNameManager managing a given persistent class and its sub classes.
 java.lang.ClassLoader getClassLoader(java.lang.String className)
          Retrieves the classloader of a class if the class has been already mapped.
 java.lang.String getFcState()
           
 PClassMapping getGenClassMapping(java.lang.String path)
          Retrieve the PClassMapping of a gen class since its path
 boolean getMappingOnClassRegistration()
          Indicates if during the class registration, the persistent classes have to be mapped.
 byte getMappingStructureRule()
           
 PName getNull()
           
 PBinder getPBinder(java.lang.Class clazz)
          Retrieve the Binder managing the persistent class (Not a Generic class).
 PBinder getPBinder(java.lang.String classname, java.lang.ClassLoader cl)
          Retrieve the Binder managing the persistent class (Not a Generic class).
 PClassMapping getPClassMapping(java.lang.Class clazz)
          Retrieves a PClassMapping instance managing a jorm class.
 PClassMapping getPClassMapping(java.lang.String classname, java.lang.ClassLoader cl)
          Is a shortcut to the call getPClassMapping(Class.forName(classname, cl, true))
 PClassMapping getPClassMapping(java.lang.String className, java.lang.ClassLoader classLoader, java.util.Properties classProperties)
          This method is the real implementation of the getPClassMapping methods from the JormFactory interface.
 PNamingContext getPNamingContext(java.lang.Class clazz)
          Retrieve the PNamingcontext managing the persistent class (Not a Generic class) and its sub classes.
 PNamingContext getPNamingContext(java.lang.String classname, java.lang.ClassLoader cl)
          This Method is a shortcut to the getPNamingContext(SpeedoProxy) method.
 PType getPType()
           
 java.lang.String[] listFc()
           
 java.lang.Object lookupFc(java.lang.String s)
           
 void registerClass(RegisterClassEvent event)
          Automatic mechanism for persistent clas registration.
 void setMappingOnClassRegistration(boolean val)
           
 void setMappingStructureRule(byte rule)
           
 void setNullPName(java.lang.Object o)
           
 void setPType(PType pt)
           
 void startFc()
           
 void stopFc()
           
 boolean supportCompositeField(java.lang.String fn, PType ft)
           
 boolean supportDynamicComposite()
           
 boolean supportStaticComposite()
           
 void unbindFc(java.lang.String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAPPER_BINDING

public static final java.lang.String MAPPER_BINDING
fractal binding name to the mapper

See Also:
Constant Field Values

CACHE_MANAGER_BINDING

public static final java.lang.String CACHE_MANAGER_BINDING
fractal binding name to the cache manager

See Also:
Constant Field Values

mapper

protected PMapper mapper
The mapper is used to map and find the Jorm classes.


cache

protected CacheManager cache
The cache to assign to the binders


binders

protected java.util.Map binders
key = String class name value = PBinder binder of the class


pnamingContexts

protected java.util.Map pnamingContexts
key = String class name value = PNamingContext pnc of the class


cn2pcm

protected java.util.Map cn2pcm
temporaly variable use in the recursive algorithm


logger

protected Logger logger
Constructor Detail

BasicJormFactory

public BasicJormFactory()
builds the BasicJormFactory and the hosting structure for the binder list.

Method Detail

getMappingStructureRule

public byte getMappingStructureRule()
Specified by:
getMappingStructureRule in interface JormFactory
See Also:
JormFactoryAttributes

setMappingStructureRule

public void setMappingStructureRule(byte rule)
Specified by:
setMappingStructureRule in interface JormFactoryAttributes
Parameters:
rule - is the default mapping structure rule to apply during the map operation of the persistent classes.

getMappingOnClassRegistration

public boolean getMappingOnClassRegistration()
Description copied from interface: JormFactoryAttributes
Indicates if during the class registration, the persistent classes have to be mapped. True : the class are mapped at class registration time False: nothing is done.

Specified by:
getMappingOnClassRegistration in interface JormFactoryAttributes

setMappingOnClassRegistration

public void setMappingOnClassRegistration(boolean val)
Specified by:
setMappingOnClassRegistration in interface JormFactoryAttributes
Parameters:
val - is a boolean value Indicating if during the class registration, the persistent classes have to be mapped. True : the class are mapped at class registration time False: nothing is done.

listFc

public java.lang.String[] listFc()

lookupFc

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

bindFc

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

unbindFc

public void unbindFc(java.lang.String s)

getFcState

public java.lang.String getFcState()

startFc

public void startFc()
             throws IllegalLifeCycleException
Throws:
IllegalLifeCycleException

stopFc

public void stopFc()
            throws IllegalLifeCycleException
Throws:
IllegalLifeCycleException

getPBinder

public PBinder getPBinder(java.lang.Class clazz)
                   throws PException
Description copied from interface: JormFactory
Retrieve the Binder managing the persistent class (Not a Generic class). This method is a shortcut to this call: getPClassMapping(clazz).getPBinder()

Specified by:
getPBinder in interface JormFactory
Parameters:
clazz - the Jorm class name managed which the PBinder is asked
Returns:
the PBinder instance to use for the given jorm class name
Throws:
PException

getPBinder

public PBinder getPBinder(java.lang.String classname,
                          java.lang.ClassLoader cl)
                   throws PException
Description copied from interface: JormFactory
Retrieve the Binder managing the persistent class (Not a Generic class). This method is a shortcut to this call: getPClassMapping(Class.forName(classname, cl, true)).getPBinder()

Specified by:
getPBinder in interface JormFactory
Parameters:
classname - is the class name of the jorm class which the PBinder is required
cl - is the classloader where to find/load the class
Returns:
the PBinder instance to use for the given jorm class name
Throws:
PException

getClassLoader

public java.lang.ClassLoader getClassLoader(java.lang.String className)
Description copied from interface: JormFactory
Retrieves the classloader of a class if the class has been already mapped. Otherwise a null value is returned

Specified by:
getClassLoader in interface JormFactory

getGenClassMapping

public PClassMapping getGenClassMapping(java.lang.String path)
Description copied from interface: JormFactory
Retrieve the PClassMapping of a gen class since its path

Specified by:
getGenClassMapping in interface JormFactory
Parameters:
path - is the path representing the way to access the GenClassMapping

getPClassMapping

public PClassMapping getPClassMapping(java.lang.String classname,
                                      java.lang.ClassLoader cl)
                               throws PException
Description copied from interface: JormFactory
Is a shortcut to the call getPClassMapping(Class.forName(classname, cl, true))

Specified by:
getPClassMapping in interface JormFactory
Parameters:
classname - is the class name of the jorm class which the PClassMapping is required
cl - is the classloader where to find/load the class
Returns:
the PClassMapping which manages a SpeedoProxy
Throws:
PException

getPClassMapping

public PClassMapping getPClassMapping(java.lang.Class clazz)
                               throws PException
Description copied from interface: JormFactory
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:
clazz - is the class of the jorm class which the PClassMapping is required
Returns:
the PClassMapping which manages the persistent class
Throws:
PException

getPNamingContext

public PNamingContext getPNamingContext(java.lang.String classname,
                                        java.lang.ClassLoader cl)
                                 throws 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:
org.objectweb.jorm.api.PException
PException
See Also:
this.getPNamingContext(Class)

getPNamingContext

public PNamingContext getPNamingContext(java.lang.Class clazz)
                                 throws PException
Description copied from interface: JormFactory
Retrieve the PNamingcontext managing the persistent class (Not a Generic class) and its sub classes.

Specified by:
getPNamingContext in interface JormFactory
Parameters:
clazz - the Jorm class name managed which the PNamingContext is asked
Returns:
the PBinder instance to use for the given jorm class name
Throws:
PException

registerClass

public void registerClass(RegisterClassEvent event)
Automatic mechanism for persistent clas registration.


codingSupported

public boolean codingSupported(int codingtype)

decode

public PName decode(byte[] en)
             throws PExceptionNaming
Throws:
PExceptionNaming

decodeAbstract

public PName decodeAbstract(java.lang.Object oid,
                            java.lang.Object context)
                     throws PExceptionNaming,
                            java.lang.UnsupportedOperationException
Throws:
PExceptionNaming
java.lang.UnsupportedOperationException

decodeByte

public PName decodeByte(byte en)
                 throws PExceptionNaming,
                        java.lang.UnsupportedOperationException
Throws:
PExceptionNaming
java.lang.UnsupportedOperationException

decodeObyte

public PName decodeObyte(java.lang.Byte en)
                  throws PExceptionNaming,
                         java.lang.UnsupportedOperationException
Throws:
PExceptionNaming
java.lang.UnsupportedOperationException

decodeChar

public PName decodeChar(char en)
                 throws PExceptionNaming,
                        java.lang.UnsupportedOperationException
Throws:
PExceptionNaming
java.lang.UnsupportedOperationException

decodeOchar

public PName decodeOchar(java.lang.Character en)
                  throws PExceptionNaming,
                         java.lang.UnsupportedOperationException
Throws:
PExceptionNaming
java.lang.UnsupportedOperationException

decodeInt

public PName decodeInt(int en)
                throws PExceptionNaming,
                       java.lang.UnsupportedOperationException
Throws:
PExceptionNaming
java.lang.UnsupportedOperationException

decodeOint

public PName decodeOint(java.lang.Integer en)
                 throws PExceptionNaming,
                        java.lang.UnsupportedOperationException
Throws:
PExceptionNaming
java.lang.UnsupportedOperationException

decodeLong

public PName decodeLong(long en)
                 throws PExceptionNaming,
                        java.lang.UnsupportedOperationException
Throws:
PExceptionNaming
java.lang.UnsupportedOperationException

decodeOlong

public PName decodeOlong(java.lang.Long en)
                  throws PExceptionNaming,
                         java.lang.UnsupportedOperationException
Throws:
PExceptionNaming
java.lang.UnsupportedOperationException

decodeShort

public PName decodeShort(short en)
                  throws PExceptionNaming,
                         java.lang.UnsupportedOperationException
Throws:
PExceptionNaming
java.lang.UnsupportedOperationException

decodeOshort

public PName decodeOshort(java.lang.Short en)
                   throws PExceptionNaming,
                          java.lang.UnsupportedOperationException
Throws:
PExceptionNaming
java.lang.UnsupportedOperationException

decodeString

public PName decodeString(java.lang.String en)
                   throws PExceptionNaming
Throws:
PExceptionNaming

decodeCharArray

public PName decodeCharArray(char[] en)
                      throws PExceptionNaming
Throws:
PExceptionNaming

decodeDate

public PName decodeDate(java.util.Date en)
                 throws PExceptionNaming
Throws:
PExceptionNaming

decodeBigInteger

public PName decodeBigInteger(java.math.BigInteger en)
                       throws PExceptionNaming
Throws:
PExceptionNaming

decodeBigDecimal

public PName decodeBigDecimal(java.math.BigDecimal en)
                       throws PExceptionNaming
Throws:
PExceptionNaming

encode

public byte[] encode(PName pn)
              throws PExceptionNaming
Throws:
PExceptionNaming

encodeAbstract

public java.lang.Object encodeAbstract(PName pn)
                                throws PExceptionNaming,
                                       java.lang.UnsupportedOperationException
Throws:
PExceptionNaming
java.lang.UnsupportedOperationException

encodeByte

public byte encodeByte(PName pn)
                throws PExceptionNaming,
                       java.lang.UnsupportedOperationException
Throws:
PExceptionNaming
java.lang.UnsupportedOperationException

encodeObyte

public java.lang.Byte encodeObyte(PName pn)
                           throws PExceptionNaming,
                                  java.lang.UnsupportedOperationException
Throws:
PExceptionNaming
java.lang.UnsupportedOperationException

encodeChar

public char encodeChar(PName pn)
                throws PExceptionNaming,
                       java.lang.UnsupportedOperationException
Throws:
PExceptionNaming
java.lang.UnsupportedOperationException

encodeOchar

public java.lang.Character encodeOchar(PName pn)
                                throws PExceptionNaming,
                                       java.lang.UnsupportedOperationException
Throws:
PExceptionNaming
java.lang.UnsupportedOperationException

encodeInt

public int encodeInt(PName pn)
              throws PExceptionNaming,
                     java.lang.UnsupportedOperationException
Throws:
PExceptionNaming
java.lang.UnsupportedOperationException

encodeOint

public java.lang.Integer encodeOint(PName pn)
                             throws PExceptionNaming,
                                    java.lang.UnsupportedOperationException
Throws:
PExceptionNaming
java.lang.UnsupportedOperationException

encodeLong

public long encodeLong(PName pn)
                throws PExceptionNaming,
                       java.lang.UnsupportedOperationException
Throws:
PExceptionNaming
java.lang.UnsupportedOperationException

encodeOlong

public java.lang.Long encodeOlong(PName pn)
                           throws PExceptionNaming,
                                  java.lang.UnsupportedOperationException
Throws:
PExceptionNaming
java.lang.UnsupportedOperationException

encodeShort

public short encodeShort(PName pn)
                  throws PExceptionNaming,
                         java.lang.UnsupportedOperationException
Throws:
PExceptionNaming
java.lang.UnsupportedOperationException

encodeOshort

public java.lang.Short encodeOshort(PName pn)
                             throws PExceptionNaming,
                                    java.lang.UnsupportedOperationException
Throws:
PExceptionNaming
java.lang.UnsupportedOperationException

encodeString

public java.lang.String encodeString(PName pn)
                              throws PExceptionNaming
Throws:
PExceptionNaming

encodeCharArray

public char[] encodeCharArray(PName pn)
                       throws PExceptionNaming
Throws:
PExceptionNaming

encodeDate

public java.util.Date encodeDate(PName pn)
                          throws PExceptionNaming
Throws:
PExceptionNaming

encodeBigInteger

public java.math.BigInteger encodeBigInteger(PName pn)
                                      throws PExceptionNaming
Throws:
PExceptionNaming

encodeBigDecimal

public java.math.BigDecimal encodeBigDecimal(PName pn)
                                      throws PExceptionNaming
Throws:
PExceptionNaming

getNull

public PName getNull()

setNullPName

public void setNullPName(java.lang.Object o)
                  throws PException
Throws:
PException

supportDynamicComposite

public boolean supportDynamicComposite()

supportCompositeField

public boolean supportCompositeField(java.lang.String fn,
                                     PType ft)

supportStaticComposite

public boolean supportStaticComposite()

getPType

public PType getPType()

setPType

public void setPType(PType pt)

getPClassMapping

public PClassMapping getPClassMapping(java.lang.String className,
                                      java.lang.ClassLoader classLoader,
                                      java.util.Properties classProperties)
                               throws PException
This method is the real implementation of the getPClassMapping methods from the JormFactory interface. It instanciates and configure a persistent class. That represents - the instanciation of the PClassMapping - its configuration: fetching PNamingContext instances for each reference and allocating GenClassMapping for each gen class reference (collection). - the mapping of class (map operation on the mapper) - the management of data strucutre for the cluster (creation table)

Parameters:
className - is the class name of the persistent class which the PClasMapping is asked
classLoader - is the classloader for the persistent class. It assumes that the classloader contains the Speedo/Jorm classes about the persistent class (PClassMapping, PAccessor, PName, PBinder, PNG, ...)
classProperties - is the Properties of the persistent class. This properties contains the information permitting to allowing the naming manager for the class and its references.
Returns:
The PClassMapping of the persistent class
Throws:
PException

findPBinder

public PBinder findPBinder(java.lang.String className,
                           java.lang.ClassLoader classLoader,
                           java.lang.String hints)
                    throws PException
Retrieves a PBinder managing a given persistent class. This implementation delegates the PBinder allocation to NamingManager.

Parameters:
className - is the name of the persistent class which the asked PBinder must managed
classLoader - is the classloader for the persistent class. It assumes that the classloader contains the Speedo/Jorm classes about the persistent class (PClassMapping, PAccessor, PName, PBinder, PNG, ...)
hints - is a string data permitting to allocate and to configure the PBinder.
Returns:
the PBinder managing the given persistent class.
Throws:
PException
See Also:
NamingManager

findPNameManager

protected PNameManager findPNameManager(java.lang.String className,
                                        java.lang.ClassLoader classLoader,
                                        java.lang.String hints)
                                 throws PException
Retrieves a PNameManager managing a given persistent class and its sub classes. This implementation delegates the PNameManager allocation to NamingManager.

Parameters:
className - is the name of the persistent class which the asked PNameManager must managed (non null value is required)
classLoader - is the classloader for the persistent class. It assumes that the classloader contains the Speedo/Jorm classes about the persistent class (PClassMapping, PAccessor, PName, PBinder, PNG, ...) (non null value is required)
hints - is a string data permitting to allocate and to configure the PNameManager. (non null value is required)
Returns:
the PNameManager managing the given persistent class and its sub classes.
Throws:
PException
See Also:
NamingManager