org.apache.felix.ipojo.webconsole
Class IPOJOServlet

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

public class IPOJOServlet
extends org.apache.felix.webconsole.AbstractWebConsolePlugin

iPOJO Plugin for the web console.

Author:
Felix Project Team
See Also:
Serialized Form

Nested Class Summary
private  class IPOJOServlet.RequestInfo
           
 
Field Summary
static java.lang.String ALL
          All constant.
static java.lang.String FACTORY
          Factory constant.
static java.lang.String HANDLER
          Handler constant.
static java.lang.String INSTANCE
          Instance constant.
private  java.util.List<Architecture> m_archs
          List of available Architecture service.
private  java.util.List<Factory> m_factories
          List of available Factories.
private  java.util.List<HandlerFactory> m_handlers
          List of available Handler Factories.
private  java.lang.String m_label
          Label used by the web console.
private  java.lang.String m_title
          Title used by the web console.
private static long serialVersionUID
          UUID.
 
Fields inherited from class org.apache.felix.webconsole.AbstractWebConsolePlugin
ATTR_FILEUPLOAD
 
Constructor Summary
IPOJOServlet(org.osgi.framework.BundleContext bc)
          Creates a IPOJOServlet.
 
Method Summary
private  void addEntry(java.io.PrintWriter pw, java.lang.String header, java.lang.String value)
          Adds a line into a key / value table.
private  java.lang.String addEntry(java.lang.String header, java.lang.String value)
          Gets the HTML code of a key / value table row.
private static java.lang.String getDependencyBindingPolicy(int policy)
          Gets the dependency binding policy as a String.
private static java.lang.String getDependencyState(int state)
          Gets the dependency state as a String.
private  java.lang.String getFactoryLinkIfPossible(InstanceDescription id)
          Gets the factory link if the factory exists.
private static java.lang.String getFactoryState(int state)
          Gets the factory state as a String.
private  InstanceDescription getInstanceDescriptionByName(java.lang.String name)
          Gets the instance description by name.
private  java.lang.String getInstanceLink(java.lang.String name)
          Gets the HTML link targeting this instance.
private  java.lang.String getInstanceList(java.lang.String factory)
          Gets the instance list created by the given factory.
private static java.lang.String getInstanceState(int state)
          Gets the instance state as a String.
private  int getInvalidCount()
          Gets the number of invalid instances.
private  java.lang.String getInvalidHandlerList(HandlerDescription[] hl)
          Gets the list of invalid handler.
 java.lang.String getLabel()
          Gets the plugin label.
private  java.lang.String getProperties(PropertyDescription[] properties)
          Gets component type properties HTML table.
private  java.lang.String getProvidedServiceDetail(HandlerDescription hd)
          Gets provided service details.
private static java.lang.String getProvidedServiceState(int state)
          Gets the provided service state as a String.
private  java.lang.String getRequiredServiceDetail(HandlerDescription hd)
          Gets required service details.
private  java.lang.String getServiceProperties(java.util.Properties properties)
          Gets the HTML list of service properties.
private  java.lang.String getServiceReferenceList(java.util.List<org.osgi.framework.ServiceReference> refs)
          Gets the HTML list containing service references.
 java.lang.String getTitle()
          Gets the plugin title.
private  int getValidCount()
          Gets the number of valid instances.
private  void printFactoryDetail(java.io.PrintWriter pw, java.lang.String name)
          Gets a Factory Detail page.
private  void printFactoryList(java.io.PrintWriter pw)
          Prints the factory list.
private  void printHandlerList(java.io.PrintWriter pw)
          Print the handler list.
private  void printInstanceDetail(java.io.PrintWriter pw, java.lang.String name)
          Gets the page containing instance detail.
private  void printInstanceList(java.io.PrintWriter pw)
          Gets the instance list page.
protected  void renderContent(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Gets the HTML content of the plugin.
 void stop()
          Stop method.
 
Methods inherited from class org.apache.felix.webconsole.AbstractWebConsolePlugin
activate, deactivate, doGet, endResponse, getBundleContext, getParameter, getServletName, renderTopNavigation, sendRedirect, 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
 

Field Detail

FACTORY

public static final java.lang.String FACTORY
Factory constant.

See Also:
Constant Field Values

INSTANCE

public static final java.lang.String INSTANCE
Instance constant.

See Also:
Constant Field Values

HANDLER

public static final java.lang.String HANDLER
Handler constant.

See Also:
Constant Field Values

ALL

public static final java.lang.String ALL
All constant.

See Also:
Constant Field Values

serialVersionUID

private static final long serialVersionUID
UUID.

See Also:
Constant Field Values

m_label

private java.lang.String m_label
Label used by the web console.


m_title

private java.lang.String m_title
Title used by the web console.


m_archs

private java.util.List<Architecture> m_archs
List of available Architecture service.


m_factories

private java.util.List<Factory> m_factories
List of available Factories.


m_handlers

private java.util.List<HandlerFactory> m_handlers
List of available Handler Factories.

Constructor Detail

IPOJOServlet

public IPOJOServlet(org.osgi.framework.BundleContext bc)
Creates a IPOJOServlet. This method activates the plugin.

Parameters:
bc - the bundle context
Method Detail

stop

public void stop()
Stop method. This method deactivates the plugin.


getLabel

public java.lang.String getLabel()
Gets the plugin label.

Specified by:
getLabel in class org.apache.felix.webconsole.AbstractWebConsolePlugin
Returns:
the label
See Also:
AbstractWebConsolePlugin.getLabel()

getTitle

public java.lang.String getTitle()
Gets the plugin title.

Specified by:
getTitle in class org.apache.felix.webconsole.AbstractWebConsolePlugin
Returns:
the title
See Also:
AbstractWebConsolePlugin.getTitle()

getValidCount

private int getValidCount()
Gets the number of valid instances.

Returns:
the number of valid instances.

getInvalidCount

private int getInvalidCount()
Gets the number of invalid instances.

Returns:
the number of invalid instances.

renderContent

protected void renderContent(javax.servlet.http.HttpServletRequest req,
                             javax.servlet.http.HttpServletResponse res)
                      throws javax.servlet.ServletException,
                             java.io.IOException
Gets the HTML content of the plugin.

Specified by:
renderContent in class org.apache.felix.webconsole.AbstractWebConsolePlugin
Parameters:
req - the request
res - the response
Throws:
javax.servlet.ServletException - if the content cannot be computed
java.io.IOException - if an IO Exception occurs
See Also:
AbstractWebConsolePlugin.renderContent(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

printFactoryDetail

private void printFactoryDetail(java.io.PrintWriter pw,
                                java.lang.String name)
Gets a Factory Detail page. This page contains all versions of the factories.

Parameters:
pw - the writer
name - the name of the factory

getProperties

private java.lang.String getProperties(PropertyDescription[] properties)
Gets component type properties HTML table.

Parameters:
properties - the properties to display
Returns:
the HTML code of the table

printInstanceList

private void printInstanceList(java.io.PrintWriter pw)
Gets the instance list page.

Parameters:
pw - the writer

addEntry

private void addEntry(java.io.PrintWriter pw,
                      java.lang.String header,
                      java.lang.String value)
Adds a line into a key / value table.

Parameters:
pw - the writer
header - the key
value - the value (may be HTML code)

addEntry

private java.lang.String addEntry(java.lang.String header,
                                  java.lang.String value)
Gets the HTML code of a key / value table row.

Parameters:
header - the key
value - the value (may be HTML code)
Returns:
the HTML code of the line

getFactoryLinkIfPossible

private java.lang.String getFactoryLinkIfPossible(InstanceDescription id)
Gets the factory link if the factory exists.

Parameters:
id - the factory name
Returns:
the HTML link targetting the detail of the factory or just the factory name.

getInvalidHandlerList

private java.lang.String getInvalidHandlerList(HandlerDescription[] hl)
Gets the list of invalid handler.

Parameters:
hl - the handler description list.
Returns:
the list of invalid handlers.

printInstanceDetail

private void printInstanceDetail(java.io.PrintWriter pw,
                                 java.lang.String name)
Gets the page containing instance detail.

Parameters:
pw - the writer
name - the instance name

getInstanceLink

private java.lang.String getInstanceLink(java.lang.String name)
Gets the HTML link targeting this instance.

Parameters:
name - the instance name
Returns:
the HTML link targetting the instance detail

getServiceProperties

private java.lang.String getServiceProperties(java.util.Properties properties)
Gets the HTML list of service properties.

Parameters:
properties - the properties
Returns:
the HTML code containing the service properties.

getInstanceList

private java.lang.String getInstanceList(java.lang.String factory)
Gets the instance list created by the given factory.

Parameters:
factory - the factory name
Returns:
the HTML list containing the created instances

getServiceReferenceList

private java.lang.String getServiceReferenceList(java.util.List<org.osgi.framework.ServiceReference> refs)
Gets the HTML list containing service references. If the service is provided by an iPOJO instance, the link is inserted.

Parameters:
refs - the references.
Returns:
the HTML list

getProvidedServiceDetail

private java.lang.String getProvidedServiceDetail(HandlerDescription hd)
Gets provided service details.

Parameters:
hd - the provided service handler description or null if not found.
Returns:
the details about provided services

getRequiredServiceDetail

private java.lang.String getRequiredServiceDetail(HandlerDescription hd)
Gets required service details.

Parameters:
hd - the required service handler description or null if not found.
Returns:
the details about required services

getInstanceDescriptionByName

private InstanceDescription getInstanceDescriptionByName(java.lang.String name)
Gets the instance description by name.

Parameters:
name - the instance name
Returns:
the instance description or null if not found

printFactoryList

private void printFactoryList(java.io.PrintWriter pw)
Prints the factory list.

Parameters:
pw - the writer.

printHandlerList

private void printHandlerList(java.io.PrintWriter pw)
Print the handler list.

Parameters:
pw - the writer.

getInstanceState

private static java.lang.String getInstanceState(int state)
Gets the instance state as a String.

Parameters:
state - the state.
Returns:
the String form of the state.

getFactoryState

private static java.lang.String getFactoryState(int state)
Gets the factory state as a String.

Parameters:
state - the state.
Returns:
the String form of the state.

getDependencyState

private static java.lang.String getDependencyState(int state)
Gets the dependency state as a String.

Parameters:
state - the state.
Returns:
the String form of the state.

getDependencyBindingPolicy

private static java.lang.String getDependencyBindingPolicy(int policy)
Gets the dependency binding policy as a String.

Parameters:
policy - the policy.
Returns:
the String form of the policy.

getProvidedServiceState

private static java.lang.String getProvidedServiceState(int state)
Gets the provided service state as a String.

Parameters:
state - the state.
Returns:
the String form of the state.


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