DODS 7.3 API

org.enhydra.dods
Class DODS

java.lang.Object
  extended by 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();
   }
   ...
 


Constructor Summary
DODS()
           
 
Method Summary
static LogChannel configureStandardLogerChannel()
           
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 LogChannel getDefaultLogChannel()
          Returns the default logger.
static LogChannel getLogChannel()
          Returns the logger object for the current thread.
static LogChannel getLogChannel(java.lang.Thread thread)
          Returns the logger object for the given thread.
protected static void init()
          Initializes DODS.
protected static boolean isDodsConfigured()
           
static boolean isThreading()
          Returns the mode of usage.
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 registerDefaultLogChannel(LogChannel channel)
          Sets the default logChannel.
static void registerLogChannel(LogChannel channel)
          In threading mode, this method associates the channel object with the current thread.
static void registerLogChannel(java.lang.Thread thread, LogChannel channel)
          Associates the given channel object with the given thread.
protected static void setDodsConfigured(boolean configured)
           
static void setThreading(boolean mode)
          Sets mode of usage.
static void shutdown()
          Shutdowns all DatabaseManagers and Loggerss.
static void startup(java.lang.String fileName)
          In threading mode, this method associates the DatabaseManager object with the current thread.
static void startup(java.lang.Thread thread, java.lang.String fileName)
          Associates DatabaseManager created by the given fileName with given thread.
static void startup(java.net.URL confURL, java.lang.String confFile)
          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 LogChannel unregisterDefaultLogChannel()
          Unregisters defaultLogger.
static LogChannel unregisterLogChannel()
          In threading mode, this method unregisters LogChannel associated with the current thread.
static LogChannel unregisterLogChannel(java.lang.Thread thread)
          Unregisters LogChannel associated with the given thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 ConfigException,
                                   DatabaseManagerException,
                                   java.sql.SQLException
Sets the default DatabaseManager.

Parameters:
fileName - full path name of the application configuration file.
Throws:
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.

startup

public static void startup(java.lang.String fileName)
                    throws 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.
Throws:
ConfigException
DatabaseManagerException
java.sql.SQLException

startup

public static void startup(java.net.URL confURL,
                           java.lang.String confFile)
                    throws 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:
confURL - Additional path to folder or *.jar file with configuration file. If null use DODS classpath.
confFile - Name of conf file relativ to *.jar file or to specifide folder (from confURL/DODS claspath).
Throws:
ConfigException
DatabaseManagerException
java.sql.SQLException

startup

public static void startup(java.lang.Thread thread,
                           java.lang.String fileName)
                    throws 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.
Throws:
ConfigException
DatabaseManagerException
java.sql.SQLException

configureStandardLogerChannel

public static LogChannel configureStandardLogerChannel()
                                                throws ConfigException
Throws:
ConfigException

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.

registerDefaultLogChannel

public static void registerDefaultLogChannel(LogChannel channel)
Sets the default logChannel.

Parameters:
channel - LogChannel that will be set as default LogChannel.

registerLogChannel

public static void registerLogChannel(LogChannel channel)
In threading mode, this method associates the channel object with the current thread. In non-threading mode, only default channel will be set.

Parameters:
channel - LogChannel that will be set.

registerLogChannel

public static void registerLogChannel(java.lang.Thread thread,
                                      LogChannel channel)
Associates the given channel object with the given thread.

Parameters:
thread - the thread to associate with channel.
channel - the channel 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.

unregisterDefaultLogChannel

public static LogChannel unregisterDefaultLogChannel()
                                              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.

unregisterLogChannel

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

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

unregisterLogChannel

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

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

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.

getDefaultLogChannel

public static LogChannel getDefaultLogChannel()
Returns the default logger.

Returns:
The default logger.

getLogChannel

public static LogChannel getLogChannel()
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.

getLogChannel

public static LogChannel getLogChannel(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.


isDodsConfigured

protected static boolean isDodsConfigured()
Returns:
Returns the dodsConfigured.

setDodsConfigured

protected static void setDodsConfigured(boolean configured)
Parameters:
configured - The dodsConfigured to set.

DODS 7.3 API