xmlBlaster 2.2.0 contributions API

org.xmlBlaster.contrib.replication.impl
Class SpecificDbReadonly

java.lang.Object
  extended by org.xmlBlaster.contrib.replication.impl.SpecificDefault
      extended by org.xmlBlaster.contrib.replication.impl.SpecificDbReadonly
All Implemented Interfaces:
I_ContribPlugin, I_DbSpecific

public class SpecificDbReadonly
extends SpecificDefault

Author:
laghi, ruff

Field Summary
 
Fields inherited from class org.xmlBlaster.contrib.replication.impl.SpecificDefault
blockLoop, COMMIT_NO, COMMIT_YES, dbMetaHelper, dbPool, info, initialUpdater, isDbWriteable, replacer, replaceVariable, replPrefix, replVersion, ROLLBACK_NO, ROLLBACK_YES, transformer
 
Fields inherited from interface org.xmlBlaster.contrib.replication.I_DbSpecific
NEEDS_PUBLISHER_KEY, WIPEOUT_ALL, WIPEOUT_FUNCTIONS, WIPEOUT_INDEXES, WIPEOUT_NO_TABLES, WIPEOUT_ONLY_TABLES, WIPEOUT_PACKAGES, WIPEOUT_PROCEDURES, WIPEOUT_SEQUENCES, WIPEOUT_SYNONYMS, WIPEOUT_TABLES, WIPEOUT_TRIGGERS, WIPEOUT_VIEWS
 
Constructor Summary
SpecificDbReadonly()
           
 
Method Summary
 void addSchemaToWatch(java.sql.Connection conn, java.lang.String catalog, java.lang.String schema)
          Adds a schema to be watched.
 void addTriggersIfNeeded(boolean force, java.lang.String[] destinations, boolean forceSend)
          If force is true, it deletes first all entries from the Tables table (kind of reset).
 void bootstrap(java.sql.Connection conn, boolean doWarn, boolean force)
          This method is invoked for the initial setup of the database.
 void checkTriggerConsistency(boolean doFix)
          Checks the consistency of the triggers.
 void cleanup(java.sql.Connection conn, boolean doWarn)
          This method is invoked for the cleanup while testing.
 java.lang.String createTableTrigger(SqlDescription infoDescription, TableToWatchInfo tableToWatch)
          Creates a string containing the trigger of the table to be watched.
 void forceTableChangeCheck()
          Invokes the function to check wether a table has been created, dropped or altered.
 java.lang.StringBuffer getColumnStatement(SqlColumn colInfoDescription)
          This method should actually be protected since it is not used on the outside.
 java.lang.String getContentFromGuid(java.lang.String guid, java.lang.String catalog, java.lang.String schema, java.lang.String table, I_AttributeTransformer transformer)
          This is used for cases where it was not possible to retrieve the (new) content of an entry synchronously in the PL/SQL Code.
 long incrementReplKey(java.sql.Connection conn)
          Increments and retreives the ${replPrefix}key sequence counter.
 void init(I_Info info)
           
 void initiateUpdate(java.lang.String topic, java.lang.String replManagerAddress, java.lang.String[] slaveNames, java.lang.String requestedVersion, java.lang.String initialFilesLocation)
          Initiates an initial update.
 boolean isDatasourceReadonly()
           
 boolean removeTrigger(java.lang.String triggerName, java.lang.String tableName, boolean isSchemaTrigger)
          removes the specified trigger from the specified table.
protected  boolean sequenceExists(java.sql.Connection conn, java.lang.String sequenceName)
           
protected  boolean triggerExists(java.sql.Connection conn, java.lang.String triggerName)
           
 boolean triggerExists(java.sql.Connection conn, TableToWatchInfo tableToWatch)
          Checks wether a trigger really exists or not.
 int wipeoutSchema(java.lang.String catalog, java.lang.String schema, boolean[] objectsToWipeout)
          Cleans up the complete schema.
 
Methods inherited from class org.xmlBlaster.contrib.replication.impl.SpecificDefault
addTableToWatch, addTrigger, broadcastStatement, cancelUpdate, checkSequenceForCreation, checkTableForCreation, checkTriggerForCreation, clearCancelUpdate, getContentFromClasspath, getCreateTableStatement, getName, getObjectName, getOwnSchema, getReplPrefix, getUsedPropertyKeys, initialCommand, initialCommandPre, main, readNewTable, releaseIntoPool, releaseIntoPool, removeFromPool, removeFromPool, removeSchemaTriggers, removeTableToWatch, setAttributeTransformer, shutdown, toString, updateFromFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpecificDbReadonly

public SpecificDbReadonly()
Method Detail

init

public void init(I_Info info)
          throws java.lang.Exception
Specified by:
init in interface I_ContribPlugin
Overrides:
init in class SpecificDefault
Throws:
java.lang.Exception
See Also:
I_ContribPlugin.init(I_Info)

addTriggersIfNeeded

public void addTriggersIfNeeded(boolean force,
                                java.lang.String[] destinations,
                                boolean forceSend)
Description copied from class: SpecificDefault
If force is true, it deletes first all entries from the Tables table (kind of reset).

Specified by:
addTriggersIfNeeded in interface I_DbSpecific
Overrides:
addTriggersIfNeeded in class SpecificDefault
Parameters:
force - to force recreation of triggers even if they exist already.

checkTriggerConsistency

public final void checkTriggerConsistency(boolean doFix)
Description copied from class: SpecificDefault
Checks the consistency of the triggers. If an entry is found in the TABLES table, and the table does not exist, nothing is done.

Specified by:
checkTriggerConsistency in interface I_DbSpecific
Overrides:
checkTriggerConsistency in class SpecificDefault

bootstrap

public final void bootstrap(java.sql.Connection conn,
                            boolean doWarn,
                            boolean force)
Description copied from interface: I_DbSpecific
This method is invoked for the initial setup of the database. In production this method is probably never called. Initial configuration (for example procedural configuration), creation of 'system tables' , 'system functions' and triggers (if any) is done here. We use the term 'system' to specify such elements which are used internally for the replication.

Specified by:
bootstrap in interface I_DbSpecific
Overrides:
bootstrap in class SpecificDefault
doWarn - if false no warning is given on excrption.
force - if true, then everything is cleaned up, if false, then tables and sequences are only rebuilt if not existing.
See Also:
In case of an exception you need to cleanup the connection yourself.

cleanup

public final void cleanup(java.sql.Connection conn,
                          boolean doWarn)
Description copied from interface: I_DbSpecific
This method is invoked for the cleanup while testing. In production this method is probably never called. Cleanup of initial configuration (for example procedural configuration), dropping of 'system tables' , 'system functions' and triggers (if any) is done here. We use the term 'system' to specify such elements which are used internally for the replication.

Specified by:
cleanup in interface I_DbSpecific
Overrides:
cleanup in class SpecificDefault
doWarn - if false no warning is given on excrption.
See Also:
In case of an exception you need to cleanup the connection yourself.

forceTableChangeCheck

public final void forceTableChangeCheck()
Description copied from interface: I_DbSpecific
Invokes the function to check wether a table has been created, dropped or altered.

Specified by:
forceTableChangeCheck in interface I_DbSpecific
Overrides:
forceTableChangeCheck in class SpecificDefault

initiateUpdate

public final void initiateUpdate(java.lang.String topic,
                                 java.lang.String replManagerAddress,
                                 java.lang.String[] slaveNames,
                                 java.lang.String requestedVersion,
                                 java.lang.String initialFilesLocation)
                          throws java.lang.Exception
Description copied from interface: I_DbSpecific
Initiates an initial update. It is invoked by the InitialUpdater in asynchronous mode.

Specified by:
initiateUpdate in interface I_DbSpecific
Overrides:
initiateUpdate in class SpecificDefault
replManagerAddress - the address to which to send acknowleges.
slaveNames - the name of the slave interested in these updates
requestedVersion - the version for which to start replication. If null the current version
initialFilesLocation - tells where to store the initial files in case the replication data has to be transfered manually by means of copying files. is ment.
Throws:
java.lang.Exception
See Also:
org.xmlBlaster.contrib.replication.I_DbSpecific#initiateUpdate(java.lang.String)

sequenceExists

protected boolean sequenceExists(java.sql.Connection conn,
                                 java.lang.String sequenceName)
                          throws java.lang.Exception
Specified by:
sequenceExists in class SpecificDefault
Throws:
java.lang.Exception

triggerExists

protected boolean triggerExists(java.sql.Connection conn,
                                java.lang.String triggerName)
                         throws java.lang.Exception
Specified by:
triggerExists in class SpecificDefault
Throws:
java.lang.Exception

addSchemaToWatch

public void addSchemaToWatch(java.sql.Connection conn,
                             java.lang.String catalog,
                             java.lang.String schema)
                      throws java.lang.Exception
Description copied from interface: I_DbSpecific
Adds a schema to be watched. By Oracle it would add triggers to the schema.

Throws:
java.lang.Exception

createTableTrigger

public java.lang.String createTableTrigger(SqlDescription infoDescription,
                                           TableToWatchInfo tableToWatch)
Description copied from interface: I_DbSpecific
Creates a string containing the trigger of the table to be watched. .

Returns:

getColumnStatement

public java.lang.StringBuffer getColumnStatement(SqlColumn colInfoDescription)
Description copied from interface: I_DbSpecific
This method should actually be protected since it is not used on the outside. It is part of this interface since the handling for the different databases can be different.

Parameters:
colInfoDescription - The info object describing this column.
Returns:
A String Buffer containing the part of the CREATE statement which is specific to this column.

getContentFromGuid

public java.lang.String getContentFromGuid(java.lang.String guid,
                                           java.lang.String catalog,
                                           java.lang.String schema,
                                           java.lang.String table,
                                           I_AttributeTransformer transformer)
                                    throws java.lang.Exception
Description copied from interface: I_DbSpecific
This is used for cases where it was not possible to retrieve the (new) content of an entry synchronously in the PL/SQL Code.

Parameters:
guid - the unique Id identifying this entry. This is needed. Can not be null
catalog - can be null
schema - can be null
table - must be defined (can not be null).
transformer - An optional plugin
Returns:
the String containing the serialized entry.
Throws:
java.lang.Exception

removeTrigger

public boolean removeTrigger(java.lang.String triggerName,
                             java.lang.String tableName,
                             boolean isSchemaTrigger)
Description copied from interface: I_DbSpecific
removes the specified trigger from the specified table.

isSchemaTrigger - true if the trigger to be removed is a schema trigger.
Returns:
true if the trigger has been removed, false otherwise.

triggerExists

public boolean triggerExists(java.sql.Connection conn,
                             TableToWatchInfo tableToWatch)
                      throws java.lang.Exception
Description copied from interface: I_DbSpecific
Checks wether a trigger really exists or not. This method is normally implemented by the vendor specific implementation. It is used to detect inconsistencies.

tableToWatch - The object containing the table to be checked for trigger
Returns:
true if the trigger really exists, false otherwise.
Throws:
java.lang.Exception - If an exception occurs in the backend.

wipeoutSchema

public int wipeoutSchema(java.lang.String catalog,
                         java.lang.String schema,
                         boolean[] objectsToWipeout)
                  throws java.lang.Exception
Description copied from interface: I_DbSpecific
Cleans up the complete schema. It cleans tables, sequences, views, functions, procedures, triggers and indexes.

objectsToWipeout - a boolean[] array containing 9 elements telling wether the specified objects of a certain type have to be wiped out or not. For the relationship between position and meaning see the static variables. If you pass null here all object types are wiped out.
Returns:
the number of entries removed.
Throws:
java.lang.Exception

incrementReplKey

public long incrementReplKey(java.sql.Connection conn)
                      throws java.lang.Exception
Description copied from class: SpecificDefault
Increments and retreives the ${replPrefix}key sequence counter. The connection must not be null. Description of sequences for oracle: http://www.lc.leidenuniv.nl/awcourse/oracle/server.920/a96540/statements_615a.htm#2067095

Specified by:
incrementReplKey in interface I_DbSpecific
Overrides:
incrementReplKey in class SpecificDefault
Parameters:
conn - the connection (it must not be null)
Returns:
the new sequence value for the repl_key sequence.
Throws:
java.lang.Exception - if an exception occurs.
See Also:
I_DbSpecific.incrementReplKey(Connection)

isDatasourceReadonly

public boolean isDatasourceReadonly()
Specified by:
isDatasourceReadonly in interface I_DbSpecific
Overrides:
isDatasourceReadonly in class SpecificDefault

xmlBlaster 2.2.0 contributions API

Copyright © 1999-2014 The xmlBlaster.org contributers.