|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.servlet.GenericServlet | +--javax.servlet.http.HttpServlet | +--org.infohazard.maverick.Dispatcher
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 Command, View, and Pipeline objects built from the maverick config file.
Commands can be gracefully chained together; if a view references another Maverick command, the same MaverickContext object is used.
The Dispatcher object is made available to Controllers (or anyone else as an object in the application-scope aka ServletContext attribute collection. The attribute key is the value of the MAVERICK_APPLICATION_KEY 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 an init param.
"*" is a special command which can be defined in the config 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 config file, bad requests return 404.
Field Summary | |
protected java.util.Map |
commands
Maps command name -> Command objects. |
protected org.jdom.Document |
configDocument
The current configuration document. |
protected static java.lang.String |
DEFAULT_CONFIG_FILE
Default location of the xml configuration file. |
protected java.lang.String |
defaultRequestCharset
If set, this string is set as the character encoding for http requests. |
protected static java.lang.String |
INITPARAM_CONFIG_FILE
Name of the servlet init parameter which defines the path to the Maverick configuration file. |
protected 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 config XML before loading. |
protected 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. |
protected static java.lang.String |
INITPARAM_DEFAULT_REQUEST_CHARSET
Name of the servlet init parameter which defines the charset to use by default for request parameter decoding. |
protected static java.lang.String |
INITPARAM_LIMIT_TRANSFORMS_PARAM
The name of an http request parameter which, if specified, causes transformation to be halted after the specified number of transforms. |
protected static java.lang.String |
INITPARAM_RELOAD_COMMAND
Name of the servlet init parameter which defines the name of the reload command. |
protected java.lang.String |
limitTransformsParam
If set, the name of a http request parameter which determines the number of transforms to run before halting. |
static java.lang.String |
MAVERICK_APPLICATION_KEY
The key in the Application (ServletContext) attribute collection under which the Dispatcher will be made available. |
protected static java.lang.String |
SAVED_MAVCTX_KEY
The MaverickContext object is stored in the request attributes with this key so that it can be recovered for recursive maverick execution. |
Constructor Summary | |
Dispatcher()
|
Method Summary | |
protected java.lang.String |
extractCommandName(javax.servlet.http.HttpServletRequest request)
Extracts the command name from the request. |
protected Command |
getCommand(java.lang.String name)
Returns the command object associated with the specified name. |
org.jdom.Document |
getConfigDocument()
|
java.lang.String |
getLimitTransformsParam()
The name of the parameter to use to limit transformation, or null if this should be disabled. |
void |
init()
Initializes the Dispatcher by loading the config file. |
protected org.jdom.Document |
loadConfigDocument()
|
protected void |
reloadConfig()
Reloads the xml configuration data. |
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 |
public static final java.lang.String MAVERICK_APPLICATION_KEY
protected static final java.lang.String INITPARAM_CONFIG_FILE
protected static final java.lang.String INITPARAM_CONFIG_TRANSFORM
protected static final java.lang.String INITPARAM_RELOAD_COMMAND
protected static final java.lang.String INITPARAM_CURRENT_CONFIG_COMMAND
protected static final java.lang.String INITPARAM_DEFAULT_REQUEST_CHARSET
protected static final java.lang.String INITPARAM_LIMIT_TRANSFORMS_PARAM
protected static final java.lang.String DEFAULT_CONFIG_FILE
protected static final java.lang.String SAVED_MAVCTX_KEY
protected java.util.Map commands
protected org.jdom.Document configDocument
protected java.lang.String defaultRequestCharset
protected java.lang.String limitTransformsParam
Constructor Detail |
public Dispatcher()
Method Detail |
public void init() throws javax.servlet.ServletException
init
in class javax.servlet.GenericServlet
javax.servlet.ServletException
protected void service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
service
in class javax.servlet.http.HttpServlet
java.io.IOException
javax.servlet.ServletException
protected java.lang.String extractCommandName(javax.servlet.http.HttpServletRequest request)
protected void reloadConfig() throws ConfigException
ConfigException
protected Command getCommand(java.lang.String name)
protected org.jdom.Document loadConfigDocument() throws ConfigException
ConfigException
public org.jdom.Document getConfigDocument()
public java.lang.String getLimitTransformsParam()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |