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.
-
ERROR_TEMPLATE
- Name of the error handler template is defined in the config
file under the name ErrorTemplate.
-
ERROR_VARIABLE
- Name of the string that gets set in WebContext on an error
message is stored in the ConfigFile under the name ,
ErrorVariable.
-
lineSeparator
- Platform dependent line separator required to construct
path names for File
-
LOG_FILE
- Name of the log file appears in the config file under
the name LogFile.
-
LOG_LEVEL
- The desired log level appears in the config file under
the name LogLevel.
-
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".
-
PROVIDERS
- This variable must correspond to a whitespace separated list
of resource providers, to be loaded into WebMacro on startup.
-
TEMPLATE_CACHE
- Duration of time to cache templates.
-
TEMPLATE_DIR
- Default directory from which to load templates is defined
in the config file under the name TemplateDirectory.
-
TYPE
- Constant that contains the Log and ResourceProvider Type
served by this class.
-
USER_DB_FILE
- The file into which the user database is saved.
-
Config()
- Construct a new config file, reading from the default location.
-
Config(InputStream)
- Read config from the supplied input stream
-
Config(String)
- Construct a new configuration instance using the specified config
file, rather than attempting to use the default.
-
destroy()
- Unimplemented / does nothing
-
get(String)
- Look up the specified configuration property in the config file
and return the value assigned to it.
-
getProperties()
- Return the configuration properties object
-
getServerId()
- Get an ID that uniquely identifies this instance of the server.
-
getTypes()
- We serve up "config" type resources
-
getUniqueString()
- Get a string that is unique across all currently running VM's
-
init(ResourceBroker)
- Unimplemented / does nothing
-
main(String[])
- Test harness
-
resourceCreate(CreateResourceEvent)
- Unimplemented / does nothing
-
resourceDelete(ResourceEvent)
- Unimplemented / does nothing
-
resourceExpireTime()
- Never cache.
-
resourceRequest(RequestResourceEvent)
- Request a configuration value.
-
resourceSave(ResourceEvent)
- Unimplemented / does nothing
-
resourceThreads()
- No concurrency--all in memory operation.
TYPE
public static final String TYPE
- Constant that contains the Log and ResourceProvider Type
served by this class.
lineSeparator
public static final String lineSeparator
- Platform dependent line separator required to construct
path names for File
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.
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.
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).
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.
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".
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)
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.
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.
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
Config
public Config()
- Construct a new config file, reading from the default location.
Config
public Config(String configFile)
- Construct a new configuration instance using the specified config
file, rather than attempting to use the default.
Config
public Config(InputStream configStream)
- Read config from the supplied input stream
resourceThreads
public final int resourceThreads()
- No concurrency--all in memory operation.
getTypes
public final String[] getTypes()
- We serve up "config" type resources
resourceExpireTime
public final int resourceExpireTime()
- Never cache. Not worth it.
resourceRequest
public final void resourceRequest(RequestResourceEvent evt)
- Request a configuration value.
destroy
public final void destroy()
- Unimplemented / does nothing
init
public final void init(ResourceBroker r)
- Unimplemented / does nothing
resourceCreate
public final void resourceCreate(CreateResourceEvent evt)
- Unimplemented / does nothing
resourceDelete
public final boolean resourceDelete(ResourceEvent evt)
- Unimplemented / does nothing
resourceSave
public final boolean resourceSave(ResourceEvent evt)
- Unimplemented / does nothing
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)
getProperties
public final Properties getProperties()
- Return the configuration properties object
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.
getUniqueString
public static final synchronized String getUniqueString()
- Get a string that is unique across all currently running VM's
main
public static void main(String arg[])
- Test harness
All Packages Class Hierarchy This Package Previous Next Index