DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
The Apache Felix Web Console is extensible in various ways described on this page.
Providing Web Console Plugins
The Web Console can be extended by registering an OSGi service for the interface javax.servlet.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.
The most basic plugin is a plain old Servlet whose service(ServletRequest, ServletResponse) method is called by the Apache Felix Web Console. Before calling the servlet the web console sets two request attributes helping the plugin rendering the response:
felix.webconsole.appRoot– This request attribute of typeStringprovides 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 (fromHttpServletRequest.getServletPath(),/system/consoleby default). This attribute can be used to provide absolute links to resources (images, CSS, scripts, etc.) or other plugins.felix.webconsole.labelMap– This request attribute of typeMapprovides 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 theAbstractWebConsolePlugin.renderTopNavigationmethod does. The keys and values of the map are of typeString.
To help rendering the response the Apache Felix Web Console bundle provides two options: One option is to extend the AbstractWebConsolePlugin overwriting the renderContent method. The other option is to register the servlet with another service registration property to indicate the desire to wrap the response.
Extending The AbstractWebConsolePlugin
To leverage the rendering of the common header and footer around the plugin's data area, the plugin can extend the abstract org.apache.felix.webconsole.AbstractWebConsolePlugin class implementing the following methods:
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 thefelix.webconsole.labelservice registration propery is set.getTitle()– Returns a human readable title to be displayed at the top of the plugin page.
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:
activateBundle(BundleContext)– Initializes the plugin with theBundleContextand prepares some data to be rendered in the header and footer areas.deactivate()– Destroys the plugin.
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.
Transparent Response Wrapping
While being very simple and straight forward, extending the AbstractWebConsolePlugin actually creates a binding from the plugin provider bundle to the Web Console bundle, which may be undesired. To support the use case of wanting the benefits of the AbstractWebConsolePlugin but wiring independency of the Web Console, a plugin servlet may be registered with a second service registration property (besides the required felix.webconsole.label):
felix.webconsole.title– If registered servlet does not extend theAbstractWebConsolePluginbut provides this property (of typeString) the servlet is wrapped in an adapter to theAbstractWebConsolePluginwhich callsServlet.service(ServletRequest, ServletResponse)method on behalf of therenderContentimplementation.
The wrapper around the plugin itself extends the AbstractWebConsolePlugin as follows:
renderContext(HttpServletRequest, HttpServletResponse)– Calls theservice(HttpServletRequest, HttpServletResponse)method of the plugin to render the actual contents of the plugin.getLabel()– Returns the value of thefelix.webconsole.labelservice registration property of the plugin.getTitle()– Returns the value of thefelix.webconsole.titleservice registration property of the plugin.service(ServletRequest, ServletResponse)– If the request method isGETtheservice(ServletRequest, ServletResponse)method of theAbstractWebConsolePluginis called which ultimately calls therenderContentmethod. For all other requests, theservice(ServletRequest, ServletResponse)method of the plugin is called directly to have the plugin handle any non-GETrequests directly.
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.
Providing Resources
ResourceProvider && getResource && spool
Branding the Web Console
Branding the Web Consle mainly concerns hooking into the looks of the Web Console providing vendor-provided setup like
- CSS
- Logo
- Main Title
- Vendor URL
Branding support is currently work in progress tracked by FELIX-1015.
Further issues with respect to extensions
Task FELIX-1013 regarding extensibility of the web console is maintained in our resource tracking system. Please create issues regarding extensibility as subtasks of this master task or at least link to the master task as being related.
The following issues are already listed as part of FELIX-1013:
- Hardcoded list of webconsole plugins in OSGiManager (FELIX-1014).
- Support WebConsole plugins without requiring extending the AbstractWebConsolePlugin (FELIX-1043).
- It is currently not yet resolved how to add resources in plugins (FELIX-1211).