|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cayenne.map.EntityResolver
public class EntityResolver
Represents a virtual shared namespace for zero or more DataMaps. Unlike DataMap, EntityResolver is intended to work as a runtime container of mapping. DataMaps can be added or removed dynamically at runtime.
EntityResolver is thread-safe.
Field Summary | |
---|---|
protected LifecycleCallbackRegistry |
callbackRegistry
|
protected ClassDescriptorMap |
classDescriptorMap
|
protected EntityResolver |
clientEntityResolver
|
protected java.util.Map<java.lang.String,DbEntity> |
dbEntityCache
|
protected java.util.Map<java.lang.String,Embeddable> |
embeddableCache
|
protected java.util.Map<java.lang.String,EntityInheritanceTree> |
entityInheritanceCache
|
protected EntityListenerFactory |
entityListenerFactory
|
protected boolean |
indexedByClass
|
protected static org.apache.commons.logging.Log |
logger
|
protected java.util.Collection<DataMap> |
maps
|
protected java.util.Map<java.lang.String,ObjEntity> |
objEntityCache
|
protected java.util.Map<java.lang.String,Procedure> |
procedureCache
|
protected java.util.Map<java.lang.String,Query> |
queryCache
|
protected java.util.Map<java.lang.String,SQLResult> |
resultsCache
|
Constructor Summary | |
---|---|
EntityResolver()
Creates new EntityResolver. |
|
EntityResolver(java.util.Collection<DataMap> dataMaps)
Creates new EntityResolver that indexes a collection of DataMaps. |
Method Summary | |
---|---|
protected DbEntity |
_lookupDbEntity(java.lang.Object object)
Internal usage only - provides the type-unsafe implementation which services the four typesafe public lookupDbEntity methods Looks in the DataMap's that this object was created with for the ObjEntity that maps to the specified object. |
protected ObjEntity |
_lookupObjEntity(java.lang.String key)
Internal usage only - provides the type-unsafe implementation which services the three typesafe public lookupObjEntity methods Looks in the DataMap's that this object was created with for the ObjEntity that maps to the specified object. |
void |
addDataMap(DataMap map)
|
void |
applyDBLayerDefaults()
Updates missing mapping artifacts that can be guessed from other mapping information. |
void |
applyObjectLayerDefaults()
Updates missing mapping artifacts that can be guessed from other mapping information. |
protected java.lang.String |
classKey(java.lang.String className)
Generates a map key for the object class. |
void |
clearCache()
Removes all entity mappings from the cache. |
protected void |
constructCache()
Creates caches of DbEntities by ObjEntity, DataObject class, and ObjEntity name using internal list of maps. |
LifecycleCallbackRegistry |
getCallbackRegistry()
Returns a LifecycleCallbackRegistry for handling callbacks. |
ClassDescriptor |
getClassDescriptor(java.lang.String entityName)
Returns ClassDescriptor for the ObjEntity matching the name. |
ClassDescriptorMap |
getClassDescriptorMap()
Returns an object that compiles and stores ClassDescriptor instances for
all entities. |
EntityResolver |
getClientEntityResolver()
Returns ClientEntityResolver with mapping information that only includes entities available on CWS Client Tier. |
DataMap |
getDataMap(java.lang.String mapName)
Returns a DataMap matching the name. |
java.util.Collection<DataMap> |
getDataMaps()
Returns an unmodifiable collection of DataMaps. |
java.util.Collection<DbEntity> |
getDbEntities()
Returns all DbEntities. |
DbEntity |
getDbEntity(java.lang.String name)
Returns DbEntity for a given name, or null if no such DbEntity is found in the MappingNamespace. |
Embeddable |
getEmbeddable(java.lang.String className)
Returns an Embeddable matching class name or null if such Embeddable is not
mapped. |
java.util.Collection<Embeddable> |
getEmbeddables()
|
java.util.Collection<ObjEntity> |
getObjEntities()
Returns all ObjEntities in the namespace. |
ObjEntity |
getObjEntity(java.lang.String name)
Returns ObjEntity for a given name, or null if no such ObjEntity is found in the MappingNamespace. |
Procedure |
getProcedure(java.lang.String name)
Returns Procedure for a given name, or null if no such Procedure is found in the MappingNamespace. |
java.util.Collection<Procedure> |
getProcedures()
Returns all Procedures in the namespace. |
java.util.Collection<Query> |
getQueries()
Returns all Queries in the namespace. |
Query |
getQuery(java.lang.String name)
Returns Query for a given name, or null if no such Query is found in the MappingNamespace. |
SQLResult |
getResult(java.lang.String name)
Returns a named result set mapping. |
java.util.Collection<SQLResult> |
getResultSets()
|
boolean |
isIndexedByClass()
|
EntityInheritanceTree |
lookupInheritanceTree(ObjEntity entity)
Deprecated. since 3.1 use lookupInheritanceTree(String) . |
EntityInheritanceTree |
lookupInheritanceTree(java.lang.String entityName)
Returns EntityInheritanceTree representing inheritance hierarchy that starts with a given ObjEntity as root, and includes all its subentities. |
ObjEntity |
lookupObjEntity(java.lang.Class<?> aClass)
Looks in the DataMap's that this object was created with for the ObjEntity that maps to the services the specified class |
ObjEntity |
lookupObjEntity(java.lang.Object object)
Looks in the DataMap's that this object was created with for the ObjEntity that services the specified data Object |
Procedure |
lookupProcedure(Query q)
|
Procedure |
lookupProcedure(java.lang.String procedureName)
|
Query |
lookupQuery(java.lang.String name)
Returns a named query or null if no query exists for a given name. |
void |
removeDataMap(DataMap map)
|
void |
setCallbackRegistry(LifecycleCallbackRegistry callbackRegistry)
Sets a lifecycle callbacks registry of the EntityResolver. |
void |
setDataMaps(java.util.Collection<DataMap> maps)
|
void |
setEntityListenerFactory(EntityListenerFactory entityListenerFactory)
Sets an optional EntityListenerFactory that should be used to create entity
listeners. |
void |
setIndexedByClass(boolean b)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.apache.commons.logging.Log logger
protected boolean indexedByClass
protected java.util.Collection<DataMap> maps
protected transient java.util.Map<java.lang.String,Query> queryCache
protected transient java.util.Map<java.lang.String,Embeddable> embeddableCache
protected transient java.util.Map<java.lang.String,SQLResult> resultsCache
protected transient java.util.Map<java.lang.String,DbEntity> dbEntityCache
protected transient java.util.Map<java.lang.String,ObjEntity> objEntityCache
protected transient java.util.Map<java.lang.String,Procedure> procedureCache
protected transient java.util.Map<java.lang.String,EntityInheritanceTree> entityInheritanceCache
protected EntityResolver clientEntityResolver
protected transient ClassDescriptorMap classDescriptorMap
protected transient LifecycleCallbackRegistry callbackRegistry
protected EntityListenerFactory entityListenerFactory
Constructor Detail |
---|
public EntityResolver()
public EntityResolver(java.util.Collection<DataMap> dataMaps)
Method Detail |
---|
public void applyDBLayerDefaults()
public void applyObjectLayerDefaults()
public LifecycleCallbackRegistry getCallbackRegistry()
LifecycleCallbackRegistry
for handling callbacks. Registry is
lazily initialized on first call.
public void setCallbackRegistry(LifecycleCallbackRegistry callbackRegistry)
public EntityResolver getClientEntityResolver()
public java.util.Collection<DbEntity> getDbEntities()
getDbEntities
in interface MappingNamespace
public java.util.Collection<ObjEntity> getObjEntities()
MappingNamespace
getObjEntities
in interface MappingNamespace
public java.util.Collection<Embeddable> getEmbeddables()
public java.util.Collection<SQLResult> getResultSets()
public java.util.Collection<Procedure> getProcedures()
MappingNamespace
getProcedures
in interface MappingNamespace
public java.util.Collection<Query> getQueries()
MappingNamespace
getQueries
in interface MappingNamespace
public DbEntity getDbEntity(java.lang.String name)
MappingNamespace
getDbEntity
in interface MappingNamespace
public ObjEntity getObjEntity(java.lang.String name)
MappingNamespace
getObjEntity
in interface MappingNamespace
public Procedure getProcedure(java.lang.String name)
MappingNamespace
getProcedure
in interface MappingNamespace
public Query getQuery(java.lang.String name)
MappingNamespace
getQuery
in interface MappingNamespace
public Embeddable getEmbeddable(java.lang.String className)
MappingNamespace
Embeddable
matching class name or null if such Embeddable is not
mapped.
getEmbeddable
in interface MappingNamespace
public SQLResult getResult(java.lang.String name)
MappingNamespace
getResult
in interface MappingNamespace
public ClassDescriptor getClassDescriptor(java.lang.String entityName)
public void addDataMap(DataMap map)
public void clearCache()
constructCache
, or on demand by calling any of the
lookup...
methods.
protected void constructCache()
public DataMap getDataMap(java.lang.String mapName)
public void setDataMaps(java.util.Collection<DataMap> maps)
public java.util.Collection<DataMap> getDataMaps()
public EntityInheritanceTree lookupInheritanceTree(ObjEntity entity)
lookupInheritanceTree(String)
.
public EntityInheritanceTree lookupInheritanceTree(java.lang.String entityName)
public ObjEntity lookupObjEntity(java.lang.Class<?> aClass)
public ObjEntity lookupObjEntity(java.lang.Object object)
public Procedure lookupProcedure(Query q)
public Procedure lookupProcedure(java.lang.String procedureName)
public Query lookupQuery(java.lang.String name)
public void removeDataMap(DataMap map)
public boolean isIndexedByClass()
public void setIndexedByClass(boolean b)
protected java.lang.String classKey(java.lang.String className)
protected DbEntity _lookupDbEntity(java.lang.Object object)
protected ObjEntity _lookupObjEntity(java.lang.String key)
public ClassDescriptorMap getClassDescriptorMap()
ClassDescriptor
instances for
all entities.
public void setEntityListenerFactory(EntityListenerFactory entityListenerFactory)
EntityListenerFactory
that should be used to create entity
listeners. Note that changing the factory does not affect already created
listeners. So refresh the existing listners, call "setCallbackRegistry(null)" after
setting the listener.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |