com.continuent.tungsten.replicator.ddlscan
Class DDLScanCtrl

java.lang.Object
  extended by com.continuent.tungsten.replicator.ddlscan.DDLScanCtrl

public class DDLScanCtrl
extends java.lang.Object

This class defines a DDLScanCtrl that implements a utility to access DDLScan methods. See the printHelp() command for a description of current commands.

Version:
1.0
Author:
Linas Virbalas

Field Summary
protected static ArgvIterator argvIterator
           
static java.lang.String DBNAME_VAR
          Variable used in JDBC URL of Replicator's configuration file to designate current schema/database.
protected static java.lang.String defaultConfigPath
          Default path to replicator.properties if user not specified other.
 
Constructor Summary
DDLScanCtrl(java.lang.String url, java.lang.String user, java.lang.String pass, java.lang.String db, java.lang.String tables, java.lang.String templateFile, java.lang.String outFile, java.lang.String renameDefinitions, java.util.Hashtable<java.lang.String,java.lang.String> templateOptions, java.lang.String additionalPath)
          Creates a new DDLScanCtrl object from provided JDBC URL connection credentials.
 
Method Summary
protected static void fail()
          Exit with a process failure code.
protected static void fatal(java.lang.String msg, java.lang.Throwable t)
          Abort following a fatal error.
protected static boolean getBoolOrFalse(java.lang.Boolean bool)
          Returns a value of a given Boolean object or false if the object is null.
static java.lang.String lookForConfigFile()
          Return the service configuration file if there is one and only one file that matches the static-svcname.properties pattern.
static void main(java.lang.String[] argv)
          Main method to run utility.
 void prepare()
           
protected static void print(java.lang.String msg)
          Print a message to stdout without trailing new line character.
protected static void printHelp()
           
protected static void println(java.lang.String msg)
          Print a message to stdout with trailing new line character.
static TungstenProperties readConfig(java.lang.String configFile)
          Reads the replicator.properties.
protected static boolean readYes()
          Reads a character from stdin, blocks until it is not received.
 void release()
           
 boolean scanAndGenerate()
          Scans the database for requested objects and generates output through a template.
static java.lang.String serviceFromConfigFileName(java.lang.String configFileName)
          Parse out service name from static configuration file name.
protected static void succeed()
          Exit with a process success code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultConfigPath

protected static final java.lang.String defaultConfigPath
Default path to replicator.properties if user not specified other.


argvIterator

protected static ArgvIterator argvIterator

DBNAME_VAR

public static final java.lang.String DBNAME_VAR
Variable used in JDBC URL of Replicator's configuration file to designate current schema/database.

See Also:
Constant Field Values
Constructor Detail

DDLScanCtrl

public DDLScanCtrl(java.lang.String url,
                   java.lang.String user,
                   java.lang.String pass,
                   java.lang.String db,
                   java.lang.String tables,
                   java.lang.String templateFile,
                   java.lang.String outFile,
                   java.lang.String renameDefinitions,
                   java.util.Hashtable<java.lang.String,java.lang.String> templateOptions,
                   java.lang.String additionalPath)
            throws java.lang.Exception
Creates a new DDLScanCtrl object from provided JDBC URL connection credentials.

Parameters:
url - JDBC URL connection string.
Throws:
java.lang.Exception
Method Detail

prepare

public void prepare()
             throws ReplicatorException,
                    java.lang.InterruptedException
Throws:
ReplicatorException
java.lang.InterruptedException

scanAndGenerate

public boolean scanAndGenerate()
                        throws java.lang.InterruptedException,
                               ReplicatorException,
                               java.sql.SQLException,
                               java.io.IOException
Scans the database for requested objects and generates output through a template.

Returns:
false, if there were unexpected errors (eg. template not found).
Throws:
java.lang.InterruptedException
ReplicatorException
java.sql.SQLException
java.io.IOException

release

public void release()

readConfig

public static TungstenProperties readConfig(java.lang.String configFile)
                                     throws java.lang.Exception
Reads the replicator.properties.

Throws:
java.lang.Exception

main

public static void main(java.lang.String[] argv)
Main method to run utility.

Parameters:
argv - optional command string

lookForConfigFile

public static java.lang.String lookForConfigFile()
Return the service configuration file if there is one and only one file that matches the static-svcname.properties pattern.


serviceFromConfigFileName

public static java.lang.String serviceFromConfigFileName(java.lang.String configFileName)
Parse out service name from static configuration file name.

Parameters:
configFileName - File name like "static-service.properties".
Returns:
Service name.

printHelp

protected static void printHelp()

println

protected static void println(java.lang.String msg)
Print a message to stdout with trailing new line character.

Parameters:
msg -

print

protected static void print(java.lang.String msg)
Print a message to stdout without trailing new line character.

Parameters:
msg -

fatal

protected static void fatal(java.lang.String msg,
                            java.lang.Throwable t)
Abort following a fatal error.

Parameters:
msg -
t -

fail

protected static void fail()
Exit with a process failure code.


succeed

protected static void succeed()
Exit with a process success code.


readYes

protected static boolean readYes()
                          throws java.io.IOException
Reads a character from stdin, blocks until it is not received.

Returns:
true if use pressed `y`, false otherwise.
Throws:
java.io.IOException

getBoolOrFalse

protected static boolean getBoolOrFalse(java.lang.Boolean bool)
Returns a value of a given Boolean object or false if the object is null.

Parameters:
bool - Boolean object to check and return.
Returns:
the value of a given Boolean object or false if the object is null.