|
|||||||||
| Home >> All >> org >> infohazard >> [ maverick overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.infohazard.maverick
Class Dispatcher

java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.infohazard.maverick.Dispatcher
- All Implemented Interfaces:
- java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
- public class Dispatcher
- extends javax.servlet.http.HttpServlet
Dispatcher is the central command processor of the Maverick framework. All commands are routed to this servlet by way of extension mapping (say, *.m). From here requests are routed through the "workflow" tree of org.infohazard.maverick.flow.Command, View, and Transform (or "Pipeline") objects built from the Maverick configuration file.
Commands can be gracefully chained together; if a view references another Maverick Command, the same org.infohazard.maverick.flow.MaverickContext object is used.
The Dispatcher object is made available to Controllers (or anyone else) as an object in the application-scope (aka javax.servlet.ServletContext attribute) collection. The attribute key is the value of the MAVERICK_APPLICATION_KEY 55 constant.
Note that there is are two special pseudocommands defined by this
servlet: "*" and "reload".
"reload" triggers a reload of the maverick config file.
This can safely be done on running system; all commands currently being
processed will complete using the old data.
New command requests will use the new data as soon as it is finished loading.
Note that the actual command name used for "reload" is
determined by the reload Servlet init parameter.
"*" is a special command which can be defined in the
configuration file.
If a command request cannot be mapped to a command (because the requested
Command was not defined), the "*" Command will be used instead.
If there is no "*" command defined in the configuration file,
unmatched requests return 404.
| Field Summary | |
protected java.util.Map |
commands
Maps command names to Command objects. |
protected org.jdom.Document |
configDocument
The current configuration document. |
protected static java.lang.String |
DEFAULT_CONFIG_FILE
Default, context-relative, location of the Maverick XML configuration file ["/WEB-INF/maverick.xml"]. |
protected java.lang.String |
defaultRequestCharset
The charset to use by default for request parameter decoding [ null]. |
static java.lang.String |
INITPARAM_CONFIG_FILE
Name of the Servlet init parameter which defines the path to the Maverick configuration file ["configFile"]. |
static java.lang.String |
INITPARAM_CONFIG_TRANSFORM
Name of the Servlet init parameter which defines the path to a transform which will be applied to the Maverick configuration XML document before loading ["configTransform"]. |
static java.lang.String |
INITPARAM_CURRENT_CONFIG_COMMAND
Name of the Servlet init parameter which defines the name of the Command which displays the current configuration ["currentConfigCommand"]. |
static java.lang.String |
INITPARAM_DEFAULT_REQUEST_CHARSET
Name of the Serlvet init parameter used to set the defaultRequestCharset 55 property ["defaultRequestCharset"]. |
static java.lang.String |
INITPARAM_LIMIT_TRANSFORMS_PARAM
Name of the Serlvet init parameter used to set the limitTransformsParam 55 property ["limitTransformsParam"]. |
static java.lang.String |
INITPARAM_RELOAD_COMMAND
Name of the Servlet init parameter which defines the name of the reload Command ["reloadCommand"]. |
static java.lang.String |
INITPARAM_REUSE_CONTEXT
Name of the Serlvet init parameter used to set the reuseMaverickContext 55 property ["reuseMaverickContext"]. |
static java.lang.String |
KEY_CONFIG_FILE
If a value is set as an application attribute with this key, the value is used to override the setting of the configFile
Servlet init parameter ["mav.configFile"]. |
static java.lang.String |
KEY_CONFIG_TRANSFORM
If a value is set as an application attribute with this key, the value is used to override the setting of the configTransform Servlet init parameter
["mav.configTransform"]. |
protected java.lang.String |
limitTransformsParam
The number of transformations to run before stopping, regardless of whether the final step has been reached. |
private static org.apache.commons.logging.Log |
log
Dispatcher logger. |
static java.lang.String |
MAVERICK_APPLICATION_KEY
The key in the application context (javax.servlet.ServletContext) under which the Dispatcher will be made available ["mav.dispatcher"]. |
protected boolean |
reuseMaverickContext
If set to true, the org.infohazard.maverick.flow.MaverickContext is reused
between Commands invoked within the same request. |
protected static java.lang.String |
SAVED_MAVCTX_KEY
The org.infohazard.maverick.flow.MaverickContext object is stored in the request context with this key so that it can be recovered for recursive maverick execution ["mav.context"]. |
| Fields inherited from class javax.servlet.http.HttpServlet |
|
| Fields inherited from class javax.servlet.GenericServlet |
|
| Constructor Summary | |
Dispatcher()
|
|
| Method Summary | |
protected java.net.URL |
convertToURL(java.lang.String path)
Interprets some absolute URLs as external paths, otherwise generates URL appropriate for loading from internal webapp. |
protected java.lang.String |
extractCommandName(javax.servlet.http.HttpServletRequest request)
Extracts the command name from the request. |
protected org.infohazard.maverick.flow.Command |
getCommand(java.lang.String name)
Returns the command object associated with the specified name. |
org.jdom.Document |
getConfigDocument()
Returns the current configuration as a JDOM Document. |
java.lang.String |
getLimitTransformsParam()
Returns the limitTransformsParam 55 property. |
void |
init()
Initializes the Dispatcher by loading the configuration file. |
protected org.jdom.Document |
loadConfigDocument()
Returns a loaded JDOM document containing the configuration information. |
protected void |
reloadConfig()
Reloads the XML configuration file. |
protected void |
service(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
The main entry point of the servlet; this processes an HTTP request. |
| Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service |
| Methods inherited from class javax.servlet.GenericServlet |
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
MAVERICK_APPLICATION_KEY
public static final java.lang.String MAVERICK_APPLICATION_KEY
The key in the application context (javax.servlet.ServletContext) under which the
Dispatcherwill be made available ["mav.dispatcher"].- See Also:
- Constant Field Values
KEY_CONFIG_FILE
public static final java.lang.String KEY_CONFIG_FILE
If a value is set as an application attribute with this key, the value is used to override the setting of the
configFileServlet init parameter ["mav.configFile"].- See Also:
- Constant Field Values
INITPARAM_CONFIG_FILE
public static final java.lang.String INITPARAM_CONFIG_FILE
Name of the Servlet init parameter which defines the path to the Maverick configuration file ["configFile"]. This parameter is used when
KEY_CONFIG_FILE55 is not set, otherwise the path defaults to DEFAULT_CONFIG_FILE 55 .- See Also:
- Constant Field Values
KEY_CONFIG_TRANSFORM
public static final java.lang.String KEY_CONFIG_TRANSFORM
If a value is set as an application attribute with this key, the value is used to override the setting of the
configTransformServlet init parameter ["mav.configTransform"].- See Also:
- Constant Field Values
INITPARAM_CONFIG_TRANSFORM
public static final java.lang.String INITPARAM_CONFIG_TRANSFORM
Name of the Servlet init parameter which defines the path to a transform which will be applied to the Maverick configuration XML document before loading ["configTransform"]. Defaults to null, which means perform no transformation.
- See Also:
- Constant Field Values
INITPARAM_RELOAD_COMMAND
public static final java.lang.String INITPARAM_RELOAD_COMMAND
Name of the Servlet init parameter which defines the name of the
reloadCommand ["reloadCommand"]. The value will typically be something like "reload".- See Also:
- Constant Field Values
INITPARAM_CURRENT_CONFIG_COMMAND
public static final java.lang.String INITPARAM_CURRENT_CONFIG_COMMAND
Name of the Servlet init parameter which defines the name of the Command which displays the current configuration ["currentConfigCommand"]. The value will typically be something like "currentConfig".
- See Also:
- Constant Field Values
INITPARAM_DEFAULT_REQUEST_CHARSET
public static final java.lang.String INITPARAM_DEFAULT_REQUEST_CHARSET
Name of the Serlvet init parameter used to set the defaultRequestCharset 55 property ["defaultRequestCharset"].
- See Also:
- Constant Field Values
INITPARAM_LIMIT_TRANSFORMS_PARAM
public static final java.lang.String INITPARAM_LIMIT_TRANSFORMS_PARAM
Name of the Serlvet init parameter used to set the limitTransformsParam 55 property ["limitTransformsParam"].
- See Also:
- Constant Field Values
INITPARAM_REUSE_CONTEXT
public static final java.lang.String INITPARAM_REUSE_CONTEXT
Name of the Serlvet init parameter used to set the reuseMaverickContext 55 property ["reuseMaverickContext"].
- See Also:
- Constant Field Values
DEFAULT_CONFIG_FILE
protected static final java.lang.String DEFAULT_CONFIG_FILE
Default, context-relative, location of the Maverick XML configuration file ["/WEB-INF/maverick.xml"].
Used if
KEY_CONFIG_FILE55 andINITPARAM_CONFIG_FILE55 are not set.- See Also:
- Constant Field Values
SAVED_MAVCTX_KEY
protected static final java.lang.String SAVED_MAVCTX_KEY
The org.infohazard.maverick.flow.MaverickContext object is stored in the request context with this key so that it can be recovered for recursive maverick execution ["mav.context"].
- See Also:
- Constant Field Values
log
private static org.apache.commons.logging.Log log
Dispatcher logger.
commands
protected java.util.Map commands
Maps command names to Command objects.
configDocument
protected org.jdom.Document configDocument
The current configuration document.
defaultRequestCharset
protected java.lang.String defaultRequestCharset
The charset to use by default for request parameter decoding [
null]. If not set, the default charset will be whatever the servlet container chooses (probably ISO-8859-1 aka Latin-1). If set, this String is used as the character encoding for HTTP requests. Leaving the property unset means do nothing special.This property may be set through the INITPARAM_DEFAULT_REQUEST_CHARSET 55 Serlvet init parameter.
limitTransformsParam
protected java.lang.String limitTransformsParam
The number of transformations to run before stopping, regardless of whether the final step has been reached. If this property is not set, all transforms will run to completion.
This property may be set through the INITPARAM_LIMIT_TRANSFORMS_PARAM 55 Serlvet init parameter.
reuseMaverickContext
protected boolean reuseMaverickContext
If set to
true, the org.infohazard.maverick.flow.MaverickContext is reused between Commands invoked within the same request. This allows Maverick Controllers to be "chained" by forwarding context attributes from one Maverick Command to another.The Context is not preserved in the case of a redirected request, since redirection creates a new HTTP request.
This property may be set through the INITPARAM_REUSE_CONTEXT 55 Serlvet init parameter. Set the parameter to "true" or leave it undefined ["false"].
| Constructor Detail |
Dispatcher
public Dispatcher()
| Method Detail |
init
public void init()
throws javax.servlet.ServletException
Initializes the Dispatcher by loading the configuration file.
service
protected void service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
The main entry point of the servlet; this processes an HTTP request.
extractCommandName
protected java.lang.String extractCommandName(javax.servlet.http.HttpServletRequest request)
Extracts the command name from the request. Extension and leading / will be removed.
reloadConfig
protected void reloadConfig()
throws org.infohazard.maverick.flow.ConfigException
Reloads the XML configuration file. Can be done on-the-fly. Any requests being serviced are allowed to complete with the old data.
getCommand
protected org.infohazard.maverick.flow.Command getCommand(java.lang.String name)
Returns the command object associated with the specified name. If the command is not found, a command with name "*" is returned. If there is no command with id "*", null is returned.
loadConfigDocument
protected org.jdom.Document loadConfigDocument() throws org.infohazard.maverick.flow.ConfigException
Returns a loaded JDOM document containing the configuration information.
getConfigDocument
public org.jdom.Document getConfigDocument()
Returns the current configuration as a JDOM Document.
getLimitTransformsParam
public java.lang.String getLimitTransformsParam()
Returns the
limitTransformsParam55 property.nullnull indicates the feature is disabled.
convertToURL
protected java.net.URL convertToURL(java.lang.String path) throws java.net.MalformedURLException
Interprets some absolute URLs as external paths, otherwise generates URL appropriate for loading from internal webapp.
|
|||||||||
| Home >> All >> org >> infohazard >> [ maverick overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC