org.apache.ojb.broker.metadata
Class DescriptorRepository

java.lang.Object
  extended byorg.apache.ojb.broker.metadata.DescriptorBase
      extended byorg.apache.ojb.broker.metadata.DescriptorRepository
All Implemented Interfaces:
AttributeContainer, IsolationLevels, RepositoryElements, java.io.Serializable, XmlCapable

public final class DescriptorRepository
extends DescriptorBase
implements java.io.Serializable, XmlCapable, IsolationLevels

The repository containing all object mapping and manipulation information of all used persistent objects.
Note: Be careful when use references of this class or caching instances of this class, because instances could become invalid (see MetadataManager).

Version:
$Id: DescriptorRepository.java,v 1.47 2004/02/04 13:48:50 tomdz Exp $
Author:
Thomas Mahler, Leandro Rodrigo Saad Cruz
See Also:
Serialized Form

Field Summary
(package private) static long serialVersionUID
           
 
Fields inherited from interface org.apache.ojb.broker.metadata.RepositoryElements
_NEXT, ACCEPT_LOCKS, ACCESS, ATTRIBUTE, ATTRIBUTE_NAME, ATTRIBUTE_VALUE, AUTO_DELETE, AUTO_INCREMENT, AUTO_RETRIEVE, AUTO_UPDATE, BATCH_MODE, CLASS_DESCRIPTOR, CLASS_EXTENT, CLASS_NAME, CLASS_PROXY, CLASS_REF, COLLECTION_CLASS, COLLECTION_DESCRIPTOR, COLUMN_NAME, CON_LOG_ABANDONED, CON_MAX_ACTIVE, CON_MAX_IDLE, CON_MAX_WAIT, CON_MIN_EVICTABLE_IDLE_TIME_MILLIS, CON_NUM_TESTS_PER_EVICTION_RUN, CON_REMOVE_ABANDONED, CON_REMOVE_ABANDONED_TIMEOUT, CON_TEST_ON_BORROW, CON_TEST_ON_RETURN, CON_TEST_WHILE_IDLE, CON_TIME_BETWEEN_EVICTION_RUNS_MILLIS, CON_WHEN_EXHAUSTED_ACTION, CONNECTION_FACTORY, CONNECTION_POOL, CONSTANT_ARGUMENT, DATASOURCE_NAME, DBMS_NAME, DEFAULT_CONNECTION, DELETE_PROCEDURE, DOCUMENTATION, DRIVER_NAME, EAGER_RELEASE, EXTENDS, FACTORY_CLASS, FACTORY_METHOD, FIELD_CONVERSION, FIELD_DESCRIPTOR, FIELD_ID_REF, FIELD_NAME, FIELD_REF, FK_POINTING_TO_ITEMS_CLASS, FK_POINTING_TO_THIS_CLASS, FOREIGN_KEY, ID, IGNORE_AUTOCOMMIT_EXCEPTION, INCLUDE_ALL_FIELDS, INCLUDE_PK_FIELDS_ONLY, INDEX_COLUMN, INDEX_DESCRIPTOR, INDEXED, INDIRECTION_TABLE, INITIALIZATION_METHOD, INSERT_PROCEDURE, INVERSE_FK, ISOLATION_LEVEL, ITEMS_CLASS, JCD_ALIAS, JDBC_CONNECTION_DESCRIPTOR, JDBC_LEVEL, JDBC_TYPE, LENGTH, LOCKING, MAPPING_REPOSITORY, NAME, NULLABLE, OBJECT_CACHE, ORDERBY, OTM_DEPENDENT, PRECISION, PRIMARY_KEY, PROXY_PREFETCHING_LIMIT, PROXY_REFERENCE, QUERY_CUSTOMIZER, REFERENCE_DESCRIPTOR, REFERENCED_CLASS, REFRESH, REPOSITORY_VERSION, RETURN, RETURN_FIELD_REF, ROW_READER, RUNTIME_ARGUMENT, SCALE, SCHEMA_NAME, SEQUENCE_MANAGER, SEQUENCE_MANAGER_CLASS, SEQUENCE_NAME, SORT, TABLE_NAME, TAG_ACCESS, TAG_ACCESS_ANONYMOUS, TAG_ACCESS_READONLY, TAG_ACCESS_READWRITE, TAG_SUPER, UNIQUE, UPDATE_LOCK, UPDATE_PROCEDURE, URL_DBALIAS, URL_PROTOCOL, URL_SUBPROTOCOL, USE_AUTOCOMMIT, USER_NAME, USER_PASSWD, VALIDATION_QUERY, VALUE
 
Fields inherited from interface org.apache.ojb.broker.metadata.IsolationLevels
IL_DEFAULT, IL_OPTIMISTIC, IL_READ_COMMITTED, IL_READ_UNCOMMITTED, IL_REPEATABLE_READ, IL_SERIALIZABLE, LITERAL_IL_OPTIMISTIC, LITERAL_IL_READ_COMMITTED, LITERAL_IL_READ_UNCOMMITTED, LITERAL_IL_REPEATABLE_READ, LITERAL_IL_SERIALIZABLE
 
Constructor Summary
DescriptorRepository()
          Constructor declaration
 
Method Summary
 void addAttribute(java.lang.String attributeName, java.lang.String attributeValue)
          Store the specified attribute and it's value.
(package private)  void addExtent(java.lang.String classname, ClassDescriptor cld)
          Add a pair of extent/classdescriptor to the extentTable to gain speed while retrieval of extents.
protected  ClassDescriptor discoverDescriptor(java.lang.String className)
          Starts by looking to see if the className is already mapped specifically to the descritpor repository.
protected  void finalize()
           
 ClassDescriptor findFirstConcreteClass(ClassDescriptor cld)
          Return the first found concrete class ClassDescriptor.
 java.util.Collection getAllConcreteSubclassDescriptors(ClassDescriptor aCld)
          Utility method to discover all concrete subclasses of a given super class.
 java.util.List getAllConcreteSubclassesOf(ClassDescriptor aCld)
          Deprecated. use getAllConcreteSubclassDescriptors
 java.lang.String getAttribute(java.lang.String attributeName)
          Get the value of an attribute
 java.lang.String getAttribute(java.lang.String attributeName, java.lang.String defaultValue)
          Get the value of an attribute
 int getDefaultIsolationLevel()
          Returns the defaultIsolationLevel.
 ClassDescriptor getDescriptorFor(java.lang.Class c)
          lookup a ClassDescriptor in the internal Hashtable
 ClassDescriptor getDescriptorFor(java.lang.String strClassName)
          lookup a ClassDescriptor in the internal Hashtable
 java.util.Map getDescriptorTable()
           
 FieldDescriptor[] getFieldDescriptorsForMultiMappedTable(ClassDescriptor targetCld)
           
protected  java.lang.String getIsolationLevelAsString()
          returns IsolationLevel literal as matching to the corresponding id
 java.lang.Class getTopLevelClass(java.lang.Class clazz)
          Returns the top level (extent) class to which the given class belongs.
static java.lang.String getVersion()
           
 boolean hasDescriptorFor(java.lang.Class c)
          Checks if repository contains given class.
 java.util.Iterator iterator()
          Returns an iterator over all managed ClassDescriptor.
 void put(java.lang.Class c, ClassDescriptor cld)
          Add a ClassDescriptor to the internal Hashtable
Set the Repository for ClassDescriptor
 void put(java.lang.String classname, ClassDescriptor cld)
          Add a ClassDescriptor to the internal Hashtable
Set the Repository for ClassDescriptor
 void remove(java.lang.Class clazz)
           
 void remove(java.lang.String className)
           
(package private)  void removeExtent(java.lang.String classname)
          Remove a pair of extent/classdescriptor from the extentTable.
 void setClassDescriptor(ClassDescriptor cld)
          Convenience for put(Class c, ClassDescriptor cld)
 void setDefaultIsolationLevel(int defaultIsolationLevel)
          Sets the defaultIsolationLevel.
 java.lang.String toString()
          returns a string representation
 java.lang.String toXML()
          returns the XML marshalled version of this instance.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

DescriptorRepository

public DescriptorRepository()
                     throws PersistenceBrokerException
Constructor declaration

Method Detail

getVersion

public static java.lang.String getVersion()

addExtent

void addExtent(java.lang.String classname,
               ClassDescriptor cld)
Add a pair of extent/classdescriptor to the extentTable to gain speed while retrieval of extents.

Parameters:
classname - the name of the extent itself
cld - the class descriptor, where it belongs to

removeExtent

void removeExtent(java.lang.String classname)
Remove a pair of extent/classdescriptor from the extentTable.

Parameters:
classname - the name of the extent itself

getTopLevelClass

public java.lang.Class getTopLevelClass(java.lang.Class clazz)
                                 throws ClassNotPersistenceCapableException
Returns the top level (extent) class to which the given class belongs. This may be a (abstract) base-class, an interface or the given class itself if given class is not defined as an extent in other class descriptors.

Throws:
ClassNotPersistenceCapableException - if clazz is not persistence capable, i.e. if clazz is not defined in the DescriptorRepository.

getFieldDescriptorsForMultiMappedTable

public FieldDescriptor[] getFieldDescriptorsForMultiMappedTable(ClassDescriptor targetCld)
Returns:
all field descriptors for a class that belongs to a set of classes mapped to the same table, otherwise the select queries produced won't contain the necessary information to materialize extents mapped to the same class.

getDescriptorTable

public java.util.Map getDescriptorTable()

findFirstConcreteClass

public ClassDescriptor findFirstConcreteClass(ClassDescriptor cld)
Return the first found concrete class ClassDescriptor. This means a class which is not an interface or an abstract class. If given class descriptor is a concrete class, given class descriptor was returned. If no concrete class can be found null will be returned.


getAllConcreteSubclassesOf

public java.util.List getAllConcreteSubclassesOf(ClassDescriptor aCld)
Deprecated. use getAllConcreteSubclassDescriptors

Utility method to discover all concrete subclasses of a given super class.
This method was introduced in order to get Extent Aware Iterators.

Returns:
a List of Class objects

getAllConcreteSubclassDescriptors

public java.util.Collection getAllConcreteSubclassDescriptors(ClassDescriptor aCld)
Utility method to discover all concrete subclasses of a given super class.
This method was introduced in order to get Extent Aware Iterators.

Returns:
a Collection of ClassDescriptor objects

hasDescriptorFor

public boolean hasDescriptorFor(java.lang.Class c)
Checks if repository contains given class.


getDescriptorFor

public ClassDescriptor getDescriptorFor(java.lang.String strClassName)
                                 throws ClassNotPersistenceCapableException
lookup a ClassDescriptor in the internal Hashtable

Parameters:
strClassName - a fully qualified class name as it is returned by Class.getName().
Throws:
ClassNotPersistenceCapableException

getDescriptorFor

public ClassDescriptor getDescriptorFor(java.lang.Class c)
                                 throws ClassNotPersistenceCapableException
lookup a ClassDescriptor in the internal Hashtable

Throws:
ClassNotPersistenceCapableException

setClassDescriptor

public void setClassDescriptor(ClassDescriptor cld)
Convenience for put(Class c, ClassDescriptor cld)


put

public void put(java.lang.Class c,
                ClassDescriptor cld)
Add a ClassDescriptor to the internal Hashtable
Set the Repository for ClassDescriptor


put

public void put(java.lang.String classname,
                ClassDescriptor cld)
Add a ClassDescriptor to the internal Hashtable
Set the Repository for ClassDescriptor


remove

public void remove(java.lang.String className)

remove

public void remove(java.lang.Class clazz)

iterator

public java.util.Iterator iterator()
Returns an iterator over all managed ClassDescriptor.


getDefaultIsolationLevel

public int getDefaultIsolationLevel()
Returns the defaultIsolationLevel.

Returns:
int

setDefaultIsolationLevel

public void setDefaultIsolationLevel(int defaultIsolationLevel)
Sets the defaultIsolationLevel.

Parameters:
defaultIsolationLevel - The defaultIsolationLevel to set

toString

public java.lang.String toString()
returns a string representation

Overrides:
toString in class DescriptorBase

toXML

public java.lang.String toXML()
Description copied from interface: XmlCapable
returns the XML marshalled version of this instance.

Specified by:
toXML in interface XmlCapable
Returns:
the XML String representing this object.

getIsolationLevelAsString

protected java.lang.String getIsolationLevelAsString()
returns IsolationLevel literal as matching to the corresponding id

Returns:
the IsolationLevel literal

discoverDescriptor

protected ClassDescriptor discoverDescriptor(java.lang.String className)
Starts by looking to see if the className is already mapped specifically to the descritpor repository. If the className is not specifically mapped we look at the className's parent class for a mapping. We do this until the parent class is of the type java.lang.Object. If no mapping was found, null is returned. Mappings successfuly discovered through inheritence are added to the internal table of class descriptors to improve performance on subsequent requests for those classes.
author Scott T. Weaver

Parameters:
className - name of class whose descriptor we need to find.
Returns:
ClassDescriptor for className or null if no ClassDescriptor could be located.

finalize

protected void finalize()
                 throws java.lang.Throwable
Throws:
java.lang.Throwable

addAttribute

public void addAttribute(java.lang.String attributeName,
                         java.lang.String attributeValue)
Description copied from interface: AttributeContainer
Store the specified attribute and it's value.

Specified by:
addAttribute in interface AttributeContainer
Parameters:
attributeName - the name of the attribute to retrieve
attributeValue - the attribute's value
See Also:
AttributeContainer.addAttribute(String, String)

getAttribute

public java.lang.String getAttribute(java.lang.String attributeName,
                                     java.lang.String defaultValue)
Description copied from interface: AttributeContainer
Get the value of an attribute

Specified by:
getAttribute in interface AttributeContainer
Parameters:
attributeName - the attribute to retrieve
defaultValue - the value to return if the attribute is not present
Returns:
the attribute value
See Also:
AttributeContainer.getAttribute(String, String)

getAttribute

public java.lang.String getAttribute(java.lang.String attributeName)
Description copied from interface: AttributeContainer
Get the value of an attribute

Specified by:
getAttribute in interface AttributeContainer
Parameters:
attributeName - the attribute to retrieve
Returns:
the attribute value
See Also:
AttributeContainer.getAttribute(String)


Authors: Thomas Mahler and others. (C) 2000 - 2003 Apache Software Foundation
All rights reserved. Published under the Apache License.
http://db.apache.org/ojb
Version: 1.0.rc5, 2003-12-14