com.googlecode.objectify.impl
Class Registrar

java.lang.Object
  extended by com.googlecode.objectify.impl.Registrar

public class Registrar
extends java.lang.Object

Maintains information about registered entity classes

There logic here is convoluted by polymorphic hierarchies. Entity classes can be registered in any particular order, requiring some considerable care.

Author:
Jeff Schnitzer

Field Summary
protected  java.util.Map<java.lang.Class<?>,EntityMetadata<?>> byClass
          This maps class to EntityMetadata for all registered classes
protected  java.util.Map<java.lang.String,EntityMetadata<?>> byKind
          This maps kind to EntityMetadata
protected  boolean cacheEnabled
          True if any @Cached entities have been registered
protected  ObjectifyFactory fact
          Needed to obtain the converters
 
Constructor Summary
Registrar(ObjectifyFactory fact)
           
 
Method Summary
<T> EntityMetadata<T>
getMetadata(java.lang.Class<T> clazz)
           
<T> EntityMetadata<T>
getMetadata(java.lang.String kind)
           
 boolean isCacheEnabled()
           
<T> void
register(java.lang.Class<T> clazz)
          All POJO entity classes which are to be managed by Objectify must be registered first.
protected
<T> PolymorphicEntityMetadata<? super T>
registerPolymorphicHierarchy(java.lang.String kind, java.lang.Class<T> clazz)
          Recursively register classes in the hierarchy which have @Subclass or @Entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fact

protected ObjectifyFactory fact
Needed to obtain the converters


byKind

protected java.util.Map<java.lang.String,EntityMetadata<?>> byKind
This maps kind to EntityMetadata


byClass

protected java.util.Map<java.lang.Class<?>,EntityMetadata<?>> byClass
This maps class to EntityMetadata for all registered classes


cacheEnabled

protected boolean cacheEnabled
True if any @Cached entities have been registered

Constructor Detail

Registrar

public Registrar(ObjectifyFactory fact)
Parameters:
fact - is so that the conversions can be obtained
Method Detail

isCacheEnabled

public boolean isCacheEnabled()
Returns:
true if any entities are cacheable

register

public <T> void register(java.lang.Class<T> clazz)

All POJO entity classes which are to be managed by Objectify must be registered first. This method must be called in a single-threaded mode sometime around application initialization.


registerPolymorphicHierarchy

protected <T> PolymorphicEntityMetadata<? super T> registerPolymorphicHierarchy(java.lang.String kind,
                                                                                java.lang.Class<T> clazz)
Recursively register classes in the hierarchy which have @Subclass or @Entity. Stops when arriving at the first @Entity. Safely handles classes that have already been registered, including @Entity classes that were registered as non-polymorphic.

Returns:
the PolymorphicEntityMetadata associated with the kind.

getMetadata

public <T> EntityMetadata<T> getMetadata(java.lang.String kind)
Returns:
the metadata for the specified kind, or null if there was nothing appropriate registered

getMetadata

public <T> EntityMetadata<T> getMetadata(java.lang.Class<T> clazz)
Returns:
the metadata for the specified class, or null if there was nothing appropriate registered


Copyright © 2011 Jeff Schnitzer and a gang of pirates. All Rights Reserved. Build version: 3.1