de.mathema.pride
Class DatabaseFactory

java.lang.Object
  extended by de.mathema.pride.DatabaseFactory

public class DatabaseFactory
extends java.lang.Object

Factory class to instantiate Database objects. All operations refer to a working context which can be switched by the setContext function. Contexts are used to identify multiple database access schemes, defined by a database name, a resource accessor, and an exception listener. This allows e.g. to serve multiple databases in an application or different types of connections to one database. RecordDescriptors may get passed a context identified to express an association of an entity type to a particular database access scheme. There is one Database object created by context. There is always at least one context available by default which is identified by DEFAULT_CONTEXT.

Author:
Jan Lessner

Field Summary
static java.lang.String DEFAULT_CONTEXT
           
static java.lang.String REVISION_ID
           
 
Method Summary
static java.lang.String getContext()
          Returns the name of the current database context
static Database getDatabase()
          Returns the Database instance of the current context
static Database getDatabase(java.lang.String contextName)
          Returns the Database instance of the specified context.
static ResourceAccessor getResourceAccessor()
          Returns the current context's ResourceAccessor
static Database setContext(java.lang.String name)
          Makes the specified context the current one and returns the context's Database instance.
static void setDatabaseName(java.lang.String dbname)
          Sets the database name for the current context to be used for Database instantiation in getDatabase.
static void setExceptionListener(ExceptionListener el)
          Sets the ExceptionListener for the current context to be used for Database instantiation in getDatabase.
static void setResourceAccessor(ResourceAccessor val)
          Sets the current context's ResourceAccessor to be used for Database instantiation in getDatabase.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CONTEXT

public static final java.lang.String DEFAULT_CONTEXT
See Also:
Constant Field Values

REVISION_ID

public static final java.lang.String REVISION_ID
See Also:
Constant Field Values
Method Detail

setResourceAccessor

public static void setResourceAccessor(ResourceAccessor val)
Sets the current context's ResourceAccessor to be used for Database instantiation in getDatabase.


getResourceAccessor

public static ResourceAccessor getResourceAccessor()
Returns the current context's ResourceAccessor


setDatabaseName

public static void setDatabaseName(java.lang.String dbname)
Sets the database name for the current context to be used for Database instantiation in getDatabase.


setExceptionListener

public static void setExceptionListener(ExceptionListener el)
Sets the ExceptionListener for the current context to be used for Database instantiation in getDatabase.


getDatabase

public static Database getDatabase()
Returns the Database instance of the current context


getDatabase

public static Database getDatabase(java.lang.String contextName)
Returns the Database instance of the specified context.

Parameters:
contextName - The context to refer to with identifying the current context.

setContext

public static Database setContext(java.lang.String name)
Makes the specified context the current one and returns the context's Database instance. If the context doesn't exist yet, it is created and the function returns null. identifies the current context and thus causes no context switch.


getContext

public static java.lang.String getContext()
Returns the name of the current database context