fedora.server
Class Server

java.lang.Object
  extended byfedora.server.Parameterized
      extended byfedora.server.Pluggable
          extended byfedora.server.Server
All Implemented Interfaces:
Logging
Direct Known Subclasses:
BasicServer

public abstract class Server
extends Pluggable
implements Logging

Title: Server.java

Description:

The starting point for working with a Fedora repository.This class handles loading, starting, and stopping modules (the module lifecycle), and provides access to core constants.

The Server class itself is abstract - it may not be instantiated. Instead, it provides an instance of the Server subclass specified in the configuration file. (see CONFIG_DIR and CONFIG_FILE)

Example Use

The following program illustrates use of the Server class.
 import fedora.server.Server;

 /**
  * Starts, then shuts down the server.
  */
 public class ServerTest {

     public static void main(String[] args) {
         try {
             Server s=Server.getInstance(System.getProperty(
                     Server.HOME_PROPERTY));
             s.shutdown();
         } catch (Exception e) {
             System.out.println("Error: " + e.getMessage());
         }
     }
 }
 

Core Constants

All constants for the core Fedora classes are set within the fedora/server/resources/Server.properties file*, and are available as static fields of this class. Non-core and extension classes may use an entirely different scheme for their own constants, and must at least use a different file.

There are two types of core constants:

* Or a locale-specific version thereof. Note that only localizable constants (messages) may change across locales.

Messages are named using the following convention:

execpoint.messagetype.errname

where execpoint is composed of phase[subphase.[subphase.(...)]]

Phase is a short string intended to show at which point in the server's execution the condition described by the message occurs. Subphase is a sub-categorization of a phase. For example, init.config and init.server are subphases of the init phase.

 Phase/Subphase       Description
 --------------       -----------
 init                 Server initialization
 init.xmlparser       XML parser initialization
 init.config          Reading and validating configuration file
 init.server          Initializing the server implementation
 init.module          Initializing a module
 storage              In the storage subsystem
 api                  Server front-end
 shutdown.server      Shutting down the server
 shutdown.module      Shutting down a module
 
There are several possible message types, described below. These coincide with jdk1.4's new java.util.logging package's log levels.
 MessageType          Description
 -----------          -----------
 severe               Errors that render the server inoperable or prevent
                      it from starting up in the first place.
 warning              Errors that signal an undesired condition, but may be
                      recovered from.
 info                 Interesting events that don't occur often, such as
                      Server and Module startup and shutdown.
 config               Significant Server or Module configuration steps.
 fine                 Request hosts and operations, success or fail.
 finer                Full request, response, and timing information.
 finest               Method entry and exit, and extremely verbose messages,
                      for debugging.
 

Version:
$Id: Server.java,v 1.45 2005/09/16 16:08:02 cwilper Exp $
Author:
cwilper@cs.cornell.edu

Field Summary
static java.lang.String BIN_DIR
          The directory where server executables are stored, relative to home.
static java.lang.String BUILD_NUMBER
          The build number of this release.
static java.lang.String CONFIG_ATTRIBUTE_CLASS
          The configuration file's class-specifying attribute for server and module elements.
static java.lang.String CONFIG_ATTRIBUTE_ID
          The configuration file datastore element's id attribute.
static java.lang.String CONFIG_ATTRIBUTE_NAME
          The configuration file param element's name attribute.
static java.lang.String CONFIG_ATTRIBUTE_ROLE
          The configuration file's role-specifying attribute for module elements.
static java.lang.String CONFIG_ATTRIBUTE_VALUE
          The configuration file param element's value attribute.
static java.lang.String CONFIG_DIR
          The directory where server configuration is stored, relative to home.
static java.lang.String CONFIG_ELEMENT_COMMENT
          The configuration file comment element's name.
static java.lang.String CONFIG_ELEMENT_DATASTORE
          The configuration file datastore element's name.
static java.lang.String CONFIG_ELEMENT_MODULE
          The configuration file module element's name.
static java.lang.String CONFIG_ELEMENT_PARAM
          The configuration file param element's name.
static java.lang.String CONFIG_ELEMENT_ROOT
          The configuration file root element's name.
static java.lang.String CONFIG_FILE
          The configuration filename.
static java.lang.String CONFIG_NAMESPACE
          The configuration file elements' namespace. 0={namespace.prefix}
static java.lang.String DEFAULT_SERVER_CLASS
          The name of the default Server implementation class
static java.lang.String EXTENSION_DIR
          The directory where server extensions are stored, relative to home.
static boolean GLOBAL_CHOICE
           
static java.lang.String HOME_PROPERTY
          The name of the property that tells the server where it's based.
static java.lang.String INIT_CONFIG_CONFIG_EXAMININGELEMENT
          Tells which config element is being looked at in order to load its parameters into memory. 0=name of element being examined, 1=distinguishing attribute (name="value"), or empty string if no distinguishing attribute.
static java.lang.String INIT_CONFIG_CONFIG_PARAMETERIS
          Tells the name and value of a parameter loaded from the config file. 0=param name, 1=param value
static java.lang.String INIT_CONFIG_SEVERE_BADELEMENT
          Indicates that an invalid element was found in the configuration xml. 1=the invalid element's name
static java.lang.String INIT_CONFIG_SEVERE_BADNAMESPACE
          Indicates that the config file's element's namespace does not match {config.namespace}. 0=config file full path, 1={config.namespace}
static java.lang.String INIT_CONFIG_SEVERE_BADROOTELEMENT
          Indicates that the config file has a mis-named root element. 0=config file full path, 1={config.element.root}, 2=actual root element name
static java.lang.String INIT_CONFIG_SEVERE_INCOMPLETEPARAM
          Indicates that a parameter element in the config file is missing a required element. 0={config.element.param}, 1={config.attribute.name}, 2={config.attribute.value}
static java.lang.String INIT_CONFIG_SEVERE_MALFORMEDXML
          Indicates that the config file has malformed XML. 0=config file full path, 1=additional info from underlying exception
static java.lang.String INIT_CONFIG_SEVERE_NOCLASSGIVEN
          Indicates that a module element in the server configuration did not specify an implementing class, but should. 0={config.element.module}, 1={config.attribute.class}
static java.lang.String INIT_CONFIG_SEVERE_NOIDGIVEN
          Indicates that a CONFIG_ELEMENT_DATASTORE didn't specify the required CONFIG_ATTRIBUTE_ID. 0={config.element.datastore}, 1={config.attribute.id}
static java.lang.String INIT_CONFIG_SEVERE_NOROLEGIVEN
          Indicates that a module element in the server configuration did not specify a role, but should. 0={config.element.module}, 1={config.attribute.role}
static java.lang.String INIT_CONFIG_SEVERE_REASSIGNMENT
          Indicates that an attribute of an element was assigned the same value as a previously specified element's attribute, and that this constitutes a disallowed reassignment. 0=the common element, 1=the common attribute's name, 2=the common attribute's value.
static java.lang.String INIT_CONFIG_SEVERE_UNREADABLE
          Indicates that the config file could not be read. 0=config file full path, 1=additional info from underlying exception
static java.lang.String INIT_LOG_WARNING_CANTWRITESTARTUPLOG
          Indicates that the startup log could not be written to its usual place for some reason, and that we're falling back to stderr. 0=usual place, 1=exception message
static java.lang.String INIT_MODULE_SEVERE_BADARGS
          Indicates that the module class constructor was invoked improperly due to programmer error. 0=module class specified in config
static java.lang.String INIT_MODULE_SEVERE_CLASSNOTFOUND
          Indicates that the module class could not be found. 0=module class specified in config
static java.lang.String INIT_MODULE_SEVERE_ILLEGALACCESS
          Indicates that the module class couldn't be accessed due to security misconfiguration. 0=module class specified in config
static java.lang.String INIT_MODULE_SEVERE_ISABSTRACT
          Indicates that the module class was abstract, but shouldn't be. 0=module class specified in config
static java.lang.String INIT_MODULE_SEVERE_MISSINGCONSTRUCTOR
          Indicates that the module class doesn't have a constructor matching Module(Map, Server, String), but needs one. 0=module class specified in config
static java.lang.String INIT_MODULE_SEVERE_UNFULFILLEDROLE
           
static java.lang.String INIT_SERVER_SEVERE_BADARGS
          Indicates that the server class constructor was invoked improperly due to programmer error. 0=server class specified in config root element
static java.lang.String INIT_SERVER_SEVERE_CLASSNOTFOUND
          Indicates that the server class could not be found. 0=server class specified in config root element
static java.lang.String INIT_SERVER_SEVERE_ILLEGALACCESS
          Indicates that the server class couldn't be accessed due to security misconfiguration. 0=server class specified in config root element
static java.lang.String INIT_SERVER_SEVERE_ISABSTRACT
          Indicates that the server class was abstract, but shouldn't be. 0=server class specified in config root element
static java.lang.String INIT_SERVER_SEVERE_MISSINGCONSTRUCTOR
          Indicates that the server class doesn't have a constructor matching Server(NodeList, File), but needs one. 0=server class specified in config root element.
static java.lang.String INIT_SERVER_SEVERE_UNFULFILLEDROLE
          Indicates that a module role required to be fulfilled by this server was not fulfilled because the configuration did not specify a module with that role. 0=the role
static java.lang.String INIT_XMLPARSER_SEVERE_MISSING
          Indicates that an XML parser could not be found.
static java.lang.String LOG_DIR
          The default directory where the server logs are stored.
static java.lang.String LOG_STARTUP_FILE
          The startup log file.
static java.lang.String MODULE_CONSTRUCTOR_PARAM1_CLASS
          The required module constructor's first parameter's class.
static java.lang.String MODULE_CONSTRUCTOR_PARAM2_CLASS
          The required module constructor's second parameter's class.
static java.lang.String MODULE_CONSTRUCTOR_PARAM3_CLASS
          The required module constructor's third parameter's class.
static java.lang.String NAMESPACE_PREFIX
          The prefix to all fedora-defined namespaces for this version. 0={version.major}, 1={version.minor}
protected static java.util.HashMap s_instances
          Holds an instance of a Server for each distinct File given as a parameter to getInstance(...)
static java.lang.String SERVER_CONSTRUCTOR_PARAM1_CLASS
          The required server constructor's first parameter's class.
static java.lang.String SERVER_CONSTRUCTOR_PARAM2_CLASS
          The required server constructor's second parameter's class.
static java.lang.String STORAGE_FORMAT
          The internal XML storage format for digital objects
static boolean USE_CACHE
           
static boolean USE_DEFINITIVE_STORE
           
static java.lang.String VERSION_MAJOR
          The major version of this release.
static java.lang.String VERSION_MINOR
          The minor version of this release.
 
Constructor Summary
protected Server(org.w3c.dom.Element rootConfigElement, java.io.File homeDir)
          Initializes the Server based on configuration.
 
Method Summary
 void closeLogger()
          Flushes, then closes any resources tied up by the Handler(s) associated with the Logger and sets the logger to null.
 java.util.Iterator datastoreConfigIds()
           
 void finalize()
          Calls shutdown() when finalization occurs.
 void flushLogger()
          Flushes any buffered log messages in the Logger's Handler(s).
 java.lang.String getConfigSummary()
           
 DatastoreConfig getDatastoreConfig(java.lang.String id)
          Gets a DatastoreConfig.
 java.io.File getHomeDir()
          Gets the server's home directory.
static Server getInstance(java.io.File homeDir)
          Provides an instance of the server specified in the configuration file at homeDir/CONFIG_DIR/CONFIG_FILE, or DEFAULT_SERVER_CLASS if unspecified.
static Server getInstance(java.io.File homeDir, boolean okToStart)
           
static java.util.Locale getLocale()
           
 Module getModule(java.lang.String role)
          Gets a loaded Module.
static PID getPID(java.lang.String pidString)
           
 boolean hasInitialized()
          Tells whether the server (and loaded modules) have initialized.
static boolean hasInstance(java.io.File homeDir)
           
protected  void initServer()
          Performs any server start-up tasks particular to this type of Server.
 java.util.Iterator loadedModuleRoles()
          Gets an Iterator over the roles that have been loaded.
 void logConfig(java.lang.String message)
          Logs a CONFIG message, indicating what occurred during the server's (or a module's) configuration phase.
 void logFine(java.lang.String message)
          Logs a FINE message, indicating basic information about a request to the server (like hostname, operation name, and success or failure).
 void logFiner(java.lang.String message)
          Logs a FINER message, indicating detailed information about a request to the server (like the full request, full response, and timing information).
 void logFinest(java.lang.String message)
          Logs a FINEST message, indicating method entry/exit or extremely verbose information intended to aid in debugging.
 boolean loggingConfig()
           
 boolean loggingFine()
           
 boolean loggingFiner()
           
 boolean loggingFinest()
           
 boolean loggingInfo()
           
 boolean loggingSevere()
           
 boolean loggingWarning()
           
 void logInfo(java.lang.String message)
          Logs an INFO message, indicating that something relatively uncommon and interesting happened, like server or module startup or shutdown, or a periodic job.
 void logSevere(java.lang.String message)
          Logs a SEVERE message, indicating that the server is inoperable or unable to start.
 void logWarning(java.lang.String message)
          Logs a WARNING message, indicating that an undesired (but non-fatal) condition occured.
protected  java.lang.String overrideModuleClass(java.lang.String moduleClass)
           
protected  boolean overrideModuleRole(java.lang.String moduleRole)
           
static PID pidFromFilename(java.lang.String filename)
           
protected  void postInitServer()
          Second stage of Server initialization.
protected  void setLogger(java.util.logging.Logger newLogger)
          Sets the Logger to which log messages are sent.
 void shutdown(Context context)
          Performs shutdown tasks for the modules and the server.
protected  void shutdownServer()
          Performs shutdown tasks for the server itself.
 java.lang.String status(Context context)
           
 
Methods inherited from class fedora.server.Pluggable
getHelp, getOptionalParameters, getParameterHelp, getRequiredModuleRoles, getRequiredParameters
 
Methods inherited from class fedora.server.Parameterized
getParameter, getParameters, parameterNames, setParameter, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USE_CACHE

public static final boolean USE_CACHE
See Also:
Constant Field Values

USE_DEFINITIVE_STORE

public static final boolean USE_DEFINITIVE_STORE
See Also:
Constant Field Values

GLOBAL_CHOICE

public static final boolean GLOBAL_CHOICE
See Also:
Constant Field Values

VERSION_MAJOR

public static java.lang.String VERSION_MAJOR
The major version of this release.


VERSION_MINOR

public static java.lang.String VERSION_MINOR
The minor version of this release.


BUILD_NUMBER

public static java.lang.String BUILD_NUMBER
The build number of this release.


HOME_PROPERTY

public static java.lang.String HOME_PROPERTY
The name of the property that tells the server where it's based.


STORAGE_FORMAT

public static java.lang.String STORAGE_FORMAT
The internal XML storage format for digital objects


CONFIG_DIR

public static java.lang.String CONFIG_DIR
The directory where server configuration is stored, relative to home.


LOG_DIR

public static java.lang.String LOG_DIR
The default directory where the server logs are stored. This directory should always exist because the startup log is written here, even if logs are written elsewhere by a Server subclass.


LOG_STARTUP_FILE

public static java.lang.String LOG_STARTUP_FILE
The startup log file. This file will include all log messages regardless of their Level.


CONFIG_FILE

public static java.lang.String CONFIG_FILE
The configuration filename.


EXTENSION_DIR

public static java.lang.String EXTENSION_DIR
The directory where server extensions are stored, relative to home.


BIN_DIR

public static java.lang.String BIN_DIR
The directory where server executables are stored, relative to home.


NAMESPACE_PREFIX

public static java.lang.String NAMESPACE_PREFIX
The prefix to all fedora-defined namespaces for this version. 0={version.major}, 1={version.minor}


CONFIG_NAMESPACE

public static java.lang.String CONFIG_NAMESPACE
The configuration file elements' namespace. 0={namespace.prefix}


CONFIG_ELEMENT_ROOT

public static java.lang.String CONFIG_ELEMENT_ROOT
The configuration file root element's name.


CONFIG_ELEMENT_COMMENT

public static java.lang.String CONFIG_ELEMENT_COMMENT
The configuration file comment element's name.


CONFIG_ELEMENT_DATASTORE

public static java.lang.String CONFIG_ELEMENT_DATASTORE
The configuration file datastore element's name.


CONFIG_ELEMENT_MODULE

public static java.lang.String CONFIG_ELEMENT_MODULE
The configuration file module element's name.


CONFIG_ELEMENT_PARAM

public static java.lang.String CONFIG_ELEMENT_PARAM
The configuration file param element's name.


CONFIG_ATTRIBUTE_CLASS

public static java.lang.String CONFIG_ATTRIBUTE_CLASS
The configuration file's class-specifying attribute for server and module elements.


CONFIG_ATTRIBUTE_ROLE

public static java.lang.String CONFIG_ATTRIBUTE_ROLE
The configuration file's role-specifying attribute for module elements.


CONFIG_ATTRIBUTE_NAME

public static java.lang.String CONFIG_ATTRIBUTE_NAME
The configuration file param element's name attribute.


CONFIG_ATTRIBUTE_VALUE

public static java.lang.String CONFIG_ATTRIBUTE_VALUE
The configuration file param element's value attribute.


CONFIG_ATTRIBUTE_ID

public static java.lang.String CONFIG_ATTRIBUTE_ID
The configuration file datastore element's id attribute.


SERVER_CONSTRUCTOR_PARAM1_CLASS

public static java.lang.String SERVER_CONSTRUCTOR_PARAM1_CLASS
The required server constructor's first parameter's class.


SERVER_CONSTRUCTOR_PARAM2_CLASS

public static java.lang.String SERVER_CONSTRUCTOR_PARAM2_CLASS
The required server constructor's second parameter's class.


MODULE_CONSTRUCTOR_PARAM1_CLASS

public static java.lang.String MODULE_CONSTRUCTOR_PARAM1_CLASS
The required module constructor's first parameter's class.


MODULE_CONSTRUCTOR_PARAM2_CLASS

public static java.lang.String MODULE_CONSTRUCTOR_PARAM2_CLASS
The required module constructor's second parameter's class.


MODULE_CONSTRUCTOR_PARAM3_CLASS

public static java.lang.String MODULE_CONSTRUCTOR_PARAM3_CLASS
The required module constructor's third parameter's class.


DEFAULT_SERVER_CLASS

public static java.lang.String DEFAULT_SERVER_CLASS
The name of the default Server implementation class


INIT_XMLPARSER_SEVERE_MISSING

public static java.lang.String INIT_XMLPARSER_SEVERE_MISSING
Indicates that an XML parser could not be found.


INIT_CONFIG_SEVERE_UNREADABLE

public static java.lang.String INIT_CONFIG_SEVERE_UNREADABLE
Indicates that the config file could not be read. 0=config file full path, 1=additional info from underlying exception


INIT_CONFIG_SEVERE_MALFORMEDXML

public static java.lang.String INIT_CONFIG_SEVERE_MALFORMEDXML
Indicates that the config file has malformed XML. 0=config file full path, 1=additional info from underlying exception


INIT_CONFIG_SEVERE_BADROOTELEMENT

public static java.lang.String INIT_CONFIG_SEVERE_BADROOTELEMENT
Indicates that the config file has a mis-named root element. 0=config file full path, 1={config.element.root}, 2=actual root element name


INIT_CONFIG_SEVERE_BADELEMENT

public static java.lang.String INIT_CONFIG_SEVERE_BADELEMENT
Indicates that an invalid element was found in the configuration xml. 1=the invalid element's name


INIT_CONFIG_SEVERE_NOIDGIVEN

public static java.lang.String INIT_CONFIG_SEVERE_NOIDGIVEN
Indicates that a CONFIG_ELEMENT_DATASTORE didn't specify the required CONFIG_ATTRIBUTE_ID. 0={config.element.datastore}, 1={config.attribute.id}


INIT_CONFIG_SEVERE_BADNAMESPACE

public static java.lang.String INIT_CONFIG_SEVERE_BADNAMESPACE
Indicates that the config file's element's namespace does not match {config.namespace}. 0=config file full path, 1={config.namespace}


INIT_CONFIG_SEVERE_NOROLEGIVEN

public static java.lang.String INIT_CONFIG_SEVERE_NOROLEGIVEN
Indicates that a module element in the server configuration did not specify a role, but should. 0={config.element.module}, 1={config.attribute.role}


INIT_CONFIG_SEVERE_NOCLASSGIVEN

public static java.lang.String INIT_CONFIG_SEVERE_NOCLASSGIVEN
Indicates that a module element in the server configuration did not specify an implementing class, but should. 0={config.element.module}, 1={config.attribute.class}


INIT_CONFIG_SEVERE_REASSIGNMENT

public static java.lang.String INIT_CONFIG_SEVERE_REASSIGNMENT
Indicates that an attribute of an element was assigned the same value as a previously specified element's attribute, and that this constitutes a disallowed reassignment. 0=the common element, 1=the common attribute's name, 2=the common attribute's value.


INIT_CONFIG_SEVERE_INCOMPLETEPARAM

public static java.lang.String INIT_CONFIG_SEVERE_INCOMPLETEPARAM
Indicates that a parameter element in the config file is missing a required element. 0={config.element.param}, 1={config.attribute.name}, 2={config.attribute.value}


INIT_CONFIG_CONFIG_EXAMININGELEMENT

public static java.lang.String INIT_CONFIG_CONFIG_EXAMININGELEMENT
Tells which config element is being looked at in order to load its parameters into memory. 0=name of element being examined, 1=distinguishing attribute (name="value"), or empty string if no distinguishing attribute.


INIT_CONFIG_CONFIG_PARAMETERIS

public static java.lang.String INIT_CONFIG_CONFIG_PARAMETERIS
Tells the name and value of a parameter loaded from the config file. 0=param name, 1=param value


INIT_SERVER_SEVERE_CLASSNOTFOUND

public static java.lang.String INIT_SERVER_SEVERE_CLASSNOTFOUND
Indicates that the server class could not be found. 0=server class specified in config root element


INIT_SERVER_SEVERE_ILLEGALACCESS

public static java.lang.String INIT_SERVER_SEVERE_ILLEGALACCESS
Indicates that the server class couldn't be accessed due to security misconfiguration. 0=server class specified in config root element


INIT_SERVER_SEVERE_BADARGS

public static java.lang.String INIT_SERVER_SEVERE_BADARGS
Indicates that the server class constructor was invoked improperly due to programmer error. 0=server class specified in config root element


INIT_SERVER_SEVERE_MISSINGCONSTRUCTOR

public static java.lang.String INIT_SERVER_SEVERE_MISSINGCONSTRUCTOR
Indicates that the server class doesn't have a constructor matching Server(NodeList, File), but needs one. 0=server class specified in config root element.


INIT_SERVER_SEVERE_UNFULFILLEDROLE

public static java.lang.String INIT_SERVER_SEVERE_UNFULFILLEDROLE
Indicates that a module role required to be fulfilled by this server was not fulfilled because the configuration did not specify a module with that role. 0=the role


INIT_MODULE_SEVERE_UNFULFILLEDROLE

public static java.lang.String INIT_MODULE_SEVERE_UNFULFILLEDROLE

INIT_SERVER_SEVERE_ISABSTRACT

public static java.lang.String INIT_SERVER_SEVERE_ISABSTRACT
Indicates that the server class was abstract, but shouldn't be. 0=server class specified in config root element


INIT_MODULE_SEVERE_CLASSNOTFOUND

public static java.lang.String INIT_MODULE_SEVERE_CLASSNOTFOUND
Indicates that the module class could not be found. 0=module class specified in config


INIT_MODULE_SEVERE_ILLEGALACCESS

public static java.lang.String INIT_MODULE_SEVERE_ILLEGALACCESS
Indicates that the module class couldn't be accessed due to security misconfiguration. 0=module class specified in config


INIT_MODULE_SEVERE_BADARGS

public static java.lang.String INIT_MODULE_SEVERE_BADARGS
Indicates that the module class constructor was invoked improperly due to programmer error. 0=module class specified in config


INIT_MODULE_SEVERE_MISSINGCONSTRUCTOR

public static java.lang.String INIT_MODULE_SEVERE_MISSINGCONSTRUCTOR
Indicates that the module class doesn't have a constructor matching Module(Map, Server, String), but needs one. 0=module class specified in config


INIT_MODULE_SEVERE_ISABSTRACT

public static java.lang.String INIT_MODULE_SEVERE_ISABSTRACT
Indicates that the module class was abstract, but shouldn't be. 0=module class specified in config


INIT_LOG_WARNING_CANTWRITESTARTUPLOG

public static java.lang.String INIT_LOG_WARNING_CANTWRITESTARTUPLOG
Indicates that the startup log could not be written to its usual place for some reason, and that we're falling back to stderr. 0=usual place, 1=exception message


s_instances

protected static java.util.HashMap s_instances
Holds an instance of a Server for each distinct File given as a parameter to getInstance(...)

Constructor Detail

Server

protected Server(org.w3c.dom.Element rootConfigElement,
                 java.io.File homeDir)
          throws ServerInitializationException,
                 ModuleInitializationException
Initializes the Server based on configuration.

Reads and schema-validates the configuration items in the given DOM NodeList, validates required server params, initializes the Server, then initializes each module, validating its required params, then verifies that the server's required module roles have been met.

Parameters:
rootConfigElement - The root Element of configuration.
homeDir - The home directory of fedora, used to interpret relative paths used in configuration.
Throws:
ServerInitializationException - If there was an error starting the server.
ModuleInitializationException - If there was an error starting a module.
Method Detail

overrideModuleRole

protected boolean overrideModuleRole(java.lang.String moduleRole)

overrideModuleClass

protected java.lang.String overrideModuleClass(java.lang.String moduleClass)

hasInitialized

public final boolean hasInitialized()
Tells whether the server (and loaded modules) have initialized.

This is useful for threaded Modules that need to wait until all initialization has occurred before doing something.

Returns:
whether initialization has completed.

logSevere

public final void logSevere(java.lang.String message)
Logs a SEVERE message, indicating that the server is inoperable or unable to start.

Specified by:
logSevere in interface Logging
Parameters:
message - The message.

loggingSevere

public final boolean loggingSevere()
Specified by:
loggingSevere in interface Logging

logWarning

public final void logWarning(java.lang.String message)
Logs a WARNING message, indicating that an undesired (but non-fatal) condition occured.

Specified by:
logWarning in interface Logging
Parameters:
message - The message.

loggingWarning

public final boolean loggingWarning()
Specified by:
loggingWarning in interface Logging

logInfo

public final void logInfo(java.lang.String message)
Logs an INFO message, indicating that something relatively uncommon and interesting happened, like server or module startup or shutdown, or a periodic job.

Specified by:
logInfo in interface Logging
Parameters:
message - The message.

loggingInfo

public final boolean loggingInfo()
Specified by:
loggingInfo in interface Logging

logConfig

public final void logConfig(java.lang.String message)
Logs a CONFIG message, indicating what occurred during the server's (or a module's) configuration phase.

Specified by:
logConfig in interface Logging
Parameters:
message - The message.

loggingConfig

public final boolean loggingConfig()
Specified by:
loggingConfig in interface Logging

logFine

public final void logFine(java.lang.String message)
Logs a FINE message, indicating basic information about a request to the server (like hostname, operation name, and success or failure).

Specified by:
logFine in interface Logging
Parameters:
message - The message.

loggingFine

public final boolean loggingFine()
Specified by:
loggingFine in interface Logging

logFiner

public final void logFiner(java.lang.String message)
Logs a FINER message, indicating detailed information about a request to the server (like the full request, full response, and timing information).

Specified by:
logFiner in interface Logging
Parameters:
message - The message.

loggingFiner

public final boolean loggingFiner()
Specified by:
loggingFiner in interface Logging

logFinest

public final void logFinest(java.lang.String message)
Logs a FINEST message, indicating method entry/exit or extremely verbose information intended to aid in debugging.

Specified by:
logFinest in interface Logging
Parameters:
message - The message.

loggingFinest

public final boolean loggingFinest()
Specified by:
loggingFinest in interface Logging

setLogger

protected final void setLogger(java.util.logging.Logger newLogger)
Sets the Logger to which log messages are sent.

This method flushes and closes the Handlers for the previously used Logger. If there was no prior Logger, the LogRecord buffer is flushed to the new Logger and to disk at LOG_DIR/LOG_STARTUP_FILE.

This method is intended for use by subclasses of Server, during initialization.

Parameters:
newLogger - The Logger to use for messages.

flushLogger

public final void flushLogger()
Flushes any buffered log messages in the Logger's Handler(s).

If no Logger has been set, this method flushes the LogRecord queue to LOG_DIR/LOG_STARTUP_FILE, and if that can't be written to, flushes it to stderr.


closeLogger

public final void closeLogger()
Flushes, then closes any resources tied up by the Handler(s) associated with the Logger and sets the logger to null. If there is no Logger, the LogRecord queue is flushed to LOG_DIR/LOG_STARTUP_FILE, and if that can't be written to, flushes it to stderr.


hasInstance

public static final boolean hasInstance(java.io.File homeDir)

status

public final java.lang.String status(Context context)
                              throws fedora.server.errors.authorization.AuthzException
Throws:
fedora.server.errors.authorization.AuthzException

getInstance

public static final Server getInstance(java.io.File homeDir,
                                       boolean okToStart)
                                throws ServerInitializationException,
                                       ModuleInitializationException
Throws:
ServerInitializationException
ModuleInitializationException

getInstance

public static final Server getInstance(java.io.File homeDir)
                                throws ServerInitializationException,
                                       ModuleInitializationException
Provides an instance of the server specified in the configuration file at homeDir/CONFIG_DIR/CONFIG_FILE, or DEFAULT_SERVER_CLASS if unspecified.

Parameters:
homeDir - The base directory for the server.
Returns:
The instance.
Throws:
ServerInitializationException - If there was an error starting the server.
ModuleInitializationException - If there was an error starting a module.

getHomeDir

public final java.io.File getHomeDir()
Gets the server's home directory.

Returns:
The directory.

getModule

public final Module getModule(java.lang.String role)
Gets a loaded Module.

Parameters:
role - The role of the Module to get.
Returns:
The Module, null if not found.

getDatastoreConfig

public final DatastoreConfig getDatastoreConfig(java.lang.String id)
Gets a DatastoreConfig.

Parameters:
id - The id as given in the server configuration.
Returns:
The DatastoreConfig, null if not found.

datastoreConfigIds

public java.util.Iterator datastoreConfigIds()

loadedModuleRoles

public final java.util.Iterator loadedModuleRoles()
Gets an Iterator over the roles that have been loaded.

Returns:
(Strings) The roles.

initServer

protected void initServer()
                   throws ServerInitializationException
Performs any server start-up tasks particular to this type of Server.

This is guaranteed to be run before any modules are loaded. The default implementation does nothing.

Throws:
ServerInitializationException - If a severe server startup-related error occurred.

postInitServer

protected void postInitServer()
                       throws ServerInitializationException
Second stage of Server initialization.

This is guaranteed to be run after all Modules have been loaded and all module initialization (initModule() and postInitModule()) has taken place. The default implementation does nothing.

Throws:
ServerInitializationException - If a severe server startup-related error occurred.

shutdown

public final void shutdown(Context context)
                    throws ServerShutdownException,
                           ModuleShutdownException,
                           fedora.server.errors.authorization.AuthzException
Performs shutdown tasks for the modules and the server.

All loaded modules' shutdownModule() methods are called, then shutdownServer is called.

How to Ensure Clean Server Shutdown

After having used a Server instance, if you know your program is the only client of the Server in the VM instance, you should make an explicit call to this method so that you can catch and handle it's exceptions properly. If you are usure or know that there may be at least one other client of the Server in the VM instance, you should call System.runFinalization() after ensuring you no longer have a reference. In this case, if there is no other reference to the object in the VM, finalization will be called (but you will be unable to catch ShutdownException variants, if thrown).

Right before this is finished, the instance is removed from the server instances map.

Throws:
ServerShutdownException - If a severe server shutdown-related error occurred. USER_REPRESENTED = addName(new XacmlName(this, "subjectRepresented"));
ModuleShutdownException - If a severe module shutdown-related error occurred.
fedora.server.errors.authorization.AuthzException

shutdownServer

protected void shutdownServer()
                       throws ServerShutdownException
Performs shutdown tasks for the server itself.

The default implementation simply calls closeLogger() - it should be overridden in Server implementations that tie up additional system resources.

This should be written so that system resources are always freed, regardless of whether there is an error. If an error occurs, it should be thrown as a ServerShutdownException after attempts to free every resource have been made.

Throws:
ServerShutdownException - If a severe server shutdown-related error occurred.

finalize

public final void finalize()
                    throws ServerShutdownException,
                           ModuleShutdownException
Calls shutdown() when finalization occurs.

Throws:
ServerShutdownException - If a severe server shutdown-related error occurred.
ModuleShutdownException - If a severe module shutdown-related error occurred.

getLocale

public static final java.util.Locale getLocale()

getConfigSummary

public java.lang.String getConfigSummary()

getPID

public static PID getPID(java.lang.String pidString)
                  throws MalformedPidException
Throws:
MalformedPidException

pidFromFilename

public static PID pidFromFilename(java.lang.String filename)
                           throws MalformedPidException
Throws:
MalformedPidException