org.eigenbase.jmi.mem
Class JmiMemFactory

java.lang.Object
  extended by org.eigenbase.jmi.mem.JmiMemFactory
Direct Known Subclasses:
JmiModeledMemFactory, MockMetadataFactory

public abstract class JmiMemFactory
extends Object

JmiMemFactory creates objects for use in an in-memory repository implementation.

Version:
$Id: //open/dev/farrago/src/org/eigenbase/jmi/mem/JmiMemFactory.java#26 $
Author:
Julian Hyde, John V. Sichi

Nested Class Summary
(package private) static interface JmiMemFactory.Element
          Implemented by proxy objects, this interface makes the proxy handler object accessible.
protected  class JmiMemFactory.ElementImpl
          Implementation of a RefBaseObject via an InvocationHandler interface.
private static class JmiMemFactory.ManyList
          List which holds instances of a bi-directional relationship.
private static class JmiMemFactory.MethodId
          Enumeration of common method names to be handled by the proxy.
protected  class JmiMemFactory.MofPackageImpl
           
private static class JmiMemFactory.OneWayList
          List which holds instances of a many-to-one relationship.
protected  class JmiMemFactory.RefAssociationImpl
          Specialized handler for implementing a RefAssociation via a dynamic proxy.
protected  class JmiMemFactory.RefClassImpl
          Specialized handler for implementing a RefClass via a dynamic proxy.
protected  class JmiMemFactory.RefPackageImpl
          Specialized handler for implementing a RefPackage via a dynamic proxy.
(package private) static class JmiMemFactory.Relationship
          Definition of a relationship.
 
Field Summary
private  Map<Class,RefClass> classMap
           
private static Double DoubleZero
           
private static Float FloatZero
           
private  HashMap<Class<? extends RefBaseObject>,RefObject> metaMap
           
private static Map<String,JmiMemFactory.MethodId> methodMap
           
private  AtomicLong nextId
           
private  Map<RefObject,RefPackage> pluginPackageMap
           
private  Map<String,JmiMemFactory.Relationship> relationshipMap
           
private  JmiMemFactory.RefPackageImpl rootPackageImpl
           
 
Constructor Summary
JmiMemFactory()
           
 
Method Summary
protected  JmiMemFactory.ElementImpl createImpl(Class<? extends RefBaseObject> clazz, JmiMemFactory.RefPackageImpl immediatePkg, boolean preemptive)
          Creates the right kind of implementation class to implement the given interface.
 void createRelationship(Class<? extends RefBaseObject> fromClass, String fromName, boolean fromMany, Class<? extends RefBaseObject> toClass, String toName, boolean toMany, boolean composite)
          Creates a relationship definition
 void createRelationship(Class<? extends RefObject> fromClass, String fromName, boolean fromMany, Class<? extends RefObject> toClass, String toName, boolean toMany)
          Creates a relationship definition
 void defineMetaObject(Class<? extends RefBaseObject> iface, RefObject metaObject)
          Defines a meta-object.
protected  JmiModelGraph getModelGraph()
           
 String getPersistentMofId(RefBaseObject obj)
          Gets the MOFID of a persistent object associated with an in-memory object.
 RefPackage getRootPackage()
           
protected  JmiMemFactory.RefPackageImpl getRootPackageImpl()
           
private  JmiMemFactory.Relationship lookupRelationship(Class<? extends RefBaseObject> fromClass, String fromName)
          Looks up a relationship.
protected  void mapMofId(RefBaseObject refObj, String mofId)
          Notifies subclasses that a new object has been created with the given MOFID.
<T extends RefPackage>
T
newRefPackage(Class<T> ifacePackage)
          Creates a new package explicitly (rather than reflectively), locating it as a child of the root package.
protected abstract  JmiMemFactory.RefPackageImpl newRootPackage()
           
protected  String parseGetter(String methodName)
           
 void setPersistentMofId(RefBaseObject obj, String persistentMofId)
          Associates the MOFID of a persistent object with an in-memory object.
protected static Method[] sortMethods(Method[] methods)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FloatZero

private static final Float FloatZero

DoubleZero

private static final Double DoubleZero

methodMap

private static final Map<String,JmiMemFactory.MethodId> methodMap

nextId

private final AtomicLong nextId

rootPackageImpl

private final JmiMemFactory.RefPackageImpl rootPackageImpl

relationshipMap

private final Map<String,JmiMemFactory.Relationship> relationshipMap

metaMap

private final HashMap<Class<? extends RefBaseObject>,RefObject> metaMap

pluginPackageMap

private final Map<RefObject,RefPackage> pluginPackageMap

classMap

private final Map<Class,RefClass> classMap
Constructor Detail

JmiMemFactory

public JmiMemFactory()
Method Detail

getRootPackage

public RefPackage getRootPackage()

setPersistentMofId

public void setPersistentMofId(RefBaseObject obj,
                               String persistentMofId)
Associates the MOFID of a persistent object with an in-memory object. This is useful when the in-memory object is being manipulated as a shadow of the persistent object.

Parameters:
obj - in-memory object
persistentMofId - MOFID of persistent object to set

getPersistentMofId

public String getPersistentMofId(RefBaseObject obj)
Gets the MOFID of a persistent object associated with an in-memory object.

Parameters:
obj - in-memory object
Returns:
MOFID of persistent object, or null if none set

newRefPackage

public <T extends RefPackage> T newRefPackage(Class<T> ifacePackage)
Creates a new package explicitly (rather than reflectively), locating it as a child of the root package. This is required for plugin sub-packages, which don't have corresponding accessor methods on the root package.

Parameters:
ifacePackage - interface corresponding to RefPackage
Returns:
new RefPackage

mapMofId

protected void mapMofId(RefBaseObject refObj,
                        String mofId)
Notifies subclasses that a new object has been created with the given MOFID.

Parameters:
refObj - new object
mofId - MOFID assigned

newRootPackage

protected abstract JmiMemFactory.RefPackageImpl newRootPackage()

getRootPackageImpl

protected JmiMemFactory.RefPackageImpl getRootPackageImpl()

createImpl

protected JmiMemFactory.ElementImpl createImpl(Class<? extends RefBaseObject> clazz,
                                               JmiMemFactory.RefPackageImpl immediatePkg,
                                               boolean preemptive)
Creates the right kind of implementation class to implement the given interface.


sortMethods

protected static Method[] sortMethods(Method[] methods)

lookupRelationship

private JmiMemFactory.Relationship lookupRelationship(Class<? extends RefBaseObject> fromClass,
                                                      String fromName)
Looks up a relationship.

Parameters:
fromClass - Name class the relationship is from
fromName - Name of the relationship
Returns:
Name of backward relationship, or null if not found

createRelationship

public void createRelationship(Class<? extends RefObject> fromClass,
                               String fromName,
                               boolean fromMany,
                               Class<? extends RefObject> toClass,
                               String toName,
                               boolean toMany)
Creates a relationship definition


defineMetaObject

public void defineMetaObject(Class<? extends RefBaseObject> iface,
                             RefObject metaObject)
Defines a meta-object.

Parameters:
iface - Java interface to associate with meta-object
metaObject - meta-object to return for RefBaseObject.refMetaObject() from instances of iface

createRelationship

public void createRelationship(Class<? extends RefBaseObject> fromClass,
                               String fromName,
                               boolean fromMany,
                               Class<? extends RefBaseObject> toClass,
                               String toName,
                               boolean toMany,
                               boolean composite)
Creates a relationship definition


parseGetter

protected String parseGetter(String methodName)

getModelGraph

protected JmiModelGraph getModelGraph()