Class AbstractWebConsolePlugin
- All Implemented Interfaces:
Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig
- Direct Known Subclasses:
SimpleWebConsolePlugin
Servlet with the service property
felix.webconsole.label set to the label (last segment in the URL)
of the page. The respective service is called a Web Console Plugin or a plugin
for short.
To help rendering the response the Apache Felix Web Console bundle provides two
options. One of the options is to extend the AbstractWebConsolePlugin overwriting
the renderContent(HttpServletRequest, HttpServletResponse) method.- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate(org.osgi.framework.BundleContext bundleContext) Deprecated.This method is called from the Felix Web Console to ensure the AbstractWebConsolePlugin is correctly setup.voidDeprecated.This method is called, by the Web Console to de-activate the plugin and release all used resources.protected voiddoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Deprecated.Renders the web console page for the request.protected voidDeprecated.This method is responsible for generating the footer of the page.static BrandingPluginDeprecated.final org.osgi.framework.BundleDeprecated.Returns theBundlepertaining to thebundle contextwith which this plugin has been activated.protected org.osgi.framework.BundleContextDeprecated.Returns theBundleContextwith which this plugin has been activated.Deprecated.This method should return category string which will be used to render the plugin in the navigation menu.protected String[]Deprecated.Returns a list of CSS reference paths ornullif no additional CSS files are provided by the plugin.abstract StringgetLabel()Deprecated.Retrieves the label.static final StringgetParameter(javax.servlet.http.HttpServletRequest request, String name) Deprecated.Use the Servlet API for uploadsprotected ObjectDeprecated.Returns the object which might provide resources.Deprecated.Returns the title for this plugin as returned bygetTitle()abstract StringgetTitle()Deprecated.Retrieves the title of the plug-in.getVariableResolver(javax.servlet.ServletRequest request) Deprecated.Returns theRequestVariableResolverfor the given request.protected booleanisHtmlRequest(javax.servlet.http.HttpServletRequest request) Deprecated.Detects whether this request is intended to have the headers and footers of this plugin be rendered or not.voidDeprecated.Logs the message in the levelvoidDeprecated.Logs the message in the levelprotected final StringreadTemplateFile(String templateFile) Deprecated.Reads thetemplateFileas a resource through the class loader of this class converting the binary data into a string using UTF-8 encoding.protected abstract voidrenderContent(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) Deprecated.This method is used to render the content of the plug-in.protected voidrenderMenu(Map menuMap, String appRoot, PrintWriter pw) Deprecated.protected voidrenderTopNavigation(javax.servlet.http.HttpServletRequest request, PrintWriter pw) Deprecated.This method is called to generate the top level links with the available plug-ins.protected voidsendRedirect(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String redirectUrl) static final voidsetBrandingPlugin(BrandingPlugin brandingPlugin) Deprecated.static final voidsetLogLevel(int logLevel) Deprecated.Sets the log level to be applied for calls to thelog(int, String)andlog(int, String, Throwable)methods.protected PrintWriterstartResponse(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Deprecated.This method is responsible for generating the top heading of the page.Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, serviceMethods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, init, init, log, log
-
Field Details
-
ATTR_FILEUPLOAD
Deprecated.Use the Servlet API for uploadsThis attribute is not supported anymore- See Also:
-
ATTR_FILEUPLOAD_REPO
Deprecated.Use the Servlet API for uploadsThis attribute is not supported anymore- See Also:
-
GET_RESOURCE_METHOD_NAME
Deprecated.Web Console Plugin typically consists of servlet and resources such as images, scripts or style sheets. To load resources, a Resource Provider is used. The resource provider is an object, that provides a method which name is specified by this constants and it is 'getResource'.- See Also:
-
-
Constructor Details
-
AbstractWebConsolePlugin
public AbstractWebConsolePlugin()Deprecated.
-
-
Method Details
-
getServletName
Deprecated.Returns the title for this plugin as returned bygetTitle()- Specified by:
getServletNamein interfacejavax.servlet.ServletConfig- Overrides:
getServletNamein classjavax.servlet.GenericServlet- See Also:
-
GenericServlet.getServletName()
-
getCategory
Deprecated.This method should return category string which will be used to render the plugin in the navigation menu. Default implementation returns null, which will result in the plugin link rendered as top level menu item. Concrete implementations wishing to be rendered as a sub-menu item under a category should override this method and return a string or definefelix.webconsole.categoryOSGi property. Currently only single level categories are supported. So, this should be a simple String.- Returns:
- category
-
doGet
protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException Deprecated.Renders the web console page for the request. This consist of the following five parts called in order:- Send back a requested resource
startResponse(HttpServletRequest, HttpServletResponse)renderTopNavigation(HttpServletRequest, PrintWriter)renderContent(HttpServletRequest, HttpServletResponse)endResponse(PrintWriter)
Note: If a resource is sent back for the request only the first step is executed. Otherwise the first step is a null-operation actually and the latter four steps are executed in order.
If the
isHtmlRequest(HttpServletRequest)method returnsfalseonly therenderContent(HttpServletRequest, HttpServletResponse)method is called.- Overrides:
doGetin classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionIOException- See Also:
-
HttpServlet.doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
-
isHtmlRequest
protected boolean isHtmlRequest(javax.servlet.http.HttpServletRequest request) Deprecated.Detects whether this request is intended to have the headers and footers of this plugin be rendered or not. This method always returnstrueand may be overwritten by plugins to detect from the actual request, whether or not to render the header and footer.- Parameters:
request- the original request passed from the HTTP server- Returns:
trueif the page should have headers and footers rendered
-
activate
public void activate(org.osgi.framework.BundleContext bundleContext) Deprecated.This method is called from the Felix Web Console to ensure the AbstractWebConsolePlugin is correctly setup. It is called right after the Web Console receives notification for plugin registration.- Parameters:
bundleContext- the context of the plugin bundle
-
deactivate
public void deactivate()Deprecated.This method is called, by the Web Console to de-activate the plugin and release all used resources. -
renderContent
protected abstract void renderContent(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws javax.servlet.ServletException, IOException Deprecated.This method is used to render the content of the plug-in. It is called internally from the Web Console.- Parameters:
req- the HTTP request send from the userres- the HTTP response object, where to render the plugin data.- Throws:
IOException- if an input or output error is detected when the servlet handles the requestjavax.servlet.ServletException- if the request for the GET could not be handled
-
getLabel
Deprecated.Retrieves the label. This is the last component in the servlet path. This method MUST be overridden, if theAbstractWebConsolePlugin()constructor is used.- Returns:
- the label.
-
getTitle
Deprecated.Retrieves the title of the plug-in. It is displayed in the page header and is also included in the title of the HTML document. This method MUST be overridden, if theAbstractWebConsolePlugin()constructor is used.- Returns:
- the plugin title.
-
getCssReferences
Deprecated.Returns a list of CSS reference paths ornullif no additional CSS files are provided by the plugin.The result is an array of strings which are used as the value of the
hrefattribute of the<link>elements placed in the head section of the HTML generated. If the reference is a relative path, it is turned into an absolute path by prepending the value of theWebConsoleConstants.ATTR_APP_ROOTrequest attribute.- Returns:
- The list of additional CSS files to reference in the head
section or
nullif no such CSS files are required.
-
getBundleContext
protected org.osgi.framework.BundleContext getBundleContext()Deprecated.Returns theBundleContextwith which this plugin has been activated. If the plugin has not be activated by calling theactivate(BundleContext)method, this method returnsnull.- Returns:
- the bundle context or
nullif the bundle is not activated.
-
getBundle
public final org.osgi.framework.Bundle getBundle()Deprecated.Returns theBundlepertaining to thebundle contextwith which this plugin has been activated. If the plugin has not be activated by calling theactivate(BundleContext)method, this method returnsnull.- Returns:
- the bundle or
nullif the plugin is not activated.
-
getResourceProvider
Deprecated.Returns the object which might provide resources. The class of this object is used to find thegetResourcemethod.This method may be overwritten by extensions. This base class implementation returns this instance.
- Returns:
- The resource provider object or
nullif no resources will be provided by this plugin.
-
log
Deprecated.Logs the message in the level- Parameters:
level- The log level at which to log the messagemessage- The message to log
-
log
Deprecated.Logs the message in the level- Parameters:
level- The log level at which to log the messagemessage- The message to logt- TheThrowableto log with the message
-
startResponse
protected PrintWriter startResponse(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException Deprecated.This method is responsible for generating the top heading of the page.- Parameters:
request- the HTTP request coming from the userresponse- the HTTP response, where data is rendered- Returns:
- the writer that was used for generating the response.
- Throws:
IOException- on I/O error- See Also:
-
renderMenu
Deprecated. -
endResponse
Deprecated.This method is responsible for generating the footer of the page.- Parameters:
pw- the writer, where the HTML data is rendered- See Also:
-
getParameter
@Deprecated public static final String getParameter(javax.servlet.http.HttpServletRequest request, String name) Deprecated.Use the Servlet API for uploadsDo not use this method anymore. Use the Servlet API for request parameter handling.- Parameters:
request- The request objectname- The name of the parameter- Returns:
- The parameter value or
nullif the parameter is not set
-
sendRedirect
protected void sendRedirect(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String redirectUrl) throws IOException Utility method to handle relative redirects. Some application servers like Web Sphere handle relative redirects differently therefore we should make an absolute URL before invoking send redirect.- Parameters:
request- the HTTP request coming from the userresponse- the HTTP response, where data is renderedredirectUrl- the redirect URI.- Throws:
IOException- If an input or output exception occursIllegalStateException- If the response was committed or if a partial URL is given and cannot be converted into a valid URL
-
getBrandingPlugin
Deprecated.Returns theBrandingPlugincurrently used for web console branding.- Returns:
- the brandingPlugin
-
setBrandingPlugin
Deprecated.Sets theBrandingPluginto use globally by all extensions of this class for branding.Note: This method is intended to be used internally by the Web Console to update the branding plugin to use.
- Parameters:
brandingPlugin- the brandingPlugin to set
-
setLogLevel
public static final void setLogLevel(int logLevel) Deprecated.Sets the log level to be applied for calls to thelog(int, String)andlog(int, String, Throwable)methods.Note: This method is intended to be used internally by the Web Console to update the log level according to the Web Console configuration.
- Parameters:
logLevel- the maximum allowed log level. If message is logged with lower level it will not be forwarded to the logger.
-
readTemplateFile
Deprecated.Reads thetemplateFileas a resource through the class loader of this class converting the binary data into a string using UTF-8 encoding.If the template file cannot read into a string and an exception is caused, the exception is logged and an empty string returned.
- Parameters:
templateFile- The absolute path to the template file to read.- Returns:
- The contents of the template file as a string or and empty string if the template file fails to be read.
- Throws:
NullPointerException- iftemplateFileisnullRuntimeException- if anIOExceptionis thrown reading the template file into a string. The exception provides the exception thrown as its cause.
-
getVariableResolver
Deprecated.Returns theRequestVariableResolverfor the given request.The resolver is added to the request attributes via the web console main servlet before it invokes any plugins. The preset properties are
appRootset to the value of theWebConsoleConstants.ATTR_APP_ROOTrequest attribute andpluginRootset to the value of theWebConsoleConstants.ATTR_PLUGIN_ROOTrequest attribute.- Parameters:
request- The request whose attribute is returned- Returns:
- The
RequestVariableResolverfor the given request. - Since:
- 3.5.0
-
AbstractServlet