public final class DMOIndex
extends java.lang.Object
The location of the DMO index document is read from the P2J directory.
Modifier and Type | Class and Description |
---|---|
private static class |
DMOIndex.DMOMetadata
Metadata about a particular DMO implementation class.
|
private static class |
DMOIndex.MetadataMap
Mapping of DMO metadata objects by both DMO interface and by DMO
implementation class.
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
ATTR_DESC
XML tag name for descending attribute
|
private static java.lang.String |
ATTR_IGNORE_CASE
XML tag name for ignore-case attribute
|
private static java.lang.String |
ATTR_IMPL
XML tag name for impl attribute
|
private static java.lang.String |
ATTR_INTERFACE
XML tag name for interface attribute
|
private static java.lang.String |
ATTR_LOCAL
XML tag name for local attribute
|
private static java.lang.String |
ATTR_NAME
XML tag name for name attribute
|
private static java.lang.String |
ATTR_PACKAGE
XML tag name for package attribute
|
private static java.lang.String |
ATTR_PRIMARY
XML tag name for primary attribute
|
private static java.lang.String |
ATTR_SCHEMA
XML tag name for schema attribute
|
private static java.lang.String |
ATTR_SEQ_CYCLE
XML tag name for cycle attribute of a sequence
|
private static java.lang.String |
ATTR_SEQ_INCREMENT
XML tag name for increment attribute of a sequence
|
private static java.lang.String |
ATTR_SEQ_INITIAL
XML tag name for initial attribute of a sequence
|
private static java.lang.String |
ATTR_SEQ_LEGACY_NAME
XML tag name for legacy name attribute of a sequence.
|
private static java.lang.String |
ATTR_SEQ_MAX
XML tag name for max-value attribute of a sequence
|
private static java.lang.String |
ATTR_SEQ_MIN
XML tag name for min-value attribute of a sequence
|
private static java.lang.String |
ATTR_SEQ_SQL_NAME
XML tag name for sql-legal name attribute of a sequence.
|
private static java.lang.String |
ATTR_UNIQUE
XML tag name for unique attribute
|
private static java.lang.String |
ATTR_WORD
XML tag name for word attribute
|
private static java.lang.String |
basePackage
Base package name
|
private static java.util.Map<java.lang.String,DMOIndex.MetadataMap> |
cache
Cached map of schema name to map of DMO metadata objects
|
private static ContextLocal<DMOIndex.MetadataMap> |
dynamicCache
DMO metadata objects for dynamic tables.
|
private static java.lang.String |
ELEM_CASE_SENSITIVE
XML tag name for case sensitive property element
|
private static java.lang.String |
ELEM_CLASS
XML tag name for class element
|
private static java.lang.String |
ELEM_COLUMN
XML tag name for index component column element
|
private static java.lang.String |
ELEM_COMPONENT
XML tag name for unique constraint component element
|
private static java.lang.String |
ELEM_ENCODED
XML tag name for base-64 encoded property elements
|
private static java.lang.String |
ELEM_FOREIGN
XML tag name for foreign element
|
private static java.lang.String |
ELEM_INDEX
XML tag name for table index element
|
private static java.lang.String |
ELEM_PROPERTY
XML tag name for property element
|
private static java.lang.String |
ELEM_SCHEMA
XML tag name for schema element
|
private static java.lang.String |
ELEM_SEQUENCE
XML tag name for sequence element
|
private static java.lang.String |
ELEM_UNIQUE
XML tag name for unique constraint element
|
private static java.lang.String |
VAL_TRUE
XML attribute value for "true"
|
Modifier | Constructor and Description |
---|---|
private |
DMOIndex()
This class is never instantiated; access is restricted to the static
classes(java.lang.String) method. |
Modifier and Type | Method and Description |
---|---|
static java.util.Iterator<java.lang.Class<?>> |
classes(java.lang.String schema)
Return an iterator on the DMO implementation classes associated with a particular schema.
|
static java.util.Iterator<P2JIndex> |
databaseIndexes(java.lang.String schema,
Database database,
java.lang.Class<?> iface)
Get an iterator on all indexes for the DMO specified by the given
schema and interface.
|
(package private) static void |
deregisterDynamicTable(java.lang.Class dmoIface,
java.lang.Class dmoClass)
Deregister dynamic table represented by the given DMO interface and implementation classes.
|
static java.lang.String |
getBasePackage()
Get the base package name for all DMOs.
|
static java.lang.Class<?> |
getDMOInterface(java.lang.Class<?> dmoClass)
Get the DMO interface associated with the given DMO implementation
class.
|
static java.lang.Class<?> |
getDMOInterface(java.lang.String schema,
java.lang.Class<?> dmoClass)
Get the DMO interface associated with the given DMO implementation
class and schema.
|
(package private) static java.lang.Class<?> |
getImplementingClass(java.lang.String schema,
java.lang.Class<?> iface)
Get the implementation class mapped to the specified interface, within
the specified schema.
|
(package private) static java.util.Map<java.lang.String,P2JIndexComponent> |
getIndexedCharacterColumns(java.lang.String schema,
Database database,
java.lang.Class<?> iface)
For the given schema and DMO interface, get the map of indexed
character column names to
P2JIndexComponent instances
which describe their use in individual indexes. |
(package private) static java.util.Map<java.lang.String,P2JIndexComponent> |
getIndexedCharacterColumns(java.lang.String schema,
Database database,
java.lang.String table)
For the given schema and DMO interface, get the map of indexed
character column names to
P2JIndexComponent instances
which describe their use in individual indexes. |
private static java.util.Map<java.lang.String,DMOIndex.MetadataMap> |
getMap()
Gets a map of fully qualified class names for each database schema
supported by the application.
|
private static DMOIndex.DMOMetadata |
getMetadata(java.lang.Class<?> dmoClass)
Retrieve a DMO metadata object for the given DMO implementation class.
|
private static DMOIndex.DMOMetadata |
getMetadata(java.lang.String schema,
java.lang.Class<?> iface)
Retrieve a DMO metadata object for the given schema and DMO interface.
|
(package private) static RelationInfo |
getRelation(java.lang.String schema,
java.lang.Class<?> localIface,
java.lang.Class<?> foreignIface)
Retrieve an object which describes the foreign relation between two
tables.
|
static java.util.Iterator<java.util.LinkedHashSet<java.lang.String>> |
indexProperties(java.lang.String schema,
Database database,
java.lang.Class<?> iface)
Get an iterator on all lists of property names in indexes for the given
DMO.
|
(package private) static java.util.Iterator<RelationInfo> |
inverseRelations(java.lang.String schema,
java.lang.Class<?> iface)
Get an iterator on all inverse foreign relation descriptors for the DMO
specified by the given schema and interface.
|
(package private) static boolean |
isCaseSensitive(java.lang.String schema,
java.lang.Class<?> iface,
java.lang.String property)
Determine whether the property defined by the given parameters handles
its data in a case-sensitive manner.
|
(package private) static boolean |
isEncoded(java.lang.String schema,
java.lang.Class<?> iface,
java.lang.String property)
Determine whether the property defined by the given parameters is
base-64 encoded.
|
private static org.w3c.dom.Document |
parseXML()
Parse the XML file and return it as a
Document . |
private static void |
populateMetadata(DMOIndex.DMOMetadata meta,
java.util.Map<java.lang.String,org.w3c.dom.Element> schemaNodeMap,
org.w3c.dom.Element classElem,
java.lang.String basePackage,
java.lang.String baseIface,
boolean tempSchema)
Populate a
DMOMetadata with the information extracted from
the specified XML element. |
(package private) 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).
|
(package private) static void |
registerDynamicTable(java.lang.Class dmoIface,
java.lang.Class dmoClass,
java.util.Collection<P2JIndex> indexes)
Register dynamic table represented by the given DMO interface and implementation classes.
|
(package private) static java.util.Iterator<RelationInfo> |
relations(java.lang.String schema,
java.lang.Class<?> iface)
Get an iterator on all foreign relation descriptors for the DMO
specified by the given schema and interface.
|
private static void |
secondPassUpdateMap(java.lang.String schema)
Second pass metadata map update to map inverse metadata relations.
|
private static void |
thirdPassUpdateMap(java.lang.String schema)
Third pass metadata map update to make metadata immutable.
|
(package private) static java.util.Iterator<java.util.Set<java.lang.String>> |
uniqueConstraints(java.lang.Class<?> dmoClass)
Get an iterator on all unique constraints for the DMO specified by the
given DMO implementation class.
|
(package private) static java.util.Iterator<java.util.Set<java.lang.String>> |
uniqueConstraints(java.lang.String schema,
java.lang.Class<?> iface)
Get an iterator on all unique constraints for the DMO specified by the
given schema and interface.
|
private static void |
updateMap(java.lang.String packageName,
java.lang.String schema,
java.util.Map<java.lang.String,org.w3c.dom.Element> schemaNodeMap)
Adds a list of fully qualified DMO class names to the specified map,
where the map entry's key is the schema name which contains those
classes.
|
private static final java.lang.String ELEM_SCHEMA
private static final java.lang.String ELEM_SEQUENCE
private static final java.lang.String ATTR_SEQ_SQL_NAME
private static final java.lang.String ATTR_SEQ_LEGACY_NAME
private static final java.lang.String ATTR_SEQ_MIN
private static final java.lang.String ATTR_SEQ_MAX
private static final java.lang.String ATTR_SEQ_INITIAL
private static final java.lang.String ATTR_SEQ_INCREMENT
private static final java.lang.String ATTR_SEQ_CYCLE
private static final java.lang.String ELEM_CLASS
private static final java.lang.String ELEM_CASE_SENSITIVE
private static final java.lang.String ELEM_ENCODED
private static final java.lang.String ELEM_UNIQUE
private static final java.lang.String ELEM_INDEX
private static final java.lang.String ELEM_COMPONENT
private static final java.lang.String ELEM_COLUMN
private static final java.lang.String ELEM_FOREIGN
private static final java.lang.String ELEM_PROPERTY
private static final java.lang.String ATTR_PACKAGE
private static final java.lang.String ATTR_NAME
private static final java.lang.String ATTR_INTERFACE
private static final java.lang.String ATTR_IMPL
private static final java.lang.String ATTR_UNIQUE
private static final java.lang.String ATTR_PRIMARY
private static final java.lang.String ATTR_WORD
private static final java.lang.String ATTR_DESC
private static final java.lang.String ATTR_IGNORE_CASE
private static final java.lang.String ATTR_LOCAL
private static final java.lang.String ATTR_SCHEMA
private static final java.lang.String VAL_TRUE
private static java.util.Map<java.lang.String,DMOIndex.MetadataMap> cache
private static java.lang.String basePackage
private static ContextLocal<DMOIndex.MetadataMap> dynamicCache
private DMOIndex()
classes(java.lang.String)
method.public static java.lang.String getBasePackage()
public static java.lang.Class<?> getDMOInterface(java.lang.Class<?> dmoClass)
dmoClass
- DMO implementation class.java.lang.IllegalArgumentException
- if neither the given class nor any of its superclasses is
recognized as a DMO implementation class.java.lang.IllegalStateException
- if P2J_HOME is not defined; if there is any error parsing
the DMO index document.public static java.lang.Class<?> getDMOInterface(java.lang.String schema, java.lang.Class<?> dmoClass)
schema
- Database schema.dmoClass
- DMO implementation class.java.lang.IllegalArgumentException
- if neither the given class nor any of its superclasses is
recognized as a DMO implementation class.java.lang.IllegalStateException
- if P2J_HOME is not defined; if there is any error parsing
the DMO index document.public static java.util.Iterator<P2JIndex> databaseIndexes(java.lang.String schema, Database database, java.lang.Class<?> iface) throws PersistenceException
P2JIndex
objects, each of which defines the columns
participating in an index.schema
- Name of database schema.database
- Database containing the indices being queried.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.PersistenceException
- if there is an error querying index information from the JDBC
driver.public static java.util.Iterator<java.util.LinkedHashSet<java.lang.String>> indexProperties(java.lang.String schema, Database database, java.lang.Class<?> iface) throws PersistenceException
The sets iterated by the returned iterator will themselves iterate the property names in the order in which they participate in the indexes.
schema
- Name of database schema.database
- Database containing the indices being queried.iface
- DMO interface.PersistenceException
- if there is an error querying index information from the JDBC
driver.public static java.util.Iterator<java.lang.Class<?>> classes(java.lang.String schema)
schema
- Schema for which a class list is required.null
if no mapping is found for the
specified schema.java.lang.IllegalStateException
- if P2J_HOME is not defined; if there is any error parsing the DMO index document.static java.lang.Class<?> getImplementingClass(java.lang.String schema, java.lang.Class<?> iface)
schema
- Schema name which identifies the desired mapping of interface
name to DMO metadata.iface
- Interface for which an implementing class name is being looked
up.iface
, or
null
if no such mapping is found.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.static boolean isCaseSensitive(java.lang.String schema, java.lang.Class<?> iface, java.lang.String property)
schema
- Name of database schema.iface
- DMO interface.property
- Name of property.true
if the property is case-sensitive; else
false
.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.static boolean isEncoded(java.lang.String schema, java.lang.Class<?> iface, java.lang.String property)
schema
- Name of database schema.iface
- DMO interface.property
- Name of property.true
if the property is encoded; else
false
.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.static java.util.Iterator<java.util.Set<java.lang.String>> uniqueConstraints(java.lang.String schema, java.lang.Class<?> iface)
schema
- Name of database schema.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.static java.util.Iterator<java.util.Set<java.lang.String>> uniqueConstraints(java.lang.Class<?> dmoClass)
dmoClass
- DMO implementation class.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.static java.util.Iterator<RelationInfo> relations(java.lang.String schema, java.lang.Class<?> iface)
RelationInfo
instances, each of which describes a
foreign key relation from the specified DMO to another.schema
- Name of database schema.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.static java.util.Iterator<RelationInfo> inverseRelations(java.lang.String schema, java.lang.Class<?> iface)
RelationInfo
instances, each of which describes a
foreign key relation to the specified DMO from another.schema
- Name of database schema.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.static RelationInfo getRelation(java.lang.String schema, java.lang.Class<?> localIface, java.lang.Class<?> foreignIface)
schema
- Name of database schema.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.static java.util.Map<java.lang.String,P2JIndexComponent> getIndexedCharacterColumns(java.lang.String schema, Database database, java.lang.Class<?> iface) throws PersistenceException
P2JIndexComponent
instances
which describe their use in individual indexes.schema
- Name of database schema.database
- Database information object.iface
- DMO interface.PersistenceException
- if there is an error querying index information from the JDBC
driver.static java.util.Map<java.lang.String,P2JIndexComponent> getIndexedCharacterColumns(java.lang.String schema, 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
Persistence.queryIndexData(Database, String)
call.
schema
- Name of database schema.database
- Database information object.table
- backing table name.PersistenceException
- if there is an error querying index information from the JDBC
driver.static void registerDynamicTable(java.lang.Class dmoIface, java.lang.Class dmoClass, java.util.Collection<P2JIndex> indexes)
dmoIface
- DMO interface class.dmoClass
- DMO implementation class.indexes
- Collection of database indexes (with Hibernate fields and indexes names).static void deregisterDynamicTable(java.lang.Class dmoIface, java.lang.Class dmoClass)
dmoIface
- DMO interface class.dmoClass
- DMO implementation class.static void putDynamicRelation(RelationInfo info)
info
- Relation descriptor.private static DMOIndex.DMOMetadata getMetadata(java.lang.String schema, java.lang.Class<?> iface)
schema
- Name of database schema.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.private static DMOIndex.DMOMetadata getMetadata(java.lang.Class<?> dmoClass)
dmoClass
- DMO implementation class.java.lang.IllegalArgumentException
- if dmoClass
cannot be resolved to a particular
schema or DMO interface.java.lang.IllegalStateException
- if P2J_HOME is not defined; if there is any error parsing
the DMO index document.private static java.util.Map<java.lang.String,DMOIndex.MetadataMap> getMap()
This map is initially created by parsing the DMO index XML file. It is cached for faster access on subsequent requests.
java.lang.IllegalStateException
- if P2J_HOME is not defined or if there is any error parsing
the DMO index document.private static void updateMap(java.lang.String packageName, java.lang.String schema, java.util.Map<java.lang.String,org.w3c.dom.Element> schemaNodeMap)
packageName
- Package name in which database-specific DMO classes are
located.schema
- Name of schema whose metadata is to be updated.schemaNodeMap
- Map of schema elements by name.java.lang.IllegalArgumentException
- if a class name specified in the DMO index file cannot be
found.private static void secondPassUpdateMap(java.lang.String schema)
schema
- Name of schema whose metadata is to be updated.private static void thirdPassUpdateMap(java.lang.String schema)
schema
- Name of schema whose metadata is to be updated.private static void populateMetadata(DMOIndex.DMOMetadata meta, java.util.Map<java.lang.String,org.w3c.dom.Element> schemaNodeMap, org.w3c.dom.Element classElem, java.lang.String basePackage, java.lang.String baseIface, boolean tempSchema) throws java.lang.ClassNotFoundException, java.lang.NoSuchFieldException, PersistenceException
DMOMetadata
with the information extracted from
the specified XML element.meta
- Metadata object to populate.schemaNodeMap
- Map of schema elements by name.classElem
- An XML element which represents a class
node
in the XML document.basePackage
- Qualified base name of DMO package.baseIface
- Qualified base name of DMO interface.tempSchema
- flag indicating if we are processing DMOs for the temporary
schema.java.lang.ClassNotFoundException
- if a local or foreign DMO interface or class cannot be found.java.lang.NoSuchFieldException
- if an error occurs setting up RelationInfo data.PersistenceException
- if any indexes are defined for a permanent DMO.private static org.w3c.dom.Document parseXML() throws MissingDataException, PersistenceException
Document
. The
location of the file (relative to the JVM's classpath) is read from the
P2J directory, as this will differ among installations.MissingDataException
- if the location of the file cannot be found in the P2J
directory, or if the DMO index file is not found at the
location specified in the directory.PersistenceException
- if the XML parser has been configured incorrectly;
if an I/O error occurs during parsing or stream cleanup;
if an error occurs parsing the XML file.java.lang.RuntimeException
- if the directory service cannot be bound.