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 instance managed by the NamingManager

Author:
S.Chassande-Barrioz

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 bcn, java.lang.String clName, java.lang.ClassLoader classLoader)
           
protected  PNameManager findPNameManager(java.lang.String pnmcn, java.lang.String clName, java.lang.ClassLoader classLoader)
           
 java.lang.ClassLoader getClassLoader(java.lang.String className)
          Retrieves the classloader of a class if the class has been already mapped.
 byte getMappingStructureRule()
           
 PName getNull()
           
 PBinder getPBinder(java.lang.Class clazz)
          This Method is a shortcut to the getPBinder(SpeedoProxy) method.
 PBinder getPBinder(SpeedoProxy sp)
           
 PBinder getPBinder(java.lang.String className)
           
 PBinder getPBinder(java.lang.String classname, java.lang.ClassLoader cl)
           
 PClassMapping getPClassMapping(java.lang.Class clazz)
           
 PClassMapping getPClassMapping(SpeedoProxy sp)
          Retrieves a PClassMapping instance managing a SpeedoProxy.
 PClassMapping getPClassMapping(java.lang.String classname, java.lang.ClassLoader cl)
          This Method is a shortcut to the getPClassMapping(SpeedoProxy) method.
 PNamingContext getPNamingContext(java.lang.Class clazz)
           
 PNamingContext getPNamingContext(SpeedoProxy sp)
           
 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 setMappingStructureRule(byte rule)
           
 void setNullPName(java.lang.Object o)
           
 void setPType(PType pt)
           
 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

getPBinder

public PBinder getPBinder(java.lang.String className)

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

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)

getPBinder

public PBinder getPBinder(SpeedoProxy sp)
                   throws PException
Specified by:
getPBinder in interface JormFactory
Returns:
the PBinder instance which manages the identifer of the SpeedoProxy instance
Throws:
PException

getPBinder

public PBinder getPBinder(java.lang.Class clazz)
                   throws 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:
clazz - the Jorm class name managed by the wanted PBinder
Returns:
the PBinder instance to use for the given jorm class name
Throws:
org.objectweb.jorm.api.PException
PException

getPBinder

public PBinder getPBinder(java.lang.String classname,
                          java.lang.ClassLoader cl)
                   throws PException
Specified by:
getPBinder in interface JormFactory
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

getPClassMapping

public PClassMapping getPClassMapping(SpeedoProxy sp)
                               throws 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:
org.objectweb.jorm.api.PException
PException

getPClassMapping

public PClassMapping getPClassMapping(java.lang.String classname,
                                      java.lang.ClassLoader cl)
                               throws 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:
org.objectweb.jorm.api.PException
PException

getPClassMapping

public PClassMapping getPClassMapping(java.lang.Class clazz)
                               throws PException
Specified by:
getPClassMapping in interface JormFactory
Throws:
PException

getPNamingContext

public PNamingContext getPNamingContext(SpeedoProxy sp)
                                 throws PException
Specified by:
getPNamingContext in interface JormFactory
Returns:
the PNamingContext instance which manages a reference to the SpeedoProxy instance
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

getPNamingContext

public PNamingContext getPNamingContext(java.lang.Class clazz)
                                 throws PException
Specified by:
getPNamingContext in interface JormFactory
Throws:
PException

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)

findPBinder

public PBinder findPBinder(java.lang.String bcn,
                           java.lang.String clName,
                           java.lang.ClassLoader classLoader)
                    throws PException
Throws:
PException

findPNameManager

protected PNameManager findPNameManager(java.lang.String pnmcn,
                                        java.lang.String clName,
                                        java.lang.ClassLoader classLoader)
                                 throws PException
Throws:
PException