public abstract class AbstractWebConsolePlugin
extends HttpServlet
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.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ATTR_FILEUPLOAD
The name of the request attribute containing the map of FileItems from the POST request
|
static java.lang.String |
ATTR_FILEUPLOAD_REPO
The name of the request attribute containing a
File - upload repository path used by
DiskFileItemFactory . |
static java.lang.String |
GET_RESOURCE_METHOD_NAME
Web Console Plugin typically consists of servlet and resources such as images,
scripts or style sheets.
|
Constructor and Description |
---|
AbstractWebConsolePlugin() |
Modifier and Type | Method and Description |
---|---|
void |
activate(BundleContext bundleContext)
This method is called from the Felix Web Console to ensure the
AbstractWebConsolePlugin is correctly setup.
|
void |
deactivate()
This method is called, by the Web Console to de-activate the plugin and release
all used resources.
|
static BrandingPlugin |
getBrandingPlugin()
Returns the
BrandingPlugin currently used for web console
branding. |
Bundle |
getBundle()
Returns the
Bundle pertaining to the
bundle context with which this plugin has
been activated. |
java.lang.String |
getCategory()
This method should return category string which will be used to render
the plugin in the navigation menu.
|
abstract java.lang.String |
getLabel()
Retrieves the label.
|
static java.lang.String |
getParameter(HttpServletRequest request,
java.lang.String name)
Deprecated.
|
java.lang.String |
getServletName()
Returns the title for this plugin as returned by
getTitle() |
abstract java.lang.String |
getTitle()
Retrieves the title of the plug-in.
|
void |
log(int level,
java.lang.String message)
Calls the
ServletContext.log(String) method if the
configured log level is less than or equal to the given level . |
void |
log(int level,
java.lang.String message,
java.lang.Throwable t)
Calls the
ServletContext.log(String, Throwable) method if
the configured log level is less than or equal to the given
level . |
static void |
setBrandingPlugin(BrandingPlugin brandingPlugin)
Sets the
BrandingPlugin to use globally by all extensions of
this class for branding. |
static void |
setLogLevel(int logLevel)
Sets the log level to be applied for calls to the
log(int, String)
and log(int, String, Throwable) methods. |
public static final java.lang.String ATTR_FILEUPLOAD
public static final java.lang.String ATTR_FILEUPLOAD_REPO
File
- upload repository path used by
DiskFileItemFactory
.The Web Console plugin, that utilizes file upload capabilities of the web console SHOULD:
org.osgi.framework.BundleContext#getDataFile(String)
WebConsoleUtil.getParameter(HttpServletRequest, String)
to obtain the file(s)
public static final java.lang.String GET_RESOURCE_METHOD_NAME
getResourceProvider()
,
Constant Field Valuespublic java.lang.String getServletName()
getTitle()
GenericServlet
public java.lang.String getCategory()
felix.webconsole.category
OSGi property. Currently only
single level categories are supported. So, this should be a simple
String.public void activate(BundleContext bundleContext)
bundleContext
- the context of the plugin bundlepublic void deactivate()
public abstract java.lang.String getLabel()
AbstractWebConsolePlugin()
constructor is used.public abstract java.lang.String getTitle()
AbstractWebConsolePlugin()
constructor is used.public final Bundle getBundle()
Bundle
pertaining to the
bundle context
with which this plugin has
been activated. If the plugin has not be activated by calling the
activate(BundleContext)
method, this method returns
null
.null
if the plugin is not activated.public void log(int level, java.lang.String message)
ServletContext.log(String)
method if the
configured log level is less than or equal to the given level
.
Note, that the level
paramter is only used to decide whether
the GenericServlet.log(String)
method is called or not. The
actual implementation of the GenericServlet.log
method is
outside of the control of this method.
If the servlet has not been initialized yet or has already been destroyed the message is printed to stderr.
level
- The log level at which to log the messagemessage
- The message to logpublic void log(int level, java.lang.String message, java.lang.Throwable t)
ServletContext.log(String, Throwable)
method if
the configured log level is less than or equal to the given
level
.
Note, that the level
paramter is only used to decide whether
the GenericServlet.log(String, Throwable)
method is called
or not. The actual implementation of the GenericServlet.log
method is outside of the control of this method.
level
- The log level at which to log the messagemessage
- The message to logt
- The Throwable
to log with the messagepublic static final java.lang.String getParameter(HttpServletRequest request, java.lang.String name)
WebConsoleUtil.getParameter(HttpServletRequest, String)
ATTR_FILEUPLOAD
. The attribute value is a Map
where the key is a String specifying the field name and the value
is a FileItem
.request
- the HTTP request coming from the username
- the name of the parameternull
if not set. If multipart is used,
and the specified parameter is field - then the value of the parameter
is returned.public static BrandingPlugin getBrandingPlugin()
BrandingPlugin
currently used for web console
branding.public static final void setBrandingPlugin(BrandingPlugin brandingPlugin)
BrandingPlugin
to 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.
brandingPlugin
- the brandingPlugin to setpublic static final void setLogLevel(int logLevel)
log(int, String)
and log(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.
logLevel
- the maximum allowed log level. If message is logged with
lower level it will not be forwarded to the logger."Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"