DODS 5.1 API

org.enhydra.dods
Class DODS

java.lang.Object
  |
  +--org.enhydra.dods.DODS

public class DODS
extends java.lang.Object

Main DODS class. There are two modes of usage: non-threading and threading. In non-threading mode, only one DatabaseManager is used for the whole application, no matter the application has one or more Threads. In threading mode, there is one DatabaseManager for every Thread. User needs, for every Thread, to define the DatabaseManager. If, for any Thread, the DatabaseManager is not defined, the default DatabaseManager is used.

Example for non-threading mode:

  ...
  try {
         String fileName = "discRack.conf";
      DatabaseManager dbManager = StandardDatabaseManager.newInstance(fileName);
      DODS.register(dbManager);
  } catch (Exception e) {
      e.printStackTrace();
  }
  ...
 


Field Summary
protected static java.lang.String LOG4J_CONF_FILE
           
 
Constructor Summary
DODS()
           
 
Method Summary
static DatabaseManager getDatabaseManager()
          Returns the DatabaseManager object for the current thread.
static DatabaseManager getDatabaseManager(java.lang.Thread thread)
          Returns the DatabaseManager object for the given thread.
static DatabaseManager getDefaultDatabaseManager()
          Returns the default DatabaseManager.
static org.apache.log4j.Logger getDefaultLogger()
          Returns the default logger.
static org.apache.log4j.Logger getLogger()
          Returns the logger object for the current thread.
static org.apache.log4j.Logger getLogger(java.lang.Thread thread)
          Returns the logger object for the given thread.
protected static void init()
          Initializes DODS.
static boolean isThreading()
          Returns the mode of usage.
static void main(java.lang.String[] args)
           
static void register(DatabaseManager databaseManager)
          In threading mode, this method associates the DatabaseManager object with the current thread.
static void register(java.lang.Thread thread, DatabaseManager databaseManager)
          Associates the given DatabaseManager object with given thread.
static void registerDefault(DatabaseManager databaseManager)
          Sets the default DatabaseManager.
static void registerDefault(java.lang.String fileName)
          Sets the default DatabaseManager.
static void registerDefaultLogger(org.apache.log4j.Logger logger)
          Sets the default logger.
static void registerDefaultLogger(java.lang.String name)
          Sets the default logger.
static void registerLogger(org.apache.log4j.Logger logger)
          In threading mode, this method associates the logger object with the current thread.
static void registerLogger(java.lang.String name)
          In threading mode, this method associates the logger object with the current thread.
static void registerLogger(java.lang.Thread thread, org.apache.log4j.Logger logger)
          Associates the given logger object with the given thread.
static void registerLogger(java.lang.Thread thread, java.lang.String name)
          Associates the given logger object with given thread.
static void setThreading(boolean mode)
          Sets mode of usage.
static void shutdown()
          Shutdowns all DatabaseManagers and Loggerss.
static void startup(java.lang.Thread thread, java.lang.String fileName)
          Associates DatabaseManager created by the given fileName with given thread.
static void stratup(java.lang.String fileName)
          In threading mode, this method associates the DatabaseManager object with the current thread.
static DatabaseManager unregister()
          In threading mode, this method unregisters DatabaseManager associated with the current thread.
static DatabaseManager unregister(java.lang.Thread thread)
          Unregisters DatabaseManager associated with the given thread.
static DatabaseManager unregisterDefault()
          Unregisters default DatabaseManager.
static org.apache.log4j.Logger unregisterDefaultLogger()
          Unregisters defaultLogger.
static org.apache.log4j.Logger unregisterLogger()
          In threading mode, this method unregisters Logger associated with the current thread.
static org.apache.log4j.Logger unregisterLogger(java.lang.Thread thread)
          Unregisters Logger associated with the given thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG4J_CONF_FILE

protected static final java.lang.String LOG4J_CONF_FILE
See Also:
Constant Field Values
Constructor Detail

DODS

public DODS()
Method Detail

registerDefault

public static void registerDefault(DatabaseManager databaseManager)
Sets the default DatabaseManager.

Parameters:
databaseManager - the DatabaseManager to be set as default.

registerDefault

public static void registerDefault(java.lang.String fileName)
                            throws com.lutris.util.ConfigException,
                                   DatabaseManagerException,
                                   java.sql.SQLException
Sets the default DatabaseManager.

Parameters:
fileName - full path name of the application configuration file.
com.lutris.util.ConfigException
DatabaseManagerException
java.sql.SQLException

register

public static void register(DatabaseManager databaseManager)
In threading mode, this method associates the DatabaseManager object with the current thread. If default DatabaseManager is null, it will also be set. In non-threading mode, only default DatabaseManager will be set.

Parameters:
databaseManager - the DatabaseManager to associate with current thread.

stratup

public static void stratup(java.lang.String fileName)
                    throws com.lutris.util.ConfigException,
                           DatabaseManagerException,
                           java.sql.SQLException
In threading mode, this method associates the DatabaseManager object with the current thread. If default DatabaseManager is null, it will also be set. In non-threading mode, only default DatabaseManager will be set.

Parameters:
fileName - full path name of the application configuration file which will create DatabaseManagerassociate with current thread.
com.lutris.util.ConfigException
DatabaseManagerException
java.sql.SQLException

register

public static void register(java.lang.Thread thread,
                            DatabaseManager databaseManager)
Associates the given DatabaseManager object with given thread. If default DatabaseManager is null, the default DatabaseManager will also be set.

Parameters:
thread - the thread to associate with DatabaseManager.
databaseManager - the DatabaseManager to associate the Thread.

startup

public static void startup(java.lang.Thread thread,
                           java.lang.String fileName)
                    throws com.lutris.util.ConfigException,
                           DatabaseManagerException,
                           java.sql.SQLException
Associates DatabaseManager created by the given fileName with given thread. If default DatabaseManager is null, the default DatabaseManager will also be set.

Parameters:
thread - the thread to associate with DatabaseManager.
fileName - full path name of the application configuration file which will create DatabaseManagerassociate with given thread.
com.lutris.util.ConfigException
DatabaseManagerException
java.sql.SQLException

registerDefaultLogger

public static void registerDefaultLogger(java.lang.String name)
Sets the default logger.

Parameters:
name - logger name, set in log4j configuration file.

registerDefaultLogger

public static void registerDefaultLogger(org.apache.log4j.Logger logger)
Sets the default logger.

Parameters:
logger - logger that will be set as default logger.

registerLogger

public static void registerLogger(java.lang.String name)
In threading mode, this method associates the logger object with the current thread. In non-threading mode, only default logger will be set.

Parameters:
name - logger name, set in log4j configuration file.

registerLogger

public static void registerLogger(org.apache.log4j.Logger logger)
In threading mode, this method associates the logger object with the current thread. In non-threading mode, only default logger will be set.

Parameters:
logger - logger that will be set.

registerLogger

public static void registerLogger(java.lang.Thread thread,
                                  java.lang.String name)
Associates the given logger object with given thread.

Parameters:
thread - the thread to associate with the logger.
name - the logger to associate the Thread.

registerLogger

public static void registerLogger(java.lang.Thread thread,
                                  org.apache.log4j.Logger logger)
Associates the given logger object with the given thread.

Parameters:
thread - the thread to associate with logger.
logger - the logger to associate the Thread.

unregisterDefault

public static DatabaseManager unregisterDefault()
                                         throws DODSException
Unregisters default DatabaseManager. Call this method to release default DatabaseManager.

Returns:
unregistered default DatabaseManager.
Throws:
DODSException - If an error occurs in unregistering the DatabaseManager.

unregister

public static DatabaseManager unregister()
                                  throws DODSException
In threading mode, this method unregisters DatabaseManager associated with the current thread. In non-threading mode, only default DatabaseManager will be unregistered. Call this method to release DatabaseManager.

Returns:
unregistered DatabaseManager.
Throws:
DODSException - If an error occurs in unregistering the DatabaseManager.

unregister

public static DatabaseManager unregister(java.lang.Thread thread)
                                  throws DODSException
Unregisters DatabaseManager associated with the given thread. Call this method to release DatabaseManager.

Returns:
unregistered DatabaseManager.
Throws:
DODSException - If an error occurs in unregistering the DatabaseManager.

unregisterDefaultLogger

public static org.apache.log4j.Logger unregisterDefaultLogger()
                                                       throws DODSException
Unregisters defaultLogger. Call this method to release default Logger.

Returns:
unregistered default Logger.
Throws:
DODSException - If an error occurs in unregistering the logger.

unregisterLogger

public static org.apache.log4j.Logger unregisterLogger()
                                                throws DODSException
In threading mode, this method unregisters Logger associated with the current thread. In non-threading mode, only default Logger will be unregistered. Call this method to release Logger.

Returns:
unregistered Logger.
Throws:
DODSException - If an error occurs in unregistering the logger.

unregisterLogger

public static org.apache.log4j.Logger unregisterLogger(java.lang.Thread thread)
                                                throws DODSException
Unregisters Logger associated with the given thread. Call this method to release Logger.

Returns:
unregistered Logger.
Throws:
DODSException - If an error occurs in unregistering the logger.

getDefaultDatabaseManager

public static DatabaseManager getDefaultDatabaseManager()
Returns the default DatabaseManager.

Returns:
the default DatabaseManager.

getDatabaseManager

public static DatabaseManager getDatabaseManager()
Returns the DatabaseManager object for the current thread. Returns default DatabaseManager if there is no database manager associated with the current thread. Returns null if default DatabaseManager is not set. If non-threading mode is used, default DatabaseManager will be returned.

Returns:
the DatabaseManager object, if available, otherwise null.

getDatabaseManager

public static DatabaseManager getDatabaseManager(java.lang.Thread thread)
Returns the DatabaseManager object for the given thread. Returns default DatabaseManager if there is no database manager associated with the thread. Returns null if default DatabaseManager is not set.

Parameters:
thread - the thread to associate with the DatabaseManager.
Returns:
the DatabaseManager object, if available, otherwise null.

getDefaultLogger

public static org.apache.log4j.Logger getDefaultLogger()
Returns the default logger.

Returns:
The default logger.

getLogger

public static org.apache.log4j.Logger getLogger()
Returns the logger object for the current thread. Returns default logger if there is no logger associated with the current thread. Returns null if default logger is not set. If non-threading mode is used, default Logger will be returned.

Returns:
the logger object, if available, otherwise null.

getLogger

public static org.apache.log4j.Logger getLogger(java.lang.Thread thread)
Returns the logger object for the given thread. Returns default logger if there is no logger associated with the thread. Returns null if default logger is not set.

Parameters:
thread - the thread to associate with the logger.
Returns:
the logger object, if available, otherwise null.

shutdown

public static void shutdown()
                     throws DODSException
Shutdowns all DatabaseManagers and Loggerss. Call this method to release and shutdown all DatabaseManagers and Loggerss.

Throws:
DODSException - If an error occurs in releasing DatabaseManagers and loggers.

isThreading

public static boolean isThreading()
Returns the mode of usage. If this flag is true, DODS uses multi threading mode. This means that DODS handles multiple threads, like Enhydra application server (each application in one Thread). If this flag is false, there can be more then one Thread, but there is only one DatabaseManager for all Threads (for the whole application).

Returns:
true if threading mode is used, otherwise false.

setThreading

public static void setThreading(boolean mode)
Sets mode of usage. If this flag is true, DODS uses multi threading mode. This means that DODS handles multiple threads, like Enhydra application server (each application in one Thread). If this flag is false, there can be more then one Thread, but there is only one DatabaseManager for all Threads (for the whole application).

Parameters:
mode - mode of usage.

init

protected static void init()
Initializes DODS. Sets default logger.


main

public static void main(java.lang.String[] args)

DODS 5.1 API