com.ibm.pvccommon.util
Class DatabaseFactory

java.lang.Object
  |
  +--com.ibm.pvccommon.util.DatabaseFactory

public class DatabaseFactory
extends java.lang.Object

An abstract factory, one per application, that encapsulates knowledge about what kind of databases are being used with this running version of the application. Any class that needs to open a database asks this class for a reference to it. Depending on how it was created, the factory will return either an IniDatabase, which is stored in the local file system, or an OrionR2Database, which uses Orion APIs to store information. The abstract factory defaults to using IniDatabases. To switch to a different type, some class, such as the root servlet or application, should call the setDatabaseType() method to switch it.


Inner Class Summary
static class DatabaseFactory.Type
          Indicator of database type, and defined values.
 
Field Summary
static java.lang.String COPYRIGHT
          IBM copyright information.
protected static java.lang.String instance
          The instance ID of the databases.
static DatabaseFactory.Type LOCAL_DATABASE
           
static DatabaseFactory.Type ORION_DATABASE
           
protected static java.lang.String purpose
          The purpose of these databases.
protected static java.lang.String server
          The server name used for the server context.
 
Constructor Summary
DatabaseFactory()
           
 
Method Summary
static void clearCache()
          Clear the database cache.
static void deleteDatabase(java.lang.String dbName, Database.ResourceType type)
          Delete the database instance of the appropriate type corresponding to a given name and type.
static Database getDatabase(java.lang.String dbName, Database.ResourceType type)
          Acquire the database instance of the appropriate type corresponding to a given name and type.
static void setDatabaseType(DatabaseFactory.Type type)
          Set the database type to the given predefined database type
static void setHomeKey(java.lang.String s)
          Set the Home key.The Home key is the key to used with Sys.properties to acquire the root directory of the application.
static void setInstanceID(java.lang.String instID)
          Modify the instance ID used to construct database names.
static void setPurpose(java.lang.String inPurpose)
          Modify the purpose value which is used by the various database types to construct names (e.g., of directories or preference contexts
static void setServer(java.lang.String name)
          Modify the server name to be used in getting the server resource context
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
IBM copyright information.

LOCAL_DATABASE

public static final DatabaseFactory.Type LOCAL_DATABASE

ORION_DATABASE

public static final DatabaseFactory.Type ORION_DATABASE

purpose

protected static java.lang.String purpose
The purpose of these databases. The calling application needs to set the value for this variable if for non-transproxy purposes to guarantee no name conflicts between different applications using the same set of classes.

instance

protected static java.lang.String instance
The instance ID of the databases. The calling application needs to set the value for this variable if the default instance ID ("") is not to be used. Instance ID supports multiple transproxies running against the same Orion server.

server

protected static java.lang.String server
The server name used for the server context. The calling application needs to set the value for if a server context is needed rather than a user or user-group context. It should be set BEFORE the first server context is needed. "localhost" probably will NOT work for all situations, so the application should set it to something more appropriate (i.e. a real fully qualified server name).
Constructor Detail

DatabaseFactory

public DatabaseFactory()
Method Detail

setDatabaseType

public static void setDatabaseType(DatabaseFactory.Type type)
Set the database type to the given predefined database type
Parameters:
type - DatabaseFactory.Type specifying the database type

setHomeKey

public static void setHomeKey(java.lang.String s)
Set the Home key.The Home key is the key to used with Sys.properties to acquire the root directory of the application. This is particularly needed by IniDatabase.
Parameters:
s - the string to set as the home key

getDatabase

public static Database getDatabase(java.lang.String dbName,
                                   Database.ResourceType type)
                            throws MissingRequiredResourceException
Acquire the database instance of the appropriate type corresponding to a given name and type.
Parameters:
dbName - the database name
type - the resource type
Returns:
Database the requested database
Throws:
MissingRequiredResourceException -  

deleteDatabase

public static void deleteDatabase(java.lang.String dbName,
                                  Database.ResourceType type)
                           throws MissingRequiredResourceException
Delete the database instance of the appropriate type corresponding to a given name and type.
Parameters:
dbName - the database name
type - the resource type
Throws:
MissingRequiredResourceException -  

clearCache

public static void clearCache()
Clear the database cache. (To be used possibly at servlet initialiation or destruction time.)

setPurpose

public static void setPurpose(java.lang.String inPurpose)
Modify the purpose value which is used by the various database types to construct names (e.g., of directories or preference contexts
Parameters:
inPurpose - string to identify purpose of this context

setInstanceID

public static void setInstanceID(java.lang.String instID)
Modify the instance ID used to construct database names.
Parameters:
instID - string to identify the instance ID

setServer

public static void setServer(java.lang.String name)
Modify the server name to be used in getting the server resource context
Parameters:
name - fully qualified name of server