|
|||||||||
| Home >> All >> com >> jcorporate >> expresso >> core >> [ misc overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.jcorporate.expresso.core.misc
Class ConfigManager

java.lang.Objectcom.jcorporate.expresso.core.misc.ConfigManager
- public final class ConfigManager
- extends java.lang.Object
ConfigManager is a static class that utilizes the Struts Digester utility to read an XML file of configuration parameters when Expresso starts up. These parameters are then available during the execution of the application.
| Field Summary | |
private static java.util.Hashtable |
allContexts
|
private static java.lang.String |
configDir
|
private static boolean |
configurationFailed
|
private static java.lang.Throwable |
configurationFailureException
If configuration failed on initial startup, we keep the exception that caused the failure available for reference |
private static com.jcorporate.expresso.core.controller.ControllerFactory |
controllerFactory
|
private static java.util.Hashtable |
currentLogins
Hashtable of current logins sitting in the system. |
private static java.util.Hashtable |
dbOtherMap
|
static java.lang.String |
EXPRESSO_DTD_COPY_LOCATION
constant path for DTD file; we expect DTD to be placed here, probably by a ANT copy before running servlet engine searched relative to class dir |
private static java.util.Hashtable |
jobHandlers
List of currently running job handlers |
private static org.apache.log4j.Logger |
log
|
static java.lang.String |
LOG_DIR_PARAM_NAME
name of servlet param which controls logging directory |
private static java.util.Map |
mapModuleMapping
Map collection to associate module names with action mappings The default module has a prefix of "". |
private static ConfigExpresso |
myConfig
|
private static javax.servlet.http.HttpServletRequest |
myRequest
|
private static java.lang.String |
servletAPIVersion
|
private static ConfigManager |
theInstance
Singleton implementation function. |
private static boolean |
xmlConfigOk
|
| Constructor Summary | |
ConfigManager()
Default Constructer |
|
| Method Summary | |
static void |
addSession(CurrentLogin newLogin)
Adds to the 'we have X many logins' hashtable. |
static void |
checkInitialized(javax.servlet.http.HttpServletRequest req,
javax.servlet.ServletConfig c)
Check if the configuration info needs to be read, and read it if so. Immediately returns if the config manager has already been initialized successfully. Any servlet can check this to make sure Expresso has been started up successfully - if not, it calls load as needed to perform/re-perform the startup. |
static void |
config(javax.servlet.ServletConfig c)
Called by the initial load servlet to initialize the entire system |
static void |
dbInitialize()
Initialize our database pool(s) |
static void |
dbUninitialize()
Remove our database pool(s) Closes all connections so that Hypersonic can handle multiple test suites from multiple VM's thrown at it as long as each test suite calls dbUninitialize in the teardown method. |
static void |
destroy()
Call this to destroy all items that ConfigManager uses. |
static java.lang.String |
expandValue(java.lang.String propValue)
Method to "expand" some simple "macro" codes allowed in property file and Setup values. |
static org.apache.struts.config.ForwardConfig |
findForwardConfig(org.apache.struts.config.ActionConfig oneConfig,
java.lang.String stateName)
Find a forward config given an action config and a state name Does not return higher level forwards, just the one for the given state IF it exists |
static org.apache.struts.config.ActionConfig |
getActionConfig(java.lang.String controllerName,
java.lang.String stateName)
Gets the action mapping associated with the controller and default root module. |
static org.apache.struts.config.ActionConfig |
getActionConfig(java.lang.String moduleName,
java.lang.String controllerName,
java.lang.String stateName)
Gets the action mapping associated with the controller and the module name. |
static java.util.List |
getActionConfigList(java.lang.String controllerName)
Gets all the action mappings associated with the controller and the default module. |
static java.util.List |
getActionConfigList(java.lang.String moduleName,
java.lang.String controllerName)
Gets all the action mappings associated with the controller and the module name. |
static java.util.Enumeration |
getAllConfigKeys()
Return an enumeration of all of the valid configuration keys. |
static java.util.Hashtable |
getAllJobHandlers()
Gets all job handlers in the system |
static java.lang.String |
getClassHandler(java.lang.String handlerName)
Return the Class dealing with the named ClassHandler |
static java.lang.String |
getClassHandlerParameter(java.lang.String handlerName,
java.lang.String parameter)
Returns the given parameter for a class handler. |
static ConfigExpresso |
getConfig()
Return the top-level configuration object, an instance of the ConfigExpresso class. |
static java.lang.String |
getConfigDir()
Return the pathname of the configuration directory (specified as "configDir" |
static java.util.HashMap |
getConfigInputSources(java.lang.String filterDocType)
Returns a hashmap keyed by filename, and data ='s a series of input streams corresponding to xml files of the desired doctype. |
static java.lang.Throwable |
getConfigurationFailureException()
|
static ConfigContext |
getContext(java.lang.String contextName)
Return the context configuration object for the named context. |
static java.lang.String |
getContextPath()
Get the web-app context path for this web application |
static com.jcorporate.expresso.core.controller.ControllerFactory |
getControllerFactory()
Returns the controller factory object. |
static java.util.Hashtable |
getCurrentLogins()
Returns a hashtable of the current login objects |
static ConfigManager |
getInstance()
Return the reference instance of the config manager Use this in preference to the singleton APIs. |
static ConfigJdbc |
getJdbc(java.lang.String contextName)
Get the Jdbc configuration (if any) for the named context |
static ConfigJdbc |
getJdbcRequired(java.lang.String contextName)
Get a Jdbc configuration object, throwing an exception if there is not one for the specified context |
static com.jcorporate.expresso.core.utility.JobHandler |
getJobHandler(java.lang.String contextName)
Returns a specific job handler. |
static org.apache.struts.action.ActionMapping |
getMapping(java.lang.String controllerName,
java.lang.String stateName)
Deprecated. this method is now deprecated and does no anything since Struts 1.1 getActionConfig(String moduleName, String controllerName, String stateName ) 55 |
static java.lang.String |
getOtherDbLocation(java.lang.String dbName,
java.lang.String objectName)
Get the cached "other db" location for a specific object Creation date: (1/5/01 6:57:06 PM) author: Adam Rossi, PlatinumSolutions |
static java.util.Hashtable |
getOtherDBLocations()
Return a cloned Hashtable containing all of the DBOtherMap entries author Adam Rossi, PlatinumSolutions |
static java.lang.String |
getServletAPIVersion()
Queries the current servletAPI defined in the configuration system |
static java.lang.String |
getWebAppDir()
Get the actual filesystem directory that is the root of this web-app |
static void |
initializeAllDBObjects()
Iterate through all schemas and instantiate a DBObject. |
protected static void |
initializeOneSchema(java.lang.String className)
|
private static void |
initLogManager(javax.servlet.ServletConfig sc)
Initialize Log Manager based upon the LogDirectory. |
static boolean |
isInitialized()
Is the ConfigManager initialized yet? |
static boolean |
isParameterReservedWord(java.lang.String testWord)
Checks to see if a controller parameter may be a reserved word. |
static boolean |
isReservedWord(java.lang.String testWord)
Checks to see if any given field or tablename fed to this qualifies as a known reserved word for various databases. |
static void |
load(java.lang.String theConfigDir)
"Second stage" configuration. |
static void |
mapOtherDBs()
Map otherdb locations into a hashtable stored in memory. |
private void |
readXMLConfig(java.lang.String configDir)
Read the Expresso-config.xml file, populating the configuration tree as we go This method utilizes the Strut's XML digester to perform it's configuration readings. |
static void |
reInitialize(javax.servlet.http.HttpServletRequest req,
javax.servlet.ServletConfig c)
Re-read all properties and other values, re-initialize everything |
static void |
removeSession(java.lang.String sessionId)
Removes a stored session. |
static void |
setConfigurationFailureException(java.lang.Throwable ee)
|
static void |
setContextPath(java.lang.String newContextPath)
Set the "context path" - this is used for translating the %context% 'macro' that can be used in property and setup values |
static void |
setControllerFactory(com.jcorporate.expresso.core.controller.ControllerFactory cf)
set the controller factory to use. |
protected void |
setDigesterRules(ConfigExpresso myConfig,
org.apache.commons.digester.Digester digester)
Set up the rules for the digester |
static void |
setRequest(javax.servlet.http.HttpServletRequest req)
This function is used by webservers to set global variables such as server prefix, or context path. |
protected void |
setSAXParser()
|
static void |
setWebAppDir(java.lang.String newDir)
Set the "Web application directory" - this is used for translating the %web-app% 'macro' that can be used in property and setup values |
static void |
startJobHandler()
Start job handlers The job handler for each DB context is started if the appropriate configuration entry is found for that context |
protected void |
stopJobHandler()
Stops all job handlers |
static void |
storeModuleActionConfig(org.apache.struts.config.ModuleConfig moduleConfig)
Store the action mappings per module to allow fast reverse based lookup based on the controller name. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
EXPRESSO_DTD_COPY_LOCATION
public static final java.lang.String EXPRESSO_DTD_COPY_LOCATION
- constant path for DTD file; we expect DTD to be placed here, probably by a ANT copy before running servlet engine
searched relative to class dir
- See Also:
- Constant Field Values
LOG_DIR_PARAM_NAME
public static final java.lang.String LOG_DIR_PARAM_NAME
- name of servlet param which controls logging directory
- See Also:
- Constant Field Values
currentLogins
private static java.util.Hashtable currentLogins
- Hashtable of current logins sitting in the system.
allContexts
private static java.util.Hashtable allContexts
configDir
private static java.lang.String configDir
servletAPIVersion
private static java.lang.String servletAPIVersion
mapModuleMapping
private static java.util.Map mapModuleMapping
- Map collection to associate module names with action mappings
The default module has a prefix of "".
myConfig
private static ConfigExpresso myConfig
dbOtherMap
private static java.util.Hashtable dbOtherMap
log
private static org.apache.log4j.Logger log
xmlConfigOk
private static boolean xmlConfigOk
configurationFailed
private static boolean configurationFailed
jobHandlers
private static java.util.Hashtable jobHandlers
- List of currently running job handlers
configurationFailureException
private static java.lang.Throwable configurationFailureException
- If configuration failed on initial startup, we keep the exception
that caused the failure available for reference
myRequest
private static javax.servlet.http.HttpServletRequest myRequest
theInstance
private static ConfigManager theInstance
- Singleton implementation function.
controllerFactory
private static com.jcorporate.expresso.core.controller.ControllerFactory controllerFactory
| Constructor Detail |
ConfigManager
public ConfigManager()
- Default Constructer
| Method Detail |
addSession
public static void addSession(CurrentLogin newLogin)
- Adds to the 'we have X many logins' hashtable.
setConfigurationFailureException
public static void setConfigurationFailureException(java.lang.Throwable ee)
getConfigurationFailureException
public static java.lang.Throwable getConfigurationFailureException()
removeSession
public static void removeSession(java.lang.String sessionId)
- Removes a stored session. Used for tracking the number of people
currently logged in.
getCurrentLogins
public static java.util.Hashtable getCurrentLogins()
- Returns a hashtable of the current login objects
getJobHandler
public static com.jcorporate.expresso.core.utility.JobHandler getJobHandler(java.lang.String contextName)
- Returns a specific job handler.
getAllJobHandlers
public static java.util.Hashtable getAllJobHandlers()
- Gets all job handlers in the system
getServletAPIVersion
public static java.lang.String getServletAPIVersion()
- Queries the current servletAPI defined in the configuration system
dbUninitialize
public static void dbUninitialize()
throws com.jcorporate.expresso.core.db.DBException
- Remove our database pool(s)
Closes all connections so that Hypersonic can handle multiple test
suites from multiple VM's thrown at it as long as each test suite
calls dbUninitialize in the teardown method.
destroy
public static void destroy()
- Call this to destroy all items that ConfigManager uses.
Initially not everythiny is implemented. Must be tested If there
is an error the system prints a stack trace to System.err instead of the
log since logging may have shut down by now.
dbInitialize
public static void dbInitialize()
throws ConfigurationException
- Initialize our database pool(s)
initializeAllDBObjects
public static void initializeAllDBObjects()
- Iterate through all schemas and instantiate a DBObject. Yes, this by
and large may get thrown away later, but constructing blank objects allows
various objects to set up listener relations with other classes.
This is especially important for UserListener information.
initializeOneSchema
protected static void initializeOneSchema(java.lang.String className)
getAllConfigKeys
public static java.util.Enumeration getAllConfigKeys()
- Return an enumeration of all of the valid configuration keys.
There is one key for each property file read.
getInstance
public static ConfigManager getInstance()
- Return the reference instance of the config manager Use this in preference
to the singleton APIs. So now you have:
ConfigManager.getInstace().getLogDirectory()for instance. instead ofConfigManager.getLogDirectory();
isInitialized
public static boolean isInitialized()
- Is the ConfigManager initialized yet?
getConfig
public static ConfigExpresso getConfig()
- Return the top-level configuration object, an instance of the ConfigExpresso
class. This class contains all the setup options common to all contexts
getConfigInputSources
public static java.util.HashMap getConfigInputSources(java.lang.String filterDocType) throws ConfigurationException
- Returns a hashmap keyed by filename, and data ='s a series of input
streams corresponding to xml files of the desired doctype. All files are
located in the Expresso configuration directory
getContext
public static ConfigContext getContext(java.lang.String contextName) throws ConfigurationException
- Return the context configuration object for the named context. This object
contains all of the configuration info for a specific context/database
getClassHandler
public static java.lang.String getClassHandler(java.lang.String handlerName)
- Return the Class dealing with the named ClassHandler
getClassHandlerParameter
public static java.lang.String getClassHandlerParameter(java.lang.String handlerName, java.lang.String parameter)
- Returns the given parameter for a class handler.
getJdbc
public static ConfigJdbc getJdbc(java.lang.String contextName) throws ConfigurationException
- Get the Jdbc configuration (if any) for the named context
getJdbcRequired
public static ConfigJdbc getJdbcRequired(java.lang.String contextName) throws ConfigurationException
- Get a Jdbc configuration object, throwing an exception if there is not one
for the specified context
getWebAppDir
public static java.lang.String getWebAppDir()
- Get the actual filesystem directory that is the root of this web-app
isReservedWord
public static boolean isReservedWord(java.lang.String testWord)
- Checks to see if any given field or tablename fed to this qualifies
as a known reserved word for various databases.
isParameterReservedWord
public static boolean isParameterReservedWord(java.lang.String testWord)
- Checks to see if a controller parameter may be a reserved word. This
helps prevent any weird behavior when posting objects.
startJobHandler
public static void startJobHandler()
throws ConfigurationException
- Start job handlers
The job handler for each DB context is started if the appropriate
configuration entry is found for that context
stopJobHandler
protected void stopJobHandler()
throws ConfigurationException
- Stops all job handlers
setWebAppDir
public static void setWebAppDir(java.lang.String newDir)
- Set the "Web application directory" - this is used for translating
the %web-app% 'macro' that can be used in property and setup
values
setContextPath
public static void setContextPath(java.lang.String newContextPath)
- Set the "context path" - this is used for translating
the %context% 'macro' that can be used in property and setup
values
setControllerFactory
public static void setControllerFactory(com.jcorporate.expresso.core.controller.ControllerFactory cf)
- set the controller factory to use.
getContextPath
public static java.lang.String getContextPath()
- Get the web-app context path for this web application
config
public static void config(javax.servlet.ServletConfig c) throws javax.servlet.ServletException
- Called by the initial load servlet to initialize the entire system
initLogManager
private static void initLogManager(javax.servlet.ServletConfig sc)
- Initialize Log Manager based upon the LogDirectory.
load
public static void load(java.lang.String theConfigDir) throws com.jcorporate.expresso.core.db.DBException, ConfigurationException
- "Second stage" configuration. Programs not running in the servlet
environment can call this method with a configuration directory
directly in order to set up Expresso. In a servlet environment, load
gets called from "config" above.
expandValue
public static java.lang.String expandValue(java.lang.String propValue)
- Method to "expand" some simple "macro" codes allowed in
property file and Setup values.
getConfigDir
public static java.lang.String getConfigDir()
- Return the pathname of the configuration directory (specified
as "configDir"
getControllerFactory
public static com.jcorporate.expresso.core.controller.ControllerFactory getControllerFactory()
- Returns the controller factory object. Instantiates the default
controller factory if one doesn't exist.
getOtherDbLocation
public static java.lang.String getOtherDbLocation(java.lang.String dbName, java.lang.String objectName)
- Get the cached "other db" location for a specific object
Creation date: (1/5/01 6:57:06 PM)
author: Adam Rossi, PlatinumSolutions
getOtherDBLocations
public static java.util.Hashtable getOtherDBLocations()
- Return a cloned Hashtable containing all of the DBOtherMap entries
author Adam Rossi, PlatinumSolutions
mapOtherDBs
public static void mapOtherDBs()
throws ConfigurationException
- Map otherdb locations into a hashtable stored in memory.
Creation date: (1/5/01 6:48:11 PM)
author: Adam Rossi, PlatinumSolutions
reInitialize
public static void reInitialize(javax.servlet.http.HttpServletRequest req, javax.servlet.ServletConfig c) throws javax.servlet.ServletException
- Re-read all properties and other values, re-initialize everything
checkInitialized
public static void checkInitialized(javax.servlet.http.HttpServletRequest req, javax.servlet.ServletConfig c) throws javax.servlet.ServletException
- Check if the configuration info needs to be read, and read
it if so.
Immediately returns if the config manager has already been initialized successfully.
Any servlet can check this to make sure Expresso has been started up successfully - if not, it calls load as needed to perform/re-perform the startup.
setRequest
public static void setRequest(javax.servlet.http.HttpServletRequest req)
- This function is used by webservers to set global variables such as
server prefix, or context path. This is usually set by checkLogin(),
or any other first pages that are reached.
storeModuleActionConfig
public static void storeModuleActionConfig(org.apache.struts.config.ModuleConfig moduleConfig)
- Store the action mappings per module to allow fast reverse based
lookup based on the controller name.
It is possible that the same controller is used across
action mappings and also across module (sub applications). So
this data structure takes account of the multiple mappings to
module names and save a list of possible action mappings
related to a controller class name.
PLEASE NOTE from Struts 1.1 the old
org.apache.struts.action.ActionMappingis deprecated and has been replaced withorg.apache.struts.config.ActionConfigwhich is part oforg.apache.struts.config.ModuleConfig
getActionConfig
public static org.apache.struts.config.ActionConfig getActionConfig(java.lang.String controllerName, java.lang.String stateName)
- Gets the action mapping associated with the controller and default root module.
Perform a 'reverse-mapping', that is, locate a Struts action mapping
by looking for the given controller name (and optional state name)
getActionConfig
public static org.apache.struts.config.ActionConfig getActionConfig(java.lang.String moduleName, java.lang.String controllerName, java.lang.String stateName)
- Gets the action mapping associated with the controller and the module name.
Perform a 'reverse-mapping', that is, locate a Struts action mapping
by looking for the given controller name (and optional state name).
If the stateName is
nullthis method will attempt to dynamically load the controller class, instantiate an object instance and retrieve the controller class's initial state. The action mapping is determined by looking atActionConfigrecords in Struts configuration, retrieving all the local action forward and comparing its name to the state forward. This means that in your Struts XML configuration you must define a local action forward with the same name as the state Method. If no action mapping can be determined by�looking for a particular matching local action forward, then the first action mapping is returned if exists. Please note the first action mapping is not necessarily the first action mapping declared in the XML configuration. This cannot be guaranteed, because the implementation may changed in the future.<action path="/Register" type="com.jcorporate.expresso.services.controller.SimpleRegistration" name="default" scope="request" validate="false" > <forward name="showDBMenu" path="/expresso/jsp/register/dbmenu.jsp" /> <forward name="promptAddRecord" path="/expresso/jsp/register/regAdd.jsp" /> <forward name="promptUpdateRecord" path="/expresso/jsp/register/regAdd.jsp" /> ... </action>In order for the above action mapping "/Register" to be returned then you need to declare a unique local action forward name, if you use the same controller class for multiple actions. For example "showDBMenu" could be the unique local forward.
findForwardConfig
public static final org.apache.struts.config.ForwardConfig findForwardConfig(org.apache.struts.config.ActionConfig oneConfig, java.lang.String stateName)
- Find a forward config given an action config and a state name Does not
return higher level forwards, just the one for the given state IF it exists
getActionConfigList
public static java.util.List getActionConfigList(java.lang.String controllerName)
- Gets all the action mappings associated with the
controller and the default module. Perform a
'reverse-mapping', that is, locate a Struts action mappings by
looking for the given controller name.
getActionConfigList
public static java.util.List getActionConfigList(java.lang.String moduleName, java.lang.String controllerName)
- Gets all the action mappings associated with the controller
and the module name.
Perform a 'reverse-mapping', that is, locate a Struts action mapping
by looking for the given controller name.
getMapping
public static org.apache.struts.action.ActionMapping getMapping(java.lang.String controllerName, java.lang.String stateName)
- Deprecated. this method is now deprecated and does no anything since Struts 1.1
getActionConfig(String moduleName, String controllerName, String stateName )55- Perform a 'reverse-mapping', that is, locate a Struts action mapping by looking for the given controller name (and optional state name)
- Perform a 'reverse-mapping', that is, locate a Struts action mapping by looking for the given controller name (and optional state name)
readXMLConfig
private void readXMLConfig(java.lang.String configDir) throws ConfigurationException
- Read the Expresso-config.xml file, populating the configuration tree as we go
This method utilizes the Strut's XML digester to perform it's configuration
readings. When Struts 1.1 is eventually integrated, the package will move
to apache.commons package.
setDigesterRules
protected void setDigesterRules(ConfigExpresso myConfig, org.apache.commons.digester.Digester digester)
- Set up the rules for the digester
setSAXParser
protected void setSAXParser()
|
|||||||||
| Home >> All >> com >> jcorporate >> expresso >> core >> [ misc overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.jcorporate.expresso.core.misc.ConfigManager