org.apache.felix.webconsole.internal
Class WebConsolePluginAdapter

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.apache.felix.webconsole.AbstractWebConsolePlugin
              extended by org.apache.felix.webconsole.internal.WebConsolePluginAdapter
All Implemented Interfaces:
Serializable, Servlet, ServletConfig

public class WebConsolePluginAdapter
extends AbstractWebConsolePlugin

The WebConsolePluginAdapter is an adapter to the AbstractWebConsolePlugin for regular servlets registered with the WebConsoleConstants.PLUGIN_TITLE service attribute.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.felix.webconsole.AbstractWebConsolePlugin
ATTR_FILEUPLOAD, GET_RESOURCE_METHOD_NAME
 
Constructor Summary
WebConsolePluginAdapter(String label, Servlet plugin, ServiceReference serviceReference)
          Creates a new wrapper for a Web Console Plugin
 
Method Summary
 void destroy()
          Destroys this servlet as well as the plugin servlet.
protected  String[] getCssReferences()
          Returns the CSS references from the felix.webconsole.css service registration property of the plugin.
 String getLabel()
          Returns the label of this plugin page as defined in the constructor.
protected  Object getResourceProvider()
          Returns the registered plugin class to be able to call the getResource() method on that object for this plugin to provide additional resources.
 String getTitle()
          Returns the title of this plugin page as defined by the WebConsoleConstants.PLUGIN_TITLE service registration attribute which is exposed as the servlet name in the servlet configuration.
 void init(ServletConfig config)
          Initializes this servlet as well as the plugin servlet.
protected  boolean isHtmlRequest(HttpServletRequest request)
          Detects whether this request is intended to have the headers and footers of this plugin be rendered or not.
protected  void renderContent(HttpServletRequest req, HttpServletResponse res)
          Call the plugin servlet's service method to render the content of this page.
 void service(ServletRequest req, ServletResponse resp)
          Directly refer to the plugin's service method unless the request method is GET in which case we defer the call into the service method until the abstract web console plugin calls the renderContent(HttpServletRequest, HttpServletResponse) method.
 
Methods inherited from class org.apache.felix.webconsole.AbstractWebConsolePlugin
activate, deactivate, doGet, endResponse, getBrandingPlugin, getBundle, getBundleContext, getParameter, getServletName, log, log, readTemplateFile, renderTopNavigation, sendRedirect, setBrandingPlugin, setLogLevel, startResponse
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebConsolePluginAdapter

public WebConsolePluginAdapter(String label,
                               Servlet plugin,
                               ServiceReference serviceReference)
Creates a new wrapper for a Web Console Plugin

Parameters:
label - the label
plugin - the plugin itself
serviceReference - reference to the plugin
Method Detail

getLabel

public String getLabel()
Returns the label of this plugin page as defined in the constructor.

Specified by:
getLabel in class AbstractWebConsolePlugin
Returns:
the label.
See Also:
AbstractWebConsolePlugin.getLabel()

getTitle

public String getTitle()
Returns the title of this plugin page as defined by the WebConsoleConstants.PLUGIN_TITLE service registration attribute which is exposed as the servlet name in the servlet configuration.

Specified by:
getTitle in class AbstractWebConsolePlugin
Returns:
the plugin title.
See Also:
AbstractWebConsolePlugin.getTitle()

getCssReferences

protected String[] getCssReferences()
Returns the CSS references from the felix.webconsole.css service registration property of the plugin.

Overrides:
getCssReferences in class AbstractWebConsolePlugin
Returns:
The list of additional CSS files to reference in the head section or null if no such CSS files are required.
See Also:
AbstractWebConsolePlugin.getCssReferences()

renderContent

protected void renderContent(HttpServletRequest req,
                             HttpServletResponse res)
                      throws ServletException,
                             IOException
Call the plugin servlet's service method to render the content of this page.

Specified by:
renderContent in class AbstractWebConsolePlugin
Parameters:
req - the HTTP request send from the user
res - the HTTP response object, where to render the plugin data.
Throws:
ServletException - if the request for the GET could not be handled
IOException - if an input or output error is detected when the servlet handles the request
See Also:
AbstractWebConsolePlugin.renderContent(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

getResourceProvider

protected Object getResourceProvider()
Returns the registered plugin class to be able to call the getResource() method on that object for this plugin to provide additional resources.

Overrides:
getResourceProvider in class AbstractWebConsolePlugin
Returns:
The resource provider object or null if no resources will be provided by this plugin.
See Also:
AbstractWebConsolePlugin.getResourceProvider()

init

public void init(ServletConfig config)
          throws ServletException
Initializes this servlet as well as the plugin servlet.

Specified by:
init in interface Servlet
Overrides:
init in class GenericServlet
Parameters:
config - the ServletConfig object that contains configutation information for this servlet
Throws:
ServletException - if an exception occurs that interrupts the servlet's normal operation
See Also:
GenericServlet.init(javax.servlet.ServletConfig)

isHtmlRequest

protected boolean isHtmlRequest(HttpServletRequest request)
Detects whether this request is intended to have the headers and footers of this plugin be rendered or not. The decision is taken based on whether and what extension the request URI has: If the request URI has no extension or the the extension is .html, the request is assumed to be rendered with header and footer. Otherwise the headers and footers are omitted and the renderContent(HttpServletRequest, HttpServletResponse) method is called without any decorations and without setting any response headers.

Overrides:
isHtmlRequest in class AbstractWebConsolePlugin
Parameters:
request - the original request passed from the HTTP server
Returns:
true if the page should have headers and footers rendered
See Also:
AbstractWebConsolePlugin.isHtmlRequest(javax.servlet.http.HttpServletRequest)

service

public void service(ServletRequest req,
                    ServletResponse resp)
             throws ServletException,
                    IOException
Directly refer to the plugin's service method unless the request method is GET in which case we defer the call into the service method until the abstract web console plugin calls the renderContent(HttpServletRequest, HttpServletResponse) method.

Specified by:
service in interface Servlet
Overrides:
service in class HttpServlet
Parameters:
req - the HttpServletRequest object that contains the request the client made of the servlet
resp - the HttpServletResponse object that contains the response the servlet returns to the client
Throws:
ServletException - if the request for the TRACE cannot be handled
IOException - if an input or output error occurs while the servlet is handling the TRACE request
See Also:
HttpServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)

destroy

public void destroy()
Destroys this servlet as well as the plugin servlet.

Specified by:
destroy in interface Servlet
Overrides:
destroy in class GenericServlet
See Also:
GenericServlet.destroy()


Copyright © 2011 Apache Software Foundation. All Rights Reserved.