org.clazzes.jdbc2xml.schema
Class SchemaEngine

java.lang.Object
  extended by org.clazzes.jdbc2xml.schema.SchemaEngine
All Implemented Interfaces:
ISchemaEngine
Direct Known Subclasses:
SchemaEngineImpl

public abstract class SchemaEngine
extends Object
implements ISchemaEngine

An implementation of this class is responsible for creating/modifying a database schema based on table descriptions.


Constructor Summary
protected SchemaEngine()
          Default constructor, which sets the default time zone.
protected SchemaEngine(IDialectFactory dialectFactory)
          Default constructor, which sets the default time zone.
 
Method Summary
 Connection getConnection()
           
 Dialect getDialect()
           
 String getSchema()
           
 TimeZone getTimeZone()
           
static ISchemaEngine newInstance()
          After generating a new SchemaEngine instance you usually have to call setConnection(Connection) in order to set up the database on which to operate.
 void setConnection(Connection connection)
          This method initializes the database dialect too, if the the dialect has not been set through ISchemaEngine.setDialect(Dialect) before.
 void setDialect(Dialect dialect)
          Normally you need not call this method, because the dialect is usually initialized by ISchemaEngine.setConnection(Connection).
 void setSchema(String schema)
           
 void setTimeZone(TimeZone timeZone)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.clazzes.jdbc2xml.schema.ISchemaEngine
addColumn, addForeignKey, addIndex, changeColumn, commit, createForeignKeys, createInsertStatement, createTable, dropColumn, dropForeignKey, dropForeignKeys, dropIndex, dropStaleBackupTables, dropTable, dropTables, fetchTableInfo, fetchTableInfos, getMaxTableNameLength, getTempTableNames, modifyColumn, renameTable, rollback
 

Constructor Detail

SchemaEngine

protected SchemaEngine()
Default constructor, which sets the default time zone.


SchemaEngine

protected SchemaEngine(IDialectFactory dialectFactory)
Default constructor, which sets the default time zone.

Method Detail

newInstance

public static ISchemaEngine newInstance()

After generating a new SchemaEngine instance you usually have to call setConnection(Connection) in order to set up the database on which to operate.

Additionally, it is recommended, that you configure the default time zone using {setTimeZone(TimeZone).

This method does not work in OSGi containers. You should use the service implementing ISchemaEngineFactory, which is registered, when jdbc2xml is deployed inside a blueprint-enabled OSGi container.

Returns:
The first implementation registered under the resource path META-INF/services/org.clazzes.jdbc2xml.schema.SchemaEngine.
See Also:
ServiceRegistry.lookupProviders(Class)

getConnection

public Connection getConnection()
Specified by:
getConnection in interface ISchemaEngine
Returns:
The database connection.

setConnection

public void setConnection(Connection connection)
                   throws SQLException
Description copied from interface: ISchemaEngine
This method initializes the database dialect too, if the the dialect has not been set through ISchemaEngine.setDialect(Dialect) before. The dialect is retrieved through a call to IDialectFactory.newDialect(java.sql.DatabaseMetaData) on the instance returned by DialectFactory.newInstance().

Specified by:
setConnection in interface ISchemaEngine
Parameters:
connection - The database connection to set.
Throws:
SQLException - If the metadata retrieval on the database failed during the dialect initialization.

getTimeZone

public TimeZone getTimeZone()
Specified by:
getTimeZone in interface ISchemaEngine
Returns:
The default time zone used for transforming date values, if the database engine does not store a time zone information.

setTimeZone

public void setTimeZone(TimeZone timeZone)
Specified by:
setTimeZone in interface ISchemaEngine
Parameters:
timeZone - The time zone to set.

getDialect

public Dialect getDialect()
Specified by:
getDialect in interface ISchemaEngine
Returns:
The dialect used by this engine.

setDialect

public void setDialect(Dialect dialect)
Description copied from interface: ISchemaEngine
Normally you need not call this method, because the dialect is usually initialized by ISchemaEngine.setConnection(Connection).

Specified by:
setDialect in interface ISchemaEngine
Parameters:
dialect - The database dialect to set

getSchema

public String getSchema()
Specified by:
getSchema in interface ISchemaEngine
Returns:
The schema name used for retrieving schema metadata. The schema is most often null, because most databases use a single namespace for tables, if the connection is opened with a valid catalog.
See Also:
DatabaseMetaData.getTables(String, String, String, String[]), DatabaseMetaData.getColumns(String, String, String, String), DatabaseMetaData.getImportedKeys(String, String, String), DatabaseMetaData.getExportedKeys(String, String, String), DatabaseMetaData.getPrimaryKeys(String, String, String)

setSchema

public void setSchema(String schema)
Specified by:
setSchema in interface ISchemaEngine
Parameters:
schema - The schema to set


Copyright © 2012. All Rights Reserved.