xmlBlaster 2.2.0 API

org.xmlBlaster.engine.mime.demo
Class PublishLenChecker

java.lang.Object
  extended by org.xmlBlaster.engine.mime.demo.PublishLenChecker
All Implemented Interfaces:
I_PublishFilter, I_Plugin

public class PublishLenChecker
extends java.lang.Object
implements I_Plugin, I_PublishFilter

This demo plugin filters away all messages having a content longer than the given filter length.

Published messages which are longer then the max length are rejected.

Please register this plugin in xmlBlaster.properties:

 MimePublishPlugin[PublishLenChecker][1.0]=org.xmlBlaster.engine.mime.demo.PublishLenChecker
 
Plugins must implement the I_Plugin interface to be loadable by the PluginManager and must implement the I_PublishFilter interface to be usable as a filter.

Author:
xmlBlaster@marcelruff.info

Field Summary
private  long DEFAULT_MAX_LEN
          Limits max message size to 1 MB as a default
private  ServerScope glob
           
private static java.util.logging.Logger log
           
private  java.lang.String ME
           
private  int THROW_EXCEPTION_FOR_LEN
          For testsuite TestPublish.java only to force an XmlBlasterException
 
Constructor Summary
PublishLenChecker()
           
 
Method Summary
 java.lang.String[] getMimeExtended()
          Get the content MIME version number for which this plugin applies
 java.lang.String[] getMimeTypes()
          Get the content MIME type for which this plugin applies
 java.lang.String getName()
          Get a human readable name of this filter implementation
 java.lang.String getType()
          Return plugin type for Plugin loader
 java.lang.String getVersion()
          Return plugin version for Plugin loader
 void init(Global glob, PluginInfo pluginInfo)
          This method is called by the PluginManager (enforced by I_Plugin).
 void initialize(ServerScope glob)
          This is called after instantiation of the plugin
 java.lang.String intercept(SubjectInfo publisher, MsgUnit msgUnit)
          Check if the filter rule matches for this message.
 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

ME

private final java.lang.String ME
See Also:
Constant Field Values

glob

private ServerScope glob

log

private static java.util.logging.Logger log

DEFAULT_MAX_LEN

private long DEFAULT_MAX_LEN
Limits max message size to 1 MB as a default


THROW_EXCEPTION_FOR_LEN

private int THROW_EXCEPTION_FOR_LEN
For testsuite TestPublish.java only to force an XmlBlasterException

Constructor Detail

PublishLenChecker

public PublishLenChecker()
Method Detail

initialize

public void initialize(ServerScope glob)
This is called after instantiation of the plugin

Specified by:
initialize in interface I_PublishFilter
Parameters:
glob - The Global handle of this xmlBlaster server instance.

init

public void init(Global glob,
                 PluginInfo pluginInfo)
This method is called by the PluginManager (enforced by I_Plugin).

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

getType

public java.lang.String getType()
Return plugin type for Plugin loader

Specified by:
getType in interface I_Plugin
Returns:
"PublishLenChecker"

getVersion

public java.lang.String getVersion()
Return plugin version for Plugin loader

Specified by:
getVersion in interface I_Plugin
Returns:
"1.0"

getName

public java.lang.String getName()
Get a human readable name of this filter implementation

Specified by:
getName in interface I_PublishFilter
Returns:
"PublishLenChecker"

getMimeTypes

public java.lang.String[] getMimeTypes()
Get the content MIME type for which this plugin applies

Specified by:
getMimeTypes in interface I_PublishFilter
Returns:
"*" This plugin handles all mime types

getMimeExtended

public java.lang.String[] getMimeExtended()
Get the content MIME version number for which this plugin applies

Specified by:
getMimeExtended in interface I_PublishFilter
Returns:
"1.0" (this is the default version number)

intercept

public java.lang.String intercept(SubjectInfo publisher,
                                  MsgUnit msgUnit)
                           throws XmlBlasterException
Check if the filter rule matches for this message. Please read the I_PublisheFilter.intercept() Javadoc.

Specified by:
intercept in interface I_PublishFilter
Parameters:
publisher - The subject object describing the publisher
msgUnit - The message to check
Returns:
"" or "OK": The message is accepted
Throws:
XmlBlasterException - Is thrown on problems, for example if the MIME type does not fit to message content.
Take care throwing an exception, as the exception is routed back to the publisher. If the publish() had many messages (a MsgUnit[]), all other messages are lost as well. Probably it is best to return 'ERROR' instead and log the situation.
See Also:
I_PublisheFilter#intercept(SubjectInfo, MsgUnit)

shutdown

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

Specified by:
shutdown in interface I_PublishFilter
Specified by:
shutdown in interface I_Plugin

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.