org.objectweb.cjdbc.controller.backend
Class DatabaseBackendMetaData

java.lang.Object
  extended byorg.objectweb.cjdbc.controller.backend.DatabaseBackendMetaData

public final class DatabaseBackendMetaData
extends java.lang.Object

A DatabaseBackendMetaData is used to retrieve the database schema of a real database backend that will have to be bound to a virtual C-JDBC database.

Version:
1.0
Author:
Julie Marguerite , Emmanuel Cecchet , Nicolas Modrzyk , Mathieu Peltier , Jean-Bernard van Zuylen

Field Summary
private  AbstractConnectionManager connectionManager
          Connection manager to get a connection from.
private  DatabaseSchema databaseSchema
          Schema of the database backend.
private  int dynamicPrecision
          The precision of the dynamically generated schema
private  boolean gatherSystemTables
          Should the system tables be gathered or not
private  Trace logger
          Logger instance.
private  MetadataContainer metadataContainer
          Container for static metadata
private  java.lang.String schemaName
          The name of the schema used to gather meta data
 
Constructor Summary
DatabaseBackendMetaData(AbstractConnectionManager connectionManager, Trace logger, int dynamicPrecision, boolean gatherSystemTables, java.lang.String schemaName)
          Creates a new DatabaseBackendMetaData instance.
 
Method Summary
 void createDatabaseSchemaDynamically()
          Gets the list of tables of a database and add them to the database schema.
 DatabaseSchema getDatabaseSchema()
          Returns the database schema.
private  void insertMetadataInContainer(java.sql.DatabaseMetaData metaData, java.lang.String methodName, java.lang.Class[] parametersType, java.lang.Object[] arguments)
          This method invokes by reflection the appropriate metadata method and fills the container with the result.
private  void overrideCJDBCSpecificFeatures()
          This method overrides metdata container information with C-JDBC specific limitations.
 MetadataContainer retrieveDatabaseMetadata()
          Retrieve metadata from a connection on this backend and build the ("getDataXXX(Y,Z,
private  void updateContainerInformation(java.lang.String methodName, java.lang.Class[] parametersType, java.lang.Object[] arguments, java.lang.Object result)
          Update the metadata container information for the given method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connectionManager

private AbstractConnectionManager connectionManager
Connection manager to get a connection from.


logger

private Trace logger
Logger instance.


databaseSchema

private DatabaseSchema databaseSchema
Schema of the database backend.


dynamicPrecision

private int dynamicPrecision
The precision of the dynamically generated schema


gatherSystemTables

private boolean gatherSystemTables
Should the system tables be gathered or not


schemaName

private java.lang.String schemaName
The name of the schema used to gather meta data


metadataContainer

private MetadataContainer metadataContainer
Container for static metadata

Constructor Detail

DatabaseBackendMetaData

public DatabaseBackendMetaData(AbstractConnectionManager connectionManager,
                               Trace logger,
                               int dynamicPrecision,
                               boolean gatherSystemTables,
                               java.lang.String schemaName)
Creates a new DatabaseBackendMetaData instance. This class takes care of initializing the connection manager if needed but the driver must have been previously loaded else the connection manager's initialization will fail.

Parameters:
connectionManager - the connection manager to gather the schema from
logger - the logger (usually the backend logger) to use
dynamicPrecision - the precision with which we gather a schema directly from the backend
gatherSystemTables - true if system tables must be gathered
schemaName - schema name to use to retrieve information
Method Detail

insertMetadataInContainer

private void insertMetadataInContainer(java.sql.DatabaseMetaData metaData,
                                       java.lang.String methodName,
                                       java.lang.Class[] parametersType,
                                       java.lang.Object[] arguments)
This method invokes by reflection the appropriate metadata method and fills the container with the result.

Parameters:
metaData - metadata to invoke
methodName - method to invoke
parametersType - parameters type of method to invoke
arguments - arguments to invoke the method

updateContainerInformation

private void updateContainerInformation(java.lang.String methodName,
                                        java.lang.Class[] parametersType,
                                        java.lang.Object[] arguments,
                                        java.lang.Object result)
Update the metadata container information for the given method.

Parameters:
methodName - method invoked to generate the key in the container
parametersType - parameters type of invoked method
arguments - arguments used to invoke the method
result - result of the method call

retrieveDatabaseMetadata

public MetadataContainer retrieveDatabaseMetadata()
                                           throws java.sql.SQLException
Retrieve metadata from a connection on this backend and build the ("getDataXXX(Y,Z,...)", value) hash table. Note that some values are overriden with C-JDBC specific features (add-ons or limitations).

Returns:
a metadata container including all metadata values
Throws:
java.sql.SQLException - if an error occurs

overrideCJDBCSpecificFeatures

private void overrideCJDBCSpecificFeatures()
This method overrides metdata container information with C-JDBC specific limitations.


createDatabaseSchemaDynamically

public void createDatabaseSchemaDynamically()
                                     throws java.sql.SQLException
Gets the list of tables of a database and add them to the database schema. The caller must ensure that the parameters are not null.

Throws:
java.sql.SQLException - if an error occurs

getDatabaseSchema

public DatabaseSchema getDatabaseSchema()
                                 throws java.sql.SQLException
Returns the database schema. Returns null If an error has occured during the schema generation.

If the schema has not been previously computed, createDatabaseSchemaDynamically()is called.

Returns:
a DatabaseSchema value
Throws:
java.sql.SQLException - if a problem occurs when creating the database schema
See Also:
createDatabaseSchemaDynamically()


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.