Package de.elo.utils.webapp.status
Class StatusPageHandler
java.lang.Object
de.elo.utils.webapp.status.StatusPageHandler
- Direct Known Subclasses:
IXClientServletHandler
public class StatusPageHandler
extends java.lang.Object
This class is the bridge between a HttpServlet class and the classes of this package.
The function service(Request, Response, StatusDataCallback) is the main method of this class.
Its purpose is to render the status page and handle predefined actions like modifying the logging level.
HttpServlet derived classes should override the HttpServlet.service function and
forward requests to an instance of StatusPageHandler.
The service method of the StatusPageHandler evaluates requests with parameters:
__cmd__, __loglevel__ and __mode__.
- See Also:
StatusPageServletExample
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceStatusPageHandler.RequestWrapper Interface for HttpServletRequest.static interfaceStatusPageHandler.ResponseWrapper Interface for HttpServletResponse.static interfaceStatusPageHandler.StatusDataCallbackCallback interface to update the status data. -
Field Summary
Fields Modifier and Type Field Description static java.lang.StringURL_COMMAND_SET_LOG_LEVELAppend this constant to the URL, if the log level should be changed.static java.lang.StringURL_COMMAND_STATUSAppend this constant to the URL, if the status page should be displayed in HTML.static java.lang.StringURL_COMMAND_STATUS_TEXTAppend this constant to the URL, if the status page should be displayed in text format.static java.lang.StringURL_PARAM_COMMANDThe parameter name for commands that are processed by the StatusPageHandler class.static java.lang.StringURL_PARAM_COMMAND_LOG_LEVELThe parameter value to display the status pagestatic java.lang.StringURL_PARAM_COMMAND_STATUSThe parameter value to display the status pagestatic java.lang.StringURL_PARAM_LOG_LEVELThe parameter name to set the logging levelstatic java.lang.StringURL_PARAM_LOGGERThe parameter value to specify which logger is to be modifiedstatic java.lang.StringURL_PARAM_MODEThe parameter name to specify the display mode (html or text)static java.lang.StringURL_PARAM_MODE_TEXTThe parameter value used to display the status page in text mode rather than in HTML mode -
Constructor Summary
Constructors Constructor Description StatusPageHandler() -
Method Summary
Modifier and Type Method Description java.lang.StringgetLogLevel()Returns the report level of the root logger.voidprintStatus(StatusPageHandler.Response resp, boolean isAuth, boolean htmlNotText, StatusPageHandler.StatusDataCallback callback)This function prints the status page.booleanservice(StatusPageHandler.Request req, StatusPageHandler.Response resp, StatusPageHandler.StatusDataCallback callback)Called from the Servlet.service method to handle known commands.voidsetLogLevel(java.lang.String logger, java.lang.String reportLevel)Modifies the report level of the root logger.
-
Field Details
-
URL_COMMAND_STATUS
public static final java.lang.String URL_COMMAND_STATUSAppend this constant to the URL, if the status page should be displayed in HTML. Example: "http://server:port/myapp/myservlet?" + URL_COMMAND_STATUS- See Also:
URL_COMMAND_STATUS_TEXT, Constant Field Values
-
URL_COMMAND_STATUS_TEXT
public static final java.lang.String URL_COMMAND_STATUS_TEXTAppend this constant to the URL, if the status page should be displayed in text format. Example: "http://server:port/myapp/myservlet?" + URL_COMMAND_STATUS_TEXT- See Also:
URL_COMMAND_STATUS, Constant Field Values
-
URL_COMMAND_SET_LOG_LEVEL
public static final java.lang.String URL_COMMAND_SET_LOG_LEVELAppend this constant to the URL, if the log level should be changed. Example: "http://server:port/myapp/myservlet?" + URL_COMMAND_SET_LOG_LEVEL + "WARN";- See Also:
URL_COMMAND_STATUS, Constant Field Values
-
URL_PARAM_COMMAND
public static final java.lang.String URL_PARAM_COMMANDThe parameter name for commands that are processed by the StatusPageHandler class.- See Also:
- Constant Field Values
-
URL_PARAM_COMMAND_STATUS
public static final java.lang.String URL_PARAM_COMMAND_STATUSThe parameter value to display the status page- See Also:
- Constant Field Values
-
URL_PARAM_COMMAND_LOG_LEVEL
public static final java.lang.String URL_PARAM_COMMAND_LOG_LEVELThe parameter value to display the status page- See Also:
- Constant Field Values
-
URL_PARAM_MODE
public static final java.lang.String URL_PARAM_MODEThe parameter name to specify the display mode (html or text)- See Also:
- Constant Field Values
-
URL_PARAM_MODE_TEXT
public static final java.lang.String URL_PARAM_MODE_TEXTThe parameter value used to display the status page in text mode rather than in HTML mode- See Also:
- Constant Field Values
-
URL_PARAM_LOG_LEVEL
public static final java.lang.String URL_PARAM_LOG_LEVELThe parameter name to set the logging level- See Also:
- Constant Field Values
-
URL_PARAM_LOGGER
public static final java.lang.String URL_PARAM_LOGGERThe parameter value to specify which logger is to be modified- See Also:
- Constant Field Values
-
-
Constructor Details
-
StatusPageHandler
public StatusPageHandler()
-
-
Method Details
-
printStatus
public void printStatus(StatusPageHandler.Response resp, boolean isAuth, boolean htmlNotText, StatusPageHandler.StatusDataCallback callback) throws java.io.IOExceptionThis function prints the status page.- Parameters:
resp- HttpServletResponse respisAuth- Authentication was successfullyhtmlNotText- true for HTML output, false for plain text outputcallback- StatusDataCallback object- Throws:
java.io.IOException
-
service
public boolean service(StatusPageHandler.Request req, StatusPageHandler.Response resp, StatusPageHandler.StatusDataCallback callback) throws java.io.IOExceptionCalled from the Servlet.service method to handle known commands.- Parameters:
req- Wrapper for HttpServletRequestresp- Wrapper fro HttpServletResponsecallback- StatusDataCallback StatusData- Returns:
- true, if the message was processed.
- Throws:
ServletExceptionjava.io.IOException
-
setLogLevel
public void setLogLevel(java.lang.String logger, java.lang.String reportLevel)Modifies the report level of the root logger.- Parameters:
logger- Logger name, null or empty for root logger.reportLevel- one of "DEBUG", "INFO", "WARN", "ERROR"
-
getLogLevel
public java.lang.String getLogLevel()Returns the report level of the root logger.- Returns:
- "DEBUG", "INFO", "WARN", "ERROR"
-