xmlBlaster 2.1.0 API

org.xmlBlaster.contrib.htmlmonitor
Class HtmlMonitorPlugin

java.lang.Object
  extended by org.xmlBlaster.contrib.htmlmonitor.HtmlMonitorPlugin
All Implemented Interfaces:
I_HttpRequest, I_Plugin

public class HtmlMonitorPlugin
extends java.lang.Object
implements I_Plugin, I_HttpRequest

HtmlMonitorPlugin is a native plugin to build simple HTML monitoring pages.

The HTML pages are available over the tiny xmlBlaster HTTP server.

This plugin needs to be registered in xmlBlasterPlugins.xml to be available on xmlBlaster server startup.

<plugin id='HtmlMonitorPlugin.MyCompany' className='org.xmlBlaster.contrib.htmlmonitor.HtmlMonitorPlugin'>
   <attribute id='urlPath'>/monitor</attribute>
   <attribute id='documentRoot'>${user.home}${file.separator}html</attribute>
   <attribute id='urlPath.CLASSPATH'>/status.html</attribute>
   <action do='LOAD' onStartupRunlevel='9' sequence='6' onFail='resource.configuration.pluginFailed'/>
   <action do='STOP' onShutdownRunlevel='6' sequence='5'/>
</plugin>
 

Setting urlPath to /monitor and documentRoot to /home/xmlblast/html and invoking in the browser http://localhost:3412/monitor/x.html will lookup /home/xmlblast/html/x.html

This plugin uses java.util.logging and redirects the logging to xmlBlasters default logging framework. You can switch this off by setting the attribute xmlBlaster/jdk14loggingCapture to false.

Author:
Marcel Ruff

Field Summary
private  CommandManager commandManager
           
private  java.lang.String documentRoot
           
private  ServerScope global
           
private  HttpIORServer httpServer
           
private static java.util.logging.Logger log
           
private  java.util.Map mimeTypes
           
private  PluginInfo pluginInfo
           
private  ReplaceVariable replaceVariable
           
private  java.util.Set urlPathClasspathSet
           
 
Constructor Summary
HtmlMonitorPlugin()
          Default constructor, you need to call init() thereafter.
 
Method Summary
 java.lang.String get(java.lang.String key, java.lang.String def)
          Access a property.
private  java.lang.String getMimeType(java.lang.String fileName)
           
 java.lang.String getType()
          The plugin name as configured im xmlBlasterPlugins.xml
 java.lang.String getVersion()
          The plugin version as configured in xmlBlasterPlugins.xml
 void init(Global global_, PluginInfo pluginInfo)
          This method is called by the PluginManager.
private  void invokeAction(java.lang.String parameter)
          Checks for parameter in the URL and if it contains an invokeAction part, it starts this action.
private  java.lang.String lookup(java.lang.String query)
          Lookup the given administrative command.
private  java.lang.String replaceAllVariables(java.lang.String template)
          Replace ${...} occurrences.
 HttpResponse service(java.lang.String urlPath, java.util.Map properties)
          A HTTP request needs to be processed
 void shutdown()
          Cleans up the resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static java.util.logging.Logger log

global

private ServerScope global

pluginInfo

private PluginInfo pluginInfo

httpServer

private HttpIORServer httpServer

urlPathClasspathSet

private java.util.Set urlPathClasspathSet

documentRoot

private java.lang.String documentRoot

commandManager

private CommandManager commandManager

replaceVariable

private ReplaceVariable replaceVariable

mimeTypes

private java.util.Map mimeTypes
Constructor Detail

HtmlMonitorPlugin

public HtmlMonitorPlugin()
Default constructor, you need to call init() thereafter.

Method Detail

init

public void init(Global global_,
                 PluginInfo pluginInfo)
          throws XmlBlasterException
Description copied from interface: I_Plugin
This method is called by the PluginManager.

Example how options are evaluated:

   // An entry in xmlBlaster.properties (in one line):
   MimeSubscribePlugin[ContentLenFilter][1.0]=\
                 org.xmlBlaster.engine.mime.demo.ContentLenFilter,\
                 DEFAULT_MAX_LEN=200,DEFAULT_MIN_LEN=20

  // Access it like this:
  java.util.Properties props = pluginInfo.getParameters();
  String maxLen = (String)props.get("DEFAULT_MAX_LEN");
  String throwLen = (String)props.get("THROW_EXCEPTION_FOR_LEN");
 

Specified by:
init in interface I_Plugin
Throws:
XmlBlasterException
See Also:
I_Plugin.init(org.xmlBlaster.util.Global, org.xmlBlaster.util.plugin.PluginInfo)

getType

public java.lang.String getType()
The plugin name as configured im xmlBlasterPlugins.xml

Specified by:
getType in interface I_Plugin
See Also:
I_Plugin.getType()

getVersion

public java.lang.String getVersion()
The plugin version as configured in xmlBlasterPlugins.xml

Specified by:
getVersion in interface I_Plugin
See Also:
I_Plugin.getVersion()

getMimeType

private java.lang.String getMimeType(java.lang.String fileName)

service

public HttpResponse service(java.lang.String urlPath,
                            java.util.Map properties)
A HTTP request needs to be processed

Specified by:
service in interface I_HttpRequest
Parameters:
urlPath - The url path like "/monitor/show.html" or "/status.html" which triggered this call contains the real file name as given in the browser window including the leading slash '/'.
properties - The key values from the browser
Returns:
The HTML page to return

invokeAction

private void invokeAction(java.lang.String parameter)
Checks for parameter in the URL and if it contains an invokeAction part, it starts this action.

Parameters:
parameter - contains the parameter given in the URL.

replaceAllVariables

private java.lang.String replaceAllVariables(java.lang.String template)
                                      throws XmlBlasterException
Replace ${...} occurrences.

Parameters:
template - The template text containing ${}
Returns:
The result text with replaced ${}
Throws:
XmlBlasterException

lookup

private java.lang.String lookup(java.lang.String query)
                         throws XmlBlasterException
Lookup the given administrative command.

Returns:
The result of the command
Throws:
XmlBlasterException

shutdown

public void shutdown()
              throws XmlBlasterException
Description copied from interface: I_Plugin
Cleans up the resource.

Specified by:
shutdown in interface I_Plugin
Throws:
XmlBlasterException - if an exception occurs. The exception is handled by the RunLevelManager depending on how the plugin has been configured with the action:

<action do='STOP' onShutdownRunlevel='2' sequence='5' onFail='resource.configuration.pluginFailed'> If onFail is defined to something, the RunLevelManager will stop.

See Also:
I_Plugin.shutdown()

get

public java.lang.String get(java.lang.String key,
                            java.lang.String def)
Access a property.

Parameters:
key - The key to lookup
def - The default to return if key is not found
Returns:
The found value

xmlBlaster 2.1.0 API

Copyright © 1999-2011 The xmlBlaster.org contributers.