All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.webmacro.broker.Config

java.lang.Object
   |
   +----org.webmacro.broker.Config

public class Config
extends Object
implements ResourceProvider
Config represnts the data stored in a WebMacro.properites, and a few things that can be derived from it; as well as other information known about the environment that is relevant to the proper functioning of the WebMacro system.

You can put your own variables into the configuration file, and use Config to access them. The configuration file is composed of key value pairs separated by an "=". It can contain comments, which are lines beginning with "#".

There are a bunch of standard values in a configuration file. A few of them MUST be set when you first install WebMacro. Most of the settings have relatively sensible defaults.

Config is used by thenservlet package's WebContext, Reactor, and Handler to construct the appropriate environment. It also controls the overal logging of WebMacro information.

When using a Config object, you should refer to standard values in the config file by way of the string constants defined below.


Variable Index

 o ERROR_TEMPLATE
Name of the error handler template is defined in the config file under the name ErrorTemplate.
 o ERROR_VARIABLE
Name of the string that gets set in WebContext on an error message is stored in the ConfigFile under the name , ErrorVariable.
 o lineSeparator
Platform dependent line separator required to construct path names for File
 o LOG_FILE
Name of the log file appears in the config file under the name LogFile.
 o LOG_LEVEL
The desired log level appears in the config file under the name LogLevel.
 o LOG_TRACE_EXCEPTIONS
Whether exceptions are traced in the log or not is set in the log file as the variable LogTraceExceptions and can have the value (ignoring case) of "true" or "false".
 o PROVIDERS
This variable must correspond to a whitespace separated list of resource providers, to be loaded into WebMacro on startup.
 o TEMPLATE_CACHE
Duration of time to cache templates.
 o TEMPLATE_DIR
Default directory from which to load templates is defined in the config file under the name TemplateDirectory.
 o TYPE
Constant that contains the Log and ResourceProvider Type served by this class.
 o USER_DB_FILE
The file into which the user database is saved.

Constructor Index

 o Config()
Construct a new config file, reading from the default location.
 o Config(InputStream)
Read config from the supplied input stream
 o Config(String)
Construct a new configuration instance using the specified config file, rather than attempting to use the default.

Method Index

 o destroy()
Unimplemented / does nothing
 o get(String)
Look up the specified configuration property in the config file and return the value assigned to it.
 o getProperties()
Return the configuration properties object
 o getServerId()
Get an ID that uniquely identifies this instance of the server.
 o getTypes()
We serve up "config" type resources
 o getUniqueString()
Get a string that is unique across all currently running VM's
 o init(ResourceBroker)
Unimplemented / does nothing
 o main(String[])
Test harness
 o resourceCreate(CreateResourceEvent)
Unimplemented / does nothing
 o resourceDelete(ResourceEvent)
Unimplemented / does nothing
 o resourceExpireTime()
Never cache.
 o resourceRequest(RequestResourceEvent)
Request a configuration value.
 o resourceSave(ResourceEvent)
Unimplemented / does nothing
 o resourceThreads()
No concurrency--all in memory operation.

Variables

 o TYPE
 public static final String TYPE
Constant that contains the Log and ResourceProvider Type served by this class.

 o lineSeparator
 public static final String lineSeparator
Platform dependent line separator required to construct path names for File

 o PROVIDERS
 public static final String PROVIDERS
This variable must correspond to a whitespace separated list of resource providers, to be loaded into WebMacro on startup.

 o TEMPLATE_DIR
 public static final String TEMPLATE_DIR
Default directory from which to load templates is defined in the config file under the name TemplateDirectory. The default is to look for a directory called "template" under the current working directory.

 o TEMPLATE_CACHE
 public static final String TEMPLATE_CACHE
Duration of time to cache templates. Setting this to zero turns off caching, which is useful during debugging and coding sessions. Set it to a number of milliseconds for production use (eg: 60000, being 10 * 60 * 1000, is 10 minutes).

 o USER_DB_FILE
 public static final String USER_DB_FILE
The file into which the user database is saved. This is defined in the config file under the name UserDB. The default is "user.db" in the current working directory.

 o ERROR_TEMPLATE
 public static final String ERROR_TEMPLATE
Name of the error handler template is defined in the config file under the name ErrorTemplate. By default it is "error.wm".

 o ERROR_VARIABLE
 public static final String ERROR_VARIABLE
Name of the string that gets set in WebContext on an error message is stored in the ConfigFile under the name , ErrorVariable. By default it is "error" ($error in templates)

 o LOG_FILE
 public static final String LOG_FILE
Name of the log file appears in the config file under the name LogFile. If it isn't defined, then stderr is used.

 o LOG_TRACE_EXCEPTIONS
 public static final String LOG_TRACE_EXCEPTIONS
Whether exceptions are traced in the log or not is set in the log file as the variable LogTraceExceptions and can have the value (ignoring case) of "true" or "false". Any other value is considered to be false. The default is false.

 o LOG_LEVEL
 public static final String LOG_LEVEL
The desired log level appears in the config file under the name LogLevel. If it isn't defined, then the default is "WARNING". Possible values: ALL DEBUG EXCEPTION ERROR WARNING INFO NONE

Constructors

 o Config
 public Config()
Construct a new config file, reading from the default location.

 o Config
 public Config(String configFile)
Construct a new configuration instance using the specified config file, rather than attempting to use the default.

 o Config
 public Config(InputStream configStream)
Read config from the supplied input stream

Methods

 o resourceThreads
 public final int resourceThreads()
No concurrency--all in memory operation.

 o getTypes
 public final String[] getTypes()
We serve up "config" type resources

 o resourceExpireTime
 public final int resourceExpireTime()
Never cache. Not worth it.

 o resourceRequest
 public final void resourceRequest(RequestResourceEvent evt)
Request a configuration value.

 o destroy
 public final void destroy()
Unimplemented / does nothing

 o init
 public final void init(ResourceBroker r)
Unimplemented / does nothing

 o resourceCreate
 public final void resourceCreate(CreateResourceEvent evt)
Unimplemented / does nothing

 o resourceDelete
 public final boolean resourceDelete(ResourceEvent evt)
Unimplemented / does nothing

 o resourceSave
 public final boolean resourceSave(ResourceEvent evt)
Unimplemented / does nothing

 o get
 public final String get(String configProperty)
Look up the specified configuration property in the config file and return the value assigned to it. If it does not exist, instead return the default setting. If there is no default setting and it does not exist, return null.

Parameters:
configProperty - the variable keyword (left hand side)
Returns:
the value corresponding to the keyword (right hand side)
 o getProperties
 public final Properties getProperties()
Return the configuration properties object

 o getServerId
 public final String getServerId()
Get an ID that uniquely identifies this instance of the server. The intent of this method is to provide a unique string that can be used to avoid conflicts between multiple simultaneous instances of a servlet. This number is unique across all VM's, and unique across all config objects in this VM. Since each Reactor gets its own copy of Config, this should work...

You can use this string to construct temporary files and create other unique strings.

 o getUniqueString
 public static final synchronized String getUniqueString()
Get a string that is unique across all currently running VM's

 o main
 public static void main(String arg[])
Test harness


All Packages  Class Hierarchy  This Package  Previous  Next  Index