org.apache.felix.webconsole
Class SimpleWebConsolePlugin

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.SimpleWebConsolePlugin
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public abstract class SimpleWebConsolePlugin
extends AbstractWebConsolePlugin

SimpleWebConsolePlugin is an utility class that provides default implementation of the AbstractWebConsolePlugin and supports the following features:

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.felix.webconsole.AbstractWebConsolePlugin
ATTR_FILEUPLOAD, GET_RESOURCE_METHOD_NAME
 
Constructor Summary
SimpleWebConsolePlugin(java.lang.String label, java.lang.String title, java.lang.String[] css)
          Creates new Simple Web Console Plugin with the default category (null)
SimpleWebConsolePlugin(java.lang.String label, java.lang.String title, java.lang.String category, java.lang.String[] css)
          Creates new Simple Web Console Plugin with the given category.
 
Method Summary
 void deactivate()
          This method will close all service trackers, created by getService(String) method.
 java.lang.String getCategory()
          This method should return category string which will be used to render the plugin in the navigation menu.
protected  java.lang.String[] getCssReferences()
          Returns a list of CSS reference paths or null if no additional CSS files are provided by the plugin.
 java.lang.String getLabel()
          Retrieves the label.
protected  java.net.URL getResource(java.lang.String path)
          Called internally by AbstractWebConsolePlugin to load resources.
 java.lang.Object getService(java.lang.String serviceName)
          Gets the service with the specified class name.
 java.lang.String getTitle()
          Retrieves the title of the plug-in.
 SimpleWebConsolePlugin register(org.osgi.framework.BundleContext bc)
          This is an utility method.
 void unregister()
          An utility method that removes the service, registered by the register(BundleContext) method.
 
Methods inherited from class org.apache.felix.webconsole.AbstractWebConsolePlugin
activate, doGet, endResponse, getBrandingPlugin, getBundle, getBundleContext, getParameter, getResourceProvider, getServletName, isHtmlRequest, log, log, readTemplateFile, renderContent, renderMenu, renderTopNavigation, sendRedirect, setBrandingPlugin, setLogLevel, startResponse
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleWebConsolePlugin

public SimpleWebConsolePlugin(java.lang.String label,
                              java.lang.String title,
                              java.lang.String[] css)
Creates new Simple Web Console Plugin with the default category (null)

Parameters:
label - the front label. See AbstractWebConsolePlugin.getLabel()
title - the plugin title . See AbstractWebConsolePlugin.getTitle()
css - the additional plugin CSS. See AbstractWebConsolePlugin.getCssReferences()

SimpleWebConsolePlugin

public SimpleWebConsolePlugin(java.lang.String label,
                              java.lang.String title,
                              java.lang.String category,
                              java.lang.String[] css)
Creates new Simple Web Console Plugin with the given category.

Parameters:
label - the front label. See AbstractWebConsolePlugin.getLabel()
title - the plugin title . See AbstractWebConsolePlugin.getTitle()
category - the plugin's navigation category. See AbstractWebConsolePlugin.getCategory()
css - the additional plugin CSS. See AbstractWebConsolePlugin.getCssReferences()
Method Detail

getLabel

public final java.lang.String getLabel()
Description copied from class: AbstractWebConsolePlugin
Retrieves the label. This is the last component in the servlet path. This method MUST be overridden, if the AbstractWebConsolePlugin.AbstractWebConsolePlugin() constructor is used.

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

getTitle

public final java.lang.String getTitle()
Description copied from class: AbstractWebConsolePlugin
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 the AbstractWebConsolePlugin.AbstractWebConsolePlugin() constructor is used.

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

getCategory

public java.lang.String getCategory()
Description copied from class: AbstractWebConsolePlugin
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 define felix.webconsole.category OSGi property. Currently only single level categories are supported. So, this should be a simple String.

Overrides:
getCategory in class AbstractWebConsolePlugin
Returns:
category
See Also:
AbstractWebConsolePlugin.getCategory()

getCssReferences

protected final java.lang.String[] getCssReferences()
Description copied from class: AbstractWebConsolePlugin
Returns a list of CSS reference paths or null if no additional CSS files are provided by the plugin.

The result is an array of strings which are used as the value of the href attribute 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 the WebConsoleConstants.ATTR_APP_ROOT request attribute.

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()

getResource

protected java.net.URL getResource(java.lang.String path)
Called internally by AbstractWebConsolePlugin to load resources. This particular implementation depends on the label. As example, if the plugin is accessed as /system/console/abc, and the plugin resources are accessed like /system/console/abc/res/logo.gif, the code here will try load resource /res/logo.gif from the bundle, providing the plugin.

Parameters:
path - the path to read.
Returns:
the URL of the resource or null if not found.

register

public final SimpleWebConsolePlugin register(org.osgi.framework.BundleContext bc)
This is an utility method. It is used to register the plugin service. Don't forget to call the unregister() when the plugin is no longer needed.

Parameters:
bc - the bundle context used for service registration.
Returns:
self

unregister

public final void unregister()
An utility method that removes the service, registered by the register(BundleContext) method.


getService

public final java.lang.Object getService(java.lang.String serviceName)
Gets the service with the specified class name. Will create a new ServiceTracker if the service is not already got.

Parameters:
serviceName - the service name to obtain
Returns:
the service or null if missing.

deactivate

public void deactivate()
This method will close all service trackers, created by getService(String) method. If you override this method, don't forget to call the super.

Overrides:
deactivate in class AbstractWebConsolePlugin
See Also:
AbstractWebConsolePlugin.deactivate()


Copyright © 2006-2013 The Apache Software Foundation. All Rights Reserved.