org.jpox.store.mapping
Class AbstractMappingManager

java.lang.Object
  extended byorg.jpox.store.mapping.AbstractMappingManager
All Implemented Interfaces:
MappingManager
Direct Known Subclasses:
org.jpox.store.rdbms.mapping.AbstractRDBMSMappingManager

public abstract class AbstractMappingManager
extends java.lang.Object
implements MappingManager

Base implementation of a MappingManager. Datastores should extend this to add their own specifics, and to add the initialisation of their supported types.

The idea behind a MappingManager is that at the Java side we have a series of Java type mappings, and at the datastore side we have a series of datastore type mappings. We need a link between the two to say that "this Java type can map to any of these 3 datastore types, and by default use this one".

Version:
$Revision: 1.53 $

Nested Class Summary
protected  class AbstractMappingManager.TypeMapping
           
 
Field Summary
protected static Localiser LOCALISER
           
 
Constructor Summary
AbstractMappingManager()
          Default constructor.
 
Method Summary
protected  java.lang.Class getDefaultJavaTypeMapping(TypeManager typeMgr, java.lang.String javaTypeName)
          Method to return the default java type mapping class for a specified java type name.
 JavaTypeMapping getElementMapping(DatastoreContainerObject container, AbstractPropertyMetaData fmd, DatastoreAdapter dba, ClassLoaderResolver clr)
          Convenience accessor for the element mapping for a collection/array of PC elements.
 JavaTypeMapping getKeyMapping(DatastoreContainerObject container, AbstractPropertyMetaData fmd, DatastoreAdapter dba, ClassLoaderResolver clr)
          Convenience accessor for the key mapping for a map of PC keys.
 JavaTypeMapping getMapping(java.lang.Class c, boolean serialised, boolean embedded, StoreManager storeMgr, ClassLoaderResolver clr, DatastoreAdapter dba)
          Accessor for the mapping for the specified class.
 JavaTypeMapping getMapping(java.lang.Class c, boolean serialised, boolean embedded, java.lang.String fieldName, DatastoreAdapter dba, TypeManager typeMgr)
          Accessor for the mapping for the specified class.
 JavaTypeMapping getMapping(DatastoreContainerObject datastoreContainer, AbstractPropertyMetaData fmd, DatastoreAdapter dba, ClassLoaderResolver clr)
          Accessor for the mapping for the field of the specified table.
protected  java.lang.Class getMappingClass(java.lang.Class c, boolean serialised, boolean embedded, java.lang.String fieldName, TypeManager typeMgr)
          Accessor for the mapping class for the specified class.
 JavaTypeMapping getValueMapping(DatastoreContainerObject container, AbstractPropertyMetaData fmd, DatastoreAdapter dba, ClassLoaderResolver clr)
          Convenience accessor for the value mapping for a map of PC values.
 void loadDatastoreMapping(PluginManager mgr, ClassLoaderResolver clr, java.lang.String vendorId)
          Initialise the datastore mapping file.
abstract  void registerDatastoreMapping(java.lang.String javaTypeName, java.lang.Class datastoreMappingType, java.lang.String jdbcType, java.lang.String sqlType, boolean dflt)
          Utility to register a datastore mapping for a java type, and the SQL/JDBC types it can be mapped to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jpox.store.mapping.MappingManager
createDatastoreField, createDatastoreField, createDatastoreField, createDatastoreMapping, createDatastoreMapping
 

Field Detail

LOCALISER

protected static final Localiser LOCALISER
Constructor Detail

AbstractMappingManager

public AbstractMappingManager()
Default constructor.

Method Detail

loadDatastoreMapping

public void loadDatastoreMapping(PluginManager mgr,
                                 ClassLoaderResolver clr,
                                 java.lang.String vendorId)
Initialise the datastore mapping file.

Specified by:
loadDatastoreMapping in interface MappingManager
Parameters:
mgr - the PluginManager
clr - the ClassLoaderResolver
vendorId - the datastore vendor id

getMapping

public JavaTypeMapping getMapping(java.lang.Class c,
                                  boolean serialised,
                                  boolean embedded,
                                  java.lang.String fieldName,
                                  DatastoreAdapter dba,
                                  TypeManager typeMgr)
Accessor for the mapping for the specified class.

Specified by:
getMapping in interface MappingManager
Parameters:
c - Java type
dba - Datastore Adapter
typeMgr - the TypeManager
serialised - Whether the type is serialised
embedded - Whether the type is embedded
fieldName - Name of the field (for logging only)
Returns:
The mapping for the class.

getMapping

public JavaTypeMapping getMapping(java.lang.Class c,
                                  boolean serialised,
                                  boolean embedded,
                                  StoreManager storeMgr,
                                  ClassLoaderResolver clr,
                                  DatastoreAdapter dba)
Accessor for the mapping for the specified class. Usually only called by JDOQL query expressions.

Specified by:
getMapping in interface MappingManager
Parameters:
c - Java type
serialised - Whether the type is serialised
embedded - Whether the type is embedded
storeMgr - Manager for the store
clr - ClassLoader resolver
dba - Datastore Adapter
Returns:
The mapping for the class.

getElementMapping

public JavaTypeMapping getElementMapping(DatastoreContainerObject container,
                                         AbstractPropertyMetaData fmd,
                                         DatastoreAdapter dba,
                                         ClassLoaderResolver clr)
Convenience accessor for the element mapping for a collection/array of PC elements. Currently only used where the collection/array elements are either serialised or embedded into a join table.

Specified by:
getElementMapping in interface MappingManager
Parameters:
container - The container
fmd - MetaData for the collection field containing the collection/array of PCs
dba - Database adapter
clr - ClassLoader resolver
Returns:
The Java type mapping

getKeyMapping

public JavaTypeMapping getKeyMapping(DatastoreContainerObject container,
                                     AbstractPropertyMetaData fmd,
                                     DatastoreAdapter dba,
                                     ClassLoaderResolver clr)
Convenience accessor for the key mapping for a map of PC keys. Currently only used where the keys are either serialised or embedded into a join table.

Specified by:
getKeyMapping in interface MappingManager
Parameters:
container - The container
fmd - MetaData for the field containing the map that this key is for
dba - Database adapter
clr - ClassLoader resolver
Returns:
The Java type mapping

getValueMapping

public JavaTypeMapping getValueMapping(DatastoreContainerObject container,
                                       AbstractPropertyMetaData fmd,
                                       DatastoreAdapter dba,
                                       ClassLoaderResolver clr)
Convenience accessor for the value mapping for a map of PC values. Currently only used where the value are either serialised or embedded into a join table.

Specified by:
getValueMapping in interface MappingManager
Parameters:
container - The container
fmd - MetaData for the field containing the map that this value is for
dba - Database adapter
clr - ClassLoader resolver
Returns:
The Java type mapping

getMapping

public JavaTypeMapping getMapping(DatastoreContainerObject datastoreContainer,
                                  AbstractPropertyMetaData fmd,
                                  DatastoreAdapter dba,
                                  ClassLoaderResolver clr)
Accessor for the mapping for the field of the specified table. Not for use when the field is a collection/map since will not allow for the serialised/embedded flags correctly in those situations.

Specified by:
getMapping in interface MappingManager
Parameters:
datastoreContainer - Table to add the mapping to
fmd - FieldMetaData for the field to map
dba - Datastore adapter
clr - The ClassLoaderResolver
Returns:
The mapping for the field.

getMappingClass

protected java.lang.Class getMappingClass(java.lang.Class c,
                                          boolean serialised,
                                          boolean embedded,
                                          java.lang.String fieldName,
                                          TypeManager typeMgr)
Accessor for the mapping class for the specified class. Provides special handling for interface types and for classes that are being embedded in a field (detected using the FieldMetaData argument). Refers others to its mapping manager lookup.

Parameters:
c - Class to query
serialised - Whether the field is serialised
embedded - Whether the field is embedded
fieldName - The full field name (for logging only)
typeMgr - the TypeManager
Returns:
The mapping class for the class

getDefaultJavaTypeMapping

protected java.lang.Class getDefaultJavaTypeMapping(TypeManager typeMgr,
                                                    java.lang.String javaTypeName)
Method to return the default java type mapping class for a specified java type name.

Parameters:
javaTypeName - Name of the java type
typeMgr - the TypeManager
Returns:
The mapping class to use (by default)

registerDatastoreMapping

public abstract void registerDatastoreMapping(java.lang.String javaTypeName,
                                              java.lang.Class datastoreMappingType,
                                              java.lang.String jdbcType,
                                              java.lang.String sqlType,
                                              boolean dflt)
Utility to register a datastore mapping for a java type, and the SQL/JDBC types it can be mapped to. This can also be called to change the default setting of a mapping - just supply the same values of java/JDBC/SQL types and a different default value

Specified by:
registerDatastoreMapping in interface MappingManager
Parameters:
javaTypeName - Name of the java type
datastoreMappingType - The datastore mapping
jdbcType - The JDBC type that can be used
sqlType - The SQL type that can be used
dflt - Whether this type should be used as the default mapping for this Java type


Copyright © -2007 . All Rights Reserved.