Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

  • felix.webconsole.appRoot – This request attribute of type String provides the absolute path of the Web Console root. This path consists of the servlet context path (from <code>ServletRequest.getContextPath()</code>) and the Web Console servlet path (from HttpServletRequest.getServletPath(), /system/console by default). This attribute can be used to provide absolute links to resources (images, CSS, scripts, etc.) or other plugins. This request attribute is available to client side JavaScript as the global appRoot variable.
  • felix.webconsole.pluginRoot – This request attribute of type String provides the absolute path of the current plugin. This path consists of the servlet context path (from <code>ServletRequest.getContextPath()</code>), the Web Console servlet path (from HttpServletRequest.getServletPath(), /system/console by default) and the plugin label. This attribute can be used to provide absolute links to the plugin itself. This request attribute is available to client side JavaScript as the global pluginRoot variable.
  • felix.webconsole.labelMap – This request attribute of type Map provides a mapping of labels to page titles of registered console plugins. This map may be used to render a navigation of the console plugins such as the AbstractWebConsolePlugin.renderTopNavigation method does. The keys and values of the map are of type String.

...

  • renderContext(HttpServletRequest, HttpServletResponse) – This method is called to render the actual plugin data area.
  • getLabel() – Returns the last path segment of the plugin page. This should return the value to which the felix.webconsole.label service registration propery is set.
  • getTitle() – Returns a human readable title to be displayed at the top of the plugin page.
  • getCssReferences() – See the section Providing CSS Files below.

To fully leverage the AbstractWebConsolePlugin it must be initialiazed before registering the extension as a service. Likewise after unregistering the service, the plugin should be destroyed. To this avail the following methods are provided in the AbstractWebConsolePlugin:

...

In addition to these OSGi-oriented setup methods the Web Console itself will call the Servlet.init(ServletConfig) method before putting the plugin into service and the Servlet.destroy() method when the plugin is removed.

Providing CSS Files

Part of rendering the header, the AbstractWebConsolePlugin also emits links to CSS files to include for displaying the page. Since such CSS links may only be present in the header section of the generated HTML the getCssReferences() method is provided. This method is called to create links for additional CSS files. The default implementation of this method returns null meaning no additional CSS links to be rendered. Extensions of the AbstractWebConsolePlugin may overwrite this method to provide a list of CSS links.

The CSS links provided by the getCssReferences() method may be absolute or relative paths, though relative paths are recommended. Relative paths are turned into absolute path by prepending them with the value of the felix.webconsole.appRoot request attribute.

Transparent Response Wrapping

...

  • felix.webconsole.title – If registered servlet does not extend the AbstractWebConsolePlugin but provides this property (of type String) the servlet is wrapped in an adapter to the AbstractWebConsolePlugin which calls Servlet.service(ServletRequest, ServletResponse) method on behalf of the renderContent implementation.
  • felix.webconsole.css – Defines a single string, an array of strings or a Collection of strings to be used as the values provided by the getCssReferences() method. This property is optional. If this property is missing or if the value does not have the correct type, the getCssReferences() just returns null assuming there are no additional CSS resources to reference.

The wrapper around the plugin itself extends the AbstractWebConsolePlugin as follows:

  • renderContext(HttpServletRequest, HttpServletResponse) – Calls the service(HttpServletRequest, HttpServletResponse) method of the plugin to render the actual contents of the plugin.
  • getLabel() – Returns the value of the felix.webconsole.label service registration property of the plugin.
  • getTitle() – Returns the value of the felix.webconsole.title service registration property of the plugin.
  • getCssReferences() – Returns the values of the felix.webconsole.css service registration property of the plugin.
  • service(ServletRequest, ServletResponse) – If the request method is GET the service(ServletRequest, ServletResponse) method of the AbstractWebConsolePlugin is called which ultimately calls the renderContent service method. For all other requests, the service(ServletRequest, ServletResponse) method of the plugin is called directly to have the plugin handle any non-GET requests directly.

Please note, that sometimes it is not desirable to have the AbstractWebConsolePlugin render the header and footer of the response. For this reason, the AbstractWebConsolePlugin only renders the header and footer if the request to such a wrapped plugin either has no extension or if the extension is .html. For any other extension, e.g. .txt or .json, the header and footer is not rendered and the service method of the plugin is directly called.

It is suggested that plugins extend from the javax.servlet.http.HttpServlet class and implement the appropriate doXxx(HttpServletRequest, HttpServletResponse) methods such as doGet and doPost. In addition, unless non-GET requests are handled through AJAX calls, it is suggested that non-GET requests return a redirect after processing the request.