XmlBlaster Logo

REQUIREMENT

mime.plugin.publishfilter.howto

XmlBlaster Logo


Type NEW
Priority HIGH
Status CLOSED
Topic XmlBlaster supports to plugin your own publish message filters
Des
cription

XmlBlaster allows to code your own specific plugins to filter messages looking into their content similar to CORBA interceptors. The plugin is MIME aware, allowing to code different plugins for different message MIME types. A MIME type is for example "text/xml" or "audio/midi" or your own specific message MIME type like "application/cool". The mime type "*" registers the plugin for all message MIME types.

There is an example xmlBlaster/src/java/org/xmlBlaster/engine/mime/demo/PublishLenChecker.java showing how to code your plugin. Just take a copy of this and change the parts you want.

These are the steps to implement your plugin:

  • Your plugin needs to implement the interface I_Plugin
    This allows our plugin manager to load the plugin as specified in xmlBlaster.properties
  • Your plugin needs to implement the interface I_PublishFilter
    The main things here are
    • Code your filter rules in the method intercept(), return "OK" if you accept the message or return an error string like REJECTED if you want to reject it. Please read the Javadoc of the intercept() method about its behavior on exceptions.
    • Return the MIME types and version number this plugin can handle.
  • Register the plugin in xmlBlaster.properties (or on command line)
    This entry registers the plugin PublishLenChecker.
    
    MimePublishPlugin[PublishLenChecker][1.0]=org.xmlBlaster.engine.mime.demo.PublishLenChecker
             
    Clients address the plugin when they publish a message which has a mime type supported by your plugin.
  • You can pass optional parameters to your plugin
    This entry registers the plugin PublishLenChecker in xmlBlaster.properties and adds some options (needs to be in one line).
    
    MimePublishPlugin[PublishLenChecker][1.0]=
      org.xmlBlaster.engine.mime.demo.PublishLenChecker,DEFAULT_MAX_LEN=10000,DEFAULT_MIN_LEN=10
             
    The plugin can access these options in its init() call:
    
    public void init(Global glob, PluginInfo pluginInfo) throws XmlBlasterException {
    
       java.util.Properties props = pluginInfo.getParameters();
    
       String lenStr = (String)props.get("DEFAULT_MAX_LEN");
    
       ...
    }
    
             
Example
Java
For an example look at the code of PublishLenChecker.java (link below).
   
Configure

This parameter registers the plugin with xmlBlaster.

Property Default Description Implemented
MimePublishPlugin[myPlugin][1.0] myPlugin.mycomp.com Give your plugin a nice name, and use this in the first bracket, and give your plugin a version number which you add in the second bracket.
Than pass the class name of your plugin as the property value.
The name/version must be the same which you returned for I_Plugin.getType() and I_Plugin.getVersion().
yes

NOTE: Configuration parameters are specified on command line (-someValue 17) or in the xmlBlaster.properties file (someValue=17). See requirement "util.property" for details.
Columns named Impl tells you if the feature is implemented.
Columns named Hot tells you if the configuration is changeable in hot operation.

See API org.xmlBlaster.engine.mime.I_PublishFilter
See API org.xmlBlaster.engine.mime.demo.PublishLenChecker
See API org.xmlBlaster.util.plugin.I_Plugin
See REQ mime.plugin.publishfilter
See REQ util.property.env
See TEST org.xmlBlaster.test.mime.TestPublishFilter

This page is generated from the requirement XML file xmlBlaster/doc/requirements/mime.plugin.publishfilter.howto.xml

Back to overview