org.apache.jdo.impl.model.jdo.caching
Class JDOModelImplCaching

java.lang.Object
  extended byorg.apache.jdo.impl.model.jdo.JDOElementImpl
      extended byorg.apache.jdo.impl.model.jdo.JDOModelImplDynamic
          extended byorg.apache.jdo.impl.model.jdo.caching.JDOModelImplCaching
All Implemented Interfaces:
JDOElement, JDOModel

public class JDOModelImplCaching
extends JDOModelImplDynamic

A JDOModel instance bundles a number of JDOClass instances used by an application. It provides factory methods to create and retrieve JDOClass instances. A fully qualified class name must be unique within a JDOModel instance. The model supports multiple classes having the same fully qualified name by different JDOModel instances.

The caching JDOModel implementation caches any caclulated value to avoid re-calculating it if it is requested again. It is intended to be used in an environment where JDO metadata does NOT change (e.g. at runtime).

Since:
1.1
Version:
2.0
Author:
Michael Bouschen

Nested Class Summary
 
Nested classes inherited from class org.apache.jdo.impl.model.jdo.JDOModelImplDynamic
 
Field Summary
private  java.util.Map jdoClassesForObjectIdClasses
          This is a mapping from ObjectId classes to its JDOClass instances.
private  java.util.Map jdoClassesForShortNames
          This is a mapping from short names to JDOClass instances.
private  java.util.Set nonPCClasses
          Set of fully qualified names of classes known to be non persistence-capable.
 
Fields inherited from class org.apache.jdo.impl.model.jdo.JDOModelImplDynamic
logger, msg, xmlLogger
 
Fields inherited from class org.apache.jdo.impl.model.jdo.JDOElementImpl
 
Constructor Summary
protected JDOModelImplCaching(JavaModel javaModel, boolean loadXMLMetadataDefault)
          Constructor.
 
Method Summary
 JDOClass getJDOClassForObjectIdClass(JavaType objectIdClass)
          This method returns the JDOClass instance that defines the specified type as its objectId class.
 JDOClass getJDOClassForShortName(java.lang.String shortName)
          The method returns the JDOClass instance for the specified short name (see JDOClass.getShortName()) or null if it cannot find a JDOClass instance with the specified short name.
protected  boolean isKnownNonPC(java.lang.String typeName)
          Checks whether the type with the specified name does NOT denote a persistence-capable class.
protected  void knownNonPC(java.lang.String className)
          Hook called when a class is known to be non persistence capable.
protected  JDOClass newJDOClassInstance(java.lang.String name)
          Returns a new instance of the JDOClass implementation class.
 
Methods inherited from class org.apache.jdo.impl.model.jdo.JDOModelImplDynamic
createJDOClass, createJDOClass, createJDOPackage, getDeclaredClasses, getDeclaredPackages, getJavaModel, getJDOClass, getJDOClass, getJDOPackage, getParent, setJavaModel
 
Methods inherited from class org.apache.jdo.impl.model.jdo.JDOElementImpl
addPropertyChangeListener, addVetoableChangeListener, createJDOExtension, firePropertyChange, fireVetoableChange, getJDOExtensions, removeJDOExtension, removePropertyChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.jdo.model.jdo.JDOElement
addPropertyChangeListener, addVetoableChangeListener, createJDOExtension, getJDOExtensions, removeJDOExtension, removePropertyChangeListener, removeVetoableChangeListener
 

Field Detail

jdoClassesForShortNames

private java.util.Map jdoClassesForShortNames
This is a mapping from short names to JDOClass instances. Key is the JDOClass short name, value is the corresponding JDOClass instance.


jdoClassesForObjectIdClasses

private java.util.Map jdoClassesForObjectIdClasses
This is a mapping from ObjectId classes to its JDOClass instances. Key is the type representation of the ObjectId class, value is the corresponding JDOClass instance. Note, in the case of inheritance the top most persistence-capable class is stored.


nonPCClasses

private java.util.Set nonPCClasses
Set of fully qualified names of classes known to be non persistence-capable.

Constructor Detail

JDOModelImplCaching

protected JDOModelImplCaching(JavaModel javaModel,
                              boolean loadXMLMetadataDefault)
Constructor. JDOModel instances are created using the JDOModelFactory only.

Method Detail

getJDOClassForShortName

public JDOClass getJDOClassForShortName(java.lang.String shortName)
The method returns the JDOClass instance for the specified short name (see JDOClass.getShortName()) or null if it cannot find a JDOClass instance with the specified short name.

The method searches the list of JDOClasses currently managed by this JDOModel instance. It does not attempt to load any metadata if it cannot find a JDOClass instance with the specified short name. The metadata for a JDOClass returned by this method must have been loaded before by any of the methods JDOModelImplDynamic.createJDOClass(String className), JDOModelImplDynamic.createJDOClass(String className, boolean loadXMLMetadataDefault), JDOModelImplDynamic.getJDOClass(String className), or JDOModelImplDynamic.getJDOClass(String className, boolean loadXMLMetadataDefault).

Specified by:
getJDOClassForShortName in interface JDOModel
Overrides:
getJDOClassForShortName in class JDOModelImplDynamic
Parameters:
shortName - the short name of the JDOClass instance to be returned
Returns:
a JDOClass instance for the specified short name or null if not present

getJDOClassForObjectIdClass

public JDOClass getJDOClassForObjectIdClass(JavaType objectIdClass)
This method returns the JDOClass instance that defines the specified type as its objectId class. In the case of an inheritance hierarchy it returns the top most persistence-capable class of the hierarchy (see JDOClass.getPersistenceCapableSuperclass()).

Specified by:
getJDOClassForObjectIdClass in interface JDOModel
Overrides:
getJDOClassForObjectIdClass in class JDOModelImplDynamic
Parameters:
objectIdClass - the type representation of the ObjectId class
Returns:
the JDOClass defining the specified class as ObjectId class

newJDOClassInstance

protected JDOClass newJDOClassInstance(java.lang.String name)
Returns a new instance of the JDOClass implementation class.

Overrides:
newJDOClassInstance in class JDOModelImplDynamic

isKnownNonPC

protected boolean isKnownNonPC(java.lang.String typeName)
Checks whether the type with the specified name does NOT denote a persistence-capable class.

Overrides:
isKnownNonPC in class JDOModelImplDynamic
Parameters:
typeName - name of the type to be checked
Returns:
true if types is a name of a primitive type; false otherwise

knownNonPC

protected void knownNonPC(java.lang.String className)
Hook called when a class is known to be non persistence capable.

Overrides:
knownNonPC in class JDOModelImplDynamic
Parameters:
className - the name of the non-pc class