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 interface
StatusPageHandler.Request
Wrapper Interface for HttpServletRequest.static interface
StatusPageHandler.Response
Wrapper Interface for HttpServletResponse.static interface
StatusPageHandler.StatusDataCallback
Callback interface to update the status data. -
Field Summary
Fields Modifier and Type Field Description static java.lang.String
URL_COMMAND_SET_LOG_LEVEL
Append this constant to the URL, if the log level should be changed.static java.lang.String
URL_COMMAND_STATUS
Append this constant to the URL, if the status page should be displayed in HTML.static java.lang.String
URL_COMMAND_STATUS_TEXT
Append this constant to the URL, if the status page should be displayed in text format.static java.lang.String
URL_PARAM_COMMAND
The parameter name for commands that are processed by the StatusPageHandler class.static java.lang.String
URL_PARAM_COMMAND_LOG_LEVEL
The parameter value to display the status pagestatic java.lang.String
URL_PARAM_COMMAND_STATUS
The parameter value to display the status pagestatic java.lang.String
URL_PARAM_LOG_LEVEL
The parameter name to set the logging levelstatic java.lang.String
URL_PARAM_LOGGER
The parameter value to specify which logger is to be modifiedstatic java.lang.String
URL_PARAM_MODE
The parameter name to specify the display mode (html or text)static java.lang.String
URL_PARAM_MODE_TEXT
The 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.String
getLogLevel()
Returns the report level of the root logger.void
printStatus(StatusPageHandler.Response resp, boolean isAuth, boolean htmlNotText, StatusPageHandler.StatusDataCallback callback)
This function prints the status page.boolean
service(StatusPageHandler.Request req, StatusPageHandler.Response resp, StatusPageHandler.StatusDataCallback callback)
Called from the Servlet.service method to handle known commands.void
setLogLevel(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:
ServletException
java.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"
-