edu.ucsb.adl.middleware
Class Global

java.lang.Object
  |
  +--edu.ucsb.adl.middleware.Global

public final class Global
extends java.lang.Object

Stores global quantities and performs global initializations. In the context of the middleware, "global" means pertaining to a middleware instance as a whole; a middleware "instance" is represented by an instance of this class and zero or more instances of service classes, all of which are tied to the same root middleware configuration file. Use of this class allows multiple middleware instances to run simultaneously in the same Java VM.

All middleware service objects maintain a reference to the global object representing the services' middleware instance.

This class also performs certain one-time initializations.

This class reads the following properties from main middleware configuration files. Property values may be indirectly specified using the notation @P where P is the name of another property (see ExtendedProperties for more information).

jython.home
The pathname of Jython's home directory, i.e., the directory in which Jython looks for its registry file, built-in modules, etc. If the pathname is not absolute, it is interpreted relative to the directory containing the main middleware configuration file. Note that, if the value of this property is D, Jython automatically looks for built-in modules in directory D/Lib. This property is read only once.
jython.cachedir
The pathname of the directory in which Jython caches package synopses. If the pathname is not absolute, it is interpreted relative to jython.home. As a special case, if the value of this property has the form "SYSTEM_PROPERTY(S)" (e.g., "SYSTEM_PROPERTY(java.io.tmpdir)"), the value of Java system property S is used. This property is read only once.
jython.module_path
A pathlist of zero or more directories in which additional Jython modules may be found, e.g., "../modules:/otherdir/lib". The pathlist is appended to Jython's python.path registry variable. Directories that are not absolute are interpreted relative to the directory containing the main middleware configuration file.
jython.class_path
A pathlist of zero or more directories in which Java class files referenced by Jython may be found, e.g., "../classes". Directories that are not absolute are interpreted relative to the directory containing the main middleware configuration file.
jython.jar_path
A pathlist of zero or more directories in which JAR files referenced by Jython may be found, e.g., "../lib". Directories that are not absolute are interpreted relative to the directory containing the main middleware configuration file.

Version:
$Header: /export/home/gjanee/middleware/edu/ucsb/adl/middleware/RCS/Global.java,v 1.5 2006/06/22 19:14:54 gjanee Exp $

$Log: Global.java,v $ Revision 1.5 2006/06/22 19:14:54 gjanee
Added method getConfigurationFile.

Revision 1.4 2004/09/21 23:53:43 gjanee
Minor documentation change.

Revision 1.3 2004/09/14 21:11:24 gjanee
Added the Jython initializations formerly performed by class edu.ucsb.adl.bucket99.PythonQueryTranslator. Added properties jython.module_path, jython.class_path, and jython.jar_path.

Revision 1.2 2004/03/09 05:50:00 gjanee
Added Jython initialization. Added properties jython.home and jython.cachedir.

Revision 1.1 2004/03/04 00:43:42 gjanee
Initial revision

Author:
Greg Janée
Alexandria Digital Library

Method Summary
static edu.ucsb.adl.middleware.Global createGlobal(java.lang.String configurationFile)
          Creates a Global object representing a middleware instance.
 void destroy()
          Decrements the reference count.
 java.lang.String getConfigurationFile()
          Returns the name of the main middleware configuration file associated with this Global object.
 java.util.Hashtable getHashtableVariable(java.lang.String name)
          Returns the value of a global variable that is a Hashtable.
 java.lang.Object getVariable(java.lang.String name)
          Returns the value of a global variable.
 java.util.Vector getVectorVariable(java.lang.String name)
          Returns the value of a global variable that is a Vector.
 void putVariable(java.lang.String name, java.lang.Object value)
          Sets the value of a global variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createGlobal

public static edu.ucsb.adl.middleware.Global createGlobal(java.lang.String configurationFile)
                                                   throws InternalErrorException
Creates a Global object representing a middleware instance. If an object already exists for the configuration file, i.e., if the middleware instance already exists, the extant object's reference count is incremented and it is returned instead.

Parameters:
configurationFile - The filename of a main middleware configuration file.
Throws:
InternalErrorException - If any global or one-time initializations fail.

getConfigurationFile

public java.lang.String getConfigurationFile()
Returns the name of the main middleware configuration file associated with this Global object.

Returns:
The filename.

getVariable

public java.lang.Object getVariable(java.lang.String name)
Returns the value of a global variable. By convention, global variable names are prefixed with the fully-qualified name of the owning class and a colon, e.g., "edu.ucsb.adl.middleware.RankingAccumulator:rankers". Also by convention, a class may set and retrieve values only for global variables it owns.

Parameters:
name - The variable name.
Returns:
The variable's value, or null if not assigned.

getHashtableVariable

public java.util.Hashtable getHashtableVariable(java.lang.String name)
Returns the value of a global variable that is a Hashtable. If the variable has not been assigned, it is assigned an empty Hashtable, which is then returned.

By convention, global variable names are prefixed with the fully-qualified name of the owning class and a colon, e.g., "edu.ucsb.adl.middleware.RankingAccumulator:rankers". Also by convention, a class may set and retrieve values only for global variables it owns.

Parameters:
name - The variable name.
Returns:
The variable's value.

getVectorVariable

public java.util.Vector getVectorVariable(java.lang.String name)
Returns the value of a global variable that is a Vector. If the variable has not been assigned, it is assigned an empty Vector, which is then returned.

By convention, global variable names are prefixed with the fully-qualified name of the owning class and a colon, e.g., "edu.ucsb.adl.middleware.RankingAccumulator:rankers". Also by convention, a class may set and retrieve values only for global variables it owns.

Parameters:
name - The variable name.
Returns:
The variable's value.

putVariable

public void putVariable(java.lang.String name,
                        java.lang.Object value)
Sets the value of a global variable. By convention, global variable names are prefixed with the fully-qualified name of the owning class and a colon, e.g., "edu.ucsb.adl.middleware.RankingAccumulator:rankers". Also by convention, a class may set and retrieve values only for global variables it owns.

Parameters:
name - The variable name.
value - The variable's value.

destroy

public void destroy()
Decrements the reference count. When the reference count drops to zero, all resources held by this object, i.e., by the middleware instance, are freed.