XmlBlaster Logo

REQUIREMENT

mime.plugin.accessfilter.howto

XmlBlaster Logo


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

XmlBlaster allows to code your own specific plugins to filter messages looking into their content. 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/ContentLenFilter.java showing how to code your plugin. Just take a copy of this and change the parts you want.

Note that each plugin type is loaded only once (it is a singleton in Global scope), this instance handles all clients which have configured it on subscribe() or get() calls

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_AccessFilter
    The main things here are
    • Code your filter rules in the method match(), return true if you accept the message or return false if you want to filter it away. Please read the Javadoc of the match() message 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 ContentLenFilter.
    MimeAccessPlugin[ContentLenFilter][1.0]=
          org.xmlBlaster.engine.mime.demo.ContentLenFilter
      
    Clients address the plugin when they subscribe with the filter type of the subscribe QoS:
    
       <filter type='ContentLenFilter' version='1.0'>
          8000
       </filter>
    
      
    The version='1.0' is default and may be omitted. 8000 is the query string, it is for this plugin the max message content size in bytes.
  • You can pass optional parameters to your plugin
    This entry registers the plugin ContentLenFilter in xmlBlaster.properties and adds some options (needs to be in one line).
    MimeAccessPlugin[ContentLenFilter][1.0]=
     org.xmlBlaster.engine.mime.demo.ContentLenFilter,
            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 ContentLenFilter.java (link below).

   
Configure

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_AccessFilter
See API org.xmlBlaster.engine.mime.demo.ContentLenFilter
See API org.xmlBlaster.contrib.mime.DropIfNotDeliverable
See API org.xmlBlaster.util.plugin.I_Plugin
See REQ mime.plugin.accessfilter
See REQ mime.plugin.access.regex
See REQ util.property.env
See TEST org.xmlBlaster.test.mime.TestSubscribeFilter
See TEST org.xmlBlaster.test.mime.TestGetFilter

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

Back to overview