public class DmoMetadataManager
extends java.lang.Object
registerDmo(Class). This method will analyze the class and build an internal
data structure that will provide metadata information at request, including:
| Modifier and Type | Field and Description |
|---|---|
private static DmoMeta[] |
byId
The
DmoMeta ordered by their unique ids. |
private static CentralLogger |
LOG
Logger
|
private static java.lang.String |
pkgroot
Cached value of the base package name for all DMOs.
|
private static java.lang.String |
PKGROOT
Relative directory path for application package root
|
private static java.util.IdentityHashMap<java.lang.Class<?>,DmoMeta> |
pojoMap
Holds the mapping from POJO types to their pair DmoMeta structure.
|
private static java.util.Map<java.lang.String,DmoMeta> |
registry
The DMO registry.
|
private static java.util.Map<java.lang.String,java.util.Map<java.lang.String,DmoMeta>> |
simpleRegistry
The short-name registry.
|
| Constructor and Description |
|---|
DmoMetadataManager() |
| Modifier and Type | Method and Description |
|---|---|
static DmoMeta |
byPojoClass(java.lang.Class<?> pojoClass)
Reverse lookup of a specific
DmoMeta by its POJO class type. |
static void |
deregisterDmos(java.lang.String... classNames)
This removes given a set of dynamic DMO from registry.
|
static java.lang.Class<? extends DataModelObject> |
getAnnotatedInterface(java.lang.Class<? extends DataModelObject> dmoIface)
Searches and returns the super-interface
DataModelObject that has the Table annotation. |
static java.lang.String |
getDmoBasePackage()
Get the base package name for all DMOs.
|
static java.lang.Class<? extends DataModelObject> |
getDmoIface(java.lang.Class<?> bufferCls)
Get the DMO interface associated with the given buffer class.
|
static DmoMeta |
getDmoInfo(java.lang.Class<?> dmo)
Searches for a
DmoMeta for a specific alias in the list of all known aliases. |
static DmoMeta |
getDmoInfo(int dmoId)
Obtain the
DmoMeta of a DMO/table based on its unique id. |
static DmoMeta |
getDmoInfo(java.lang.String dmoName)
Searches for a
DmoMeta for a specific alias in the list of all known aliases. |
static DmoMeta |
getDmoInfo(java.lang.String dmoName,
java.lang.String schema)
Searches for a
DmoMeta for a specific alias in the list of all known aliases. |
static java.lang.Class<? extends DataModelObject> |
getDMOInterface(java.lang.Class<? extends Record> dmoClass)
Deprecated.
|
static java.util.Set<java.lang.String> |
getDmoInterfaces(java.lang.String pathPrefix)
Filters and returns a set of interface names from a specified package.
|
static java.util.Map<java.lang.String,P2JIndexComponent> |
getIndexedCharacterColumns(Database database,
java.lang.String table)
Deprecated.
|
static RelationInfo |
getRelation(java.lang.Class<? extends DataModelObject> localIface,
java.lang.Class<? extends DataModelObject> foreignIface)
Deprecated.
|
private static java.lang.String |
getSchema(java.lang.Class<?> aClass)
Extracts the schema from a DMO class name.
|
static java.util.Iterator<RelationInfo> |
inverseRelations(java.lang.Class<? extends DataModelObject> iface)
Deprecated.
|
static boolean |
isLeadingIndexComponent(java.lang.Class<? extends DataModelObject> dmo,
java.lang.String property)
Deprecated.
|
static boolean |
isSchemaMatch(java.lang.Class<? extends DataModelObject> ifc1,
java.lang.Class<? extends DataModelObject> ifc2)
Check if the two DMO interfaces have the same schema.
|
static void |
putDynamicRelation(RelationInfo info)
Add an object which describes a foreign relation from one table to another at server runtime
(as opposed to relations detected at conversion stage).
|
static DmoMeta |
registerDmo(java.lang.Class<? extends DataModelObject> dmoIface)
Gather information for a DMO.
|
static DmoMeta |
registerDmo(java.lang.Class<? extends DataModelObject> dmoIface,
java.util.function.Consumer<DmoClass> assembleCallback)
Gather information for a DMO.
|
static java.util.Iterator<RelationInfo> |
relations(java.lang.Class<? extends DataModelObject> iface)
Deprecated.
use
DmoMeta.relations(). |
private static final java.lang.String PKGROOT
private static final java.util.Map<java.lang.String,DmoMeta> registry
private static final java.util.Map<java.lang.String,java.util.Map<java.lang.String,DmoMeta>> simpleRegistry
private static final java.util.IdentityHashMap<java.lang.Class<?>,DmoMeta> pojoMap
private static DmoMeta[] byId
DmoMeta ordered by their unique ids. Allocate a minimum amount of space sufficient for
basic projects. If there are more DMOs the array will be resized as needed (incrementally, by 150%).private static final CentralLogger LOG
private static java.lang.String pkgroot
public static java.lang.String getDmoBasePackage()
public static java.lang.Class<? extends DataModelObject> getDmoIface(java.lang.Class<?> bufferCls)
bufferCls - The buffer classpublic static boolean isSchemaMatch(java.lang.Class<? extends DataModelObject> ifc1, java.lang.Class<? extends DataModelObject> ifc2)
ifc1 - The first DMO interface.ifc2 - The second DMO interface.true if the signature is the same.public static DmoMeta registerDmo(java.lang.Class<? extends DataModelObject> dmoIface)
aClass and it super interfaces are analyzed
and, if DMO annotation are found, they are stored for later use.dmoIface - The interface to be analyzed.DmoMeta.getAnnotatedInterface().java.lang.NullPointerException - if dmoIface is null.java.lang.IllegalArgumentException - if dmoIface is null or neither dmoIface and none of its super
interfaces are annotated as DMO or @Table annotation is not presentpublic static DmoMeta registerDmo(java.lang.Class<? extends DataModelObject> dmoIface, java.util.function.Consumer<DmoClass> assembleCallback)
aClass and it super interfaces are analyzed
and, if DMO annotation are found, they are stored for later use.dmoIface - The interface to be analyzed.assembleCallback - Callback method to use after assembling implementation.DmoMeta.getAnnotatedInterface().java.lang.NullPointerException - if dmoIface is null.java.lang.IllegalArgumentException - if dmoIface is null or neither dmoIface and none of its super
interfaces are annotated as DMO or @Table annotation is not present@Deprecated public static java.lang.Class<? extends DataModelObject> getDMOInterface(java.lang.Class<? extends Record> dmoClass)
dmoClass - DMO implementation class.java.lang.IllegalArgumentException - if any of its interfaces is recognized as a valid DMO interface.public static void deregisterDmos(java.lang.String... classNames)
classNames - An array of class names to be deregistered.public static DmoMeta byPojoClass(java.lang.Class<?> pojoClass)
DmoMeta by its POJO class type.pojoClass - The POJO type to be used as key. If teh specific POJODmoMeta of the DMO which declared the pojoClass as its POJO type.public static DmoMeta getDmoInfo(java.lang.String dmoName, java.lang.String schema)
DmoMeta for a specific alias in the list of all known aliases.dmoName - The name of the alias to be located. May be a full-path DMO, DMO implementation, or simple
name of DMO, DMO implementation in which case the schema parameter is used for
disambiguate the entity.schema - The schema of the database. This is used to disambiguate short-names entities.DmoMeta structure corresponding to dmoName alias, or
null if information on this alias is not available.public static DmoMeta getDmoInfo(java.lang.Class<?> dmo)
DmoMeta for a specific alias in the list of all known aliases. The
method does the best effort to find the right information, regardless the dmo
parameter is a DMO interface or an DMO implementation class.dmo - The DMO class to be located.DmoMeta structure corresponding to DMO classjava.lang.IllegalArgumentException - if the class passed in is not implementing DMO interface or its interface was not
registered beforehand.public static DmoMeta getDmoInfo(java.lang.String dmoName)
DmoMeta for a specific alias in the list of all known aliases. The
method does the best effort to find the right information, regardless the dmo
parameter is a DMO interface or an DMO implementation class.dmoName - The name of the DMO class to be located.DmoMeta structure corresponding to DMO classjava.lang.IllegalArgumentException - if the class passed in is not implementing DMO interface or its interface was not
registered beforehand.public static DmoMeta getDmoInfo(int dmoId)
DmoMeta of a DMO/table based on its unique id.dmoId - The unique id of the DMO/table.DmoMeta for respective DMO/table, or null if dmoId is invalid.public static java.util.Set<java.lang.String> getDmoInterfaces(java.lang.String pathPrefix)
pathPrefix - All registered DMOs will to be 'scanned' and the interfaces whose full name start with this
prefix will be returned. The search will exclude the class implementations by looking at their
specific suffix.@Deprecated public static java.util.Map<java.lang.String,P2JIndexComponent> getIndexedCharacterColumns(Database database, java.lang.String table) throws PersistenceException
P2JIndexComponent instances which describe their use in individual indexes.
They are read directly from the specified table, using a
IndexMetadataCollector.queryIndexData(Session, String) call.
database - Database information object.table - backing table name.PersistenceException - if there is an error querying index information from the JDBC driver.@Deprecated public static boolean isLeadingIndexComponent(java.lang.Class<? extends DataModelObject> dmo, java.lang.String property)
DmoMeta.isLeadingIndexComponent(String).dmo - The DMO of a table associated with the property.property - DMO property to be tested.true if property is a leading index component; else false.@Deprecated public static java.util.Iterator<RelationInfo> relations(java.lang.Class<? extends DataModelObject> iface)
DmoMeta.relations().RelationInfo instances, each
of which describes a foreign key relation from the specified DMO to another.iface - DMO interface.java.lang.IllegalArgumentException - if either the schema or iface parameters are not recognized.java.lang.IllegalStateException - if P2J_HOME is not defined; if there is any error parsing the DMO index document.@Deprecated public static java.util.Iterator<RelationInfo> inverseRelations(java.lang.Class<? extends DataModelObject> iface)
RelationInfo instances,
each of which describes a foreign key relation to the specified DMO from another.iface - DMO interface.java.lang.IllegalArgumentException - if either the schema or iface parameters are not recognized.java.lang.IllegalStateException - if P2J_HOME is not defined; if there is any error parsing the DMO index document.@Deprecated public static RelationInfo getRelation(java.lang.Class<? extends DataModelObject> localIface, java.lang.Class<? extends DataModelObject> foreignIface)
localIface - DMO interface for the local table.foreignIface - DMO interface for the foreign table.null if no such relation exists.
Note that a null return does not necessarily indicate that the inverse
relation does not exist. This can be determined by invoking this method with the
localIface and foreignIface parameters inverted.public static void putDynamicRelation(RelationInfo info)
info - Relation descriptor.public static java.lang.Class<? extends DataModelObject> getAnnotatedInterface(java.lang.Class<? extends DataModelObject> dmoIface)
DataModelObject that has the Table annotation.dmoIface - The interface to be analysed.DataModelObject that has the Table annotation
or null if no such interface can be found.private static java.lang.String getSchema(java.lang.Class<?> aClass)
aClass - the DMO class or interface.