org.progeeks.meta
Class MetaClassRegistry

java.lang.Object
  extended by org.progeeks.meta.MetaClassRegistry

public class MetaClassRegistry
extends java.lang.Object

A registry of MetaClasses that can be looked up by name. The MetaClassRegistry acts as sort of a class-loader in meta-space. Each MetaClass knows which class registry it belongs to and can use this information to look up information about related classes.

Version:
$Revision: 1.12 $
Author:
Paul Speed

Field Summary
static int LOOKUP_LOCAL_FIRST
           
static int LOOKUP_LOCAL_ONLY
           
static int LOOKUP_PARENT_FIRST
           
 
Constructor Summary
MetaClassRegistry()
          Creates a new meta-class registry that delegates to the root registry after looking for a class locally.
MetaClassRegistry(int delegationPolicy)
          Creates a new meta-class registry the delegates to the root registry as specified by the delegation policy parameter.
MetaClassRegistry(MetaClassRegistry parentRegistry)
          Creates a new meta-class registry the delegates to the specified parent registry after looking for a class locally.
MetaClassRegistry(MetaClassRegistry parentRegistry, int delegationPolicy)
          Creates a new meta-class registry the delegates to the specified parent registry as specified by the delegation policy parameter.
 
Method Summary
 MetaClass createMetaClass(java.lang.String name, java.util.Collection propertyInfos)
          Creates a meta-class from the specified information.
 MetaClass createMetaClass(java.lang.String name, java.util.Collection propertyInfos, java.util.Collection uniqueProperties, java.util.Collection superclasses)
          Creates a meta-class from the specified information.
 MetaClass createMetaClass(java.lang.String name, java.util.Collection propertyInfos, java.util.List superclasses)
          Creates a meta-class from the specified information.
 MetaClass createMetaClass(java.lang.String name, java.util.Collection propertyInfos, MetaClass superclass)
          Creates a meta-class from the specified information.
 boolean exists(java.lang.String name)
          Returns true if the specified class name has a meta-class associated with it.
static MetaClassRegistry getContextRegistry()
          Returns the current thread's context meta-class registry or the root class registry if one has not been set.
 int getDelegationPolicy()
          Returns the policy used to determine how this class registry interacts with its parent registry.
 MetaClass getMetaClass(java.lang.String name)
          Retrieves the meta-class associated with the specified class name.
 java.util.Collection getMetaClasses()
          Returns a read-only collection containing all of the MetaClasses in this registry.
 MetaClassRegistry getParentRegistry()
          Returns the parent registry to this meta-class registry or null if there is no parent registry.
static MetaClassRegistry getRootRegistry()
          Returns the singleton instance of the root class registry.
protected  boolean isInCache(java.lang.String name)
          Temporary.
protected  void putMetaClass(java.lang.String name, MetaClass mc)
          Temporary.
static void setContextRegistry(MetaClassRegistry registry)
          Sets the current thread's context meta-class registry or the root class registry if one has not been set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOOKUP_PARENT_FIRST

public static final int LOOKUP_PARENT_FIRST
See Also:
Constant Field Values

LOOKUP_LOCAL_FIRST

public static final int LOOKUP_LOCAL_FIRST
See Also:
Constant Field Values

LOOKUP_LOCAL_ONLY

public static final int LOOKUP_LOCAL_ONLY
See Also:
Constant Field Values
Constructor Detail

MetaClassRegistry

public MetaClassRegistry()
Creates a new meta-class registry that delegates to the root registry after looking for a class locally.


MetaClassRegistry

public MetaClassRegistry(int delegationPolicy)
Creates a new meta-class registry the delegates to the root registry as specified by the delegation policy parameter.


MetaClassRegistry

public MetaClassRegistry(MetaClassRegistry parentRegistry)
Creates a new meta-class registry the delegates to the specified parent registry after looking for a class locally.


MetaClassRegistry

public MetaClassRegistry(MetaClassRegistry parentRegistry,
                         int delegationPolicy)
Creates a new meta-class registry the delegates to the specified parent registry as specified by the delegation policy parameter.

Method Detail

getRootRegistry

public static MetaClassRegistry getRootRegistry()
Returns the singleton instance of the root class registry.


getContextRegistry

public static MetaClassRegistry getContextRegistry()
Returns the current thread's context meta-class registry or the root class registry if one has not been set. The context meta-class registry is similar to the standard Java context ClassLoader as implemented in the java.lang.Thread class.


setContextRegistry

public static void setContextRegistry(MetaClassRegistry registry)
Sets the current thread's context meta-class registry or the root class registry if one has not been set. The context meta-class registry is similar to the standard Java context ClassLoader as implemented in the java.lang.Thread class.


getParentRegistry

public MetaClassRegistry getParentRegistry()
Returns the parent registry to this meta-class registry or null if there is no parent registry.


getDelegationPolicy

public int getDelegationPolicy()
Returns the policy used to determine how this class registry interacts with its parent registry.


createMetaClass

public MetaClass createMetaClass(java.lang.String name,
                                 java.util.Collection propertyInfos)
                          throws DuplicateMetaClassException
Creates a meta-class from the specified information. The created class will be added to this registry. This is a factory method that can insulate callers from the specifics of creating a meta-class and makes sure the meta-class is associated with the correct registry.

Parameters:
name - The name of the meta-class to create.
propertyInfos - The PropertyInfo objects describing the properties of the meta-class.
Throws:
DuplicateMetaClassException - if a MetaClass already exists in this registry for the specified name.

createMetaClass

public MetaClass createMetaClass(java.lang.String name,
                                 java.util.Collection propertyInfos,
                                 java.util.Collection uniqueProperties,
                                 java.util.Collection superclasses)
                          throws DuplicateMetaClassException
Creates a meta-class from the specified information. The created class will be added to this registry. This is a factory method that insulates callers from the specifics of creating a meta-class and makes sure the meta-class is associated with the correct registry.

Parameters:
name - The name of the meta-class to create.
propertyInfos - The PropertyInfo objects describing the properties of the meta-class.
superclasses - The meta-classes from which this meta-class is derived. Any properties in the superclasses will be inherited directly unless specifically overridden in the propertyInfos list.
uniqueProperties - The set of properties that define the uniqueness of instances of the created meta-class. This will be used by most implementations for object equivalence checks. The unique properties are combined with those defined in the superclasses.
Throws:
DuplicateMetaClassException - if a MetaClass already exists in this registry for the specified name.

putMetaClass

protected void putMetaClass(java.lang.String name,
                            MetaClass mc)
Temporary. Provided for the experimental subclass that needs to poke in its own meta-class implementations.


isInCache

protected boolean isInCache(java.lang.String name)
Temporary. Returns true if the specified class name is already in cache. See the comments inside createMetaClass() for why this is different than calling exists().


createMetaClass

public MetaClass createMetaClass(java.lang.String name,
                                 java.util.Collection propertyInfos,
                                 java.util.List superclasses)
                          throws DuplicateMetaClassException
Creates a meta-class from the specified information. The created class will be added to this registry, replacing any existing meta-class for the specified name. This is a factory method that can insulate callers from the specifics of creating a meta-class and makes sure the meta-class is associated with the correct registry.

Parameters:
name - The name of the meta-class to create.
propertyInfos - The PropertyInfo objects describing the properties of the meta-class.
superclasses - The meta-classes from which this meta-class is derived. Any properties in the superclasses will be inherited directly unless specifically overridden in the propertyInfos list.
Throws:
DuplicateMetaClassException - if a MetaClass already exists in this registry for the specified name.

createMetaClass

public MetaClass createMetaClass(java.lang.String name,
                                 java.util.Collection propertyInfos,
                                 MetaClass superclass)
Creates a meta-class from the specified information. The created class will be added to this registry, replacing any existing meta-class for the specified name. This is a factory method that can insulate callers from the specifics of creating a meta-class and makes sure the meta-class is associated with the correct registry.

Parameters:
name - The name of the meta-class to create.
propertyInfos - The PropertyInfo objects describing the properties of the meta-class.
superclass - The single meta-class from which this meta-class is derived. Any properties in the superclass will be inherited directly unless specifically overridden in the propertyInfos list.

getMetaClass

public MetaClass getMetaClass(java.lang.String name)
Retrieves the meta-class associated with the specified class name. Once a meta-class has been retrieved through this registry it is permanently cached in this registry to facilitate future duplicate checks.


exists

public boolean exists(java.lang.String name)
Returns true if the specified class name has a meta-class associated with it.


getMetaClasses

public java.util.Collection getMetaClasses()
Returns a read-only collection containing all of the MetaClasses in this registry.



Copyright © 2002-2003 Paul Speed. All Rights Reserved.