xmlBlaster 2.1.0 API

org.xmlBlaster.engine.mime.demo
Class ContentLenFilter

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

public class ContentLenFilter
extends java.lang.Object
implements I_Plugin, I_AccessFilter

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

Message which are longer then the max length are used to filter subscribed messages, they are not send via updated() to the subscriber. The same filter may be used for the synchronous get() access.

Please register this plugin in xmlBlaster.properties:

 MimeAccessPlugin[ContentLenFilter][1.0]=org.xmlBlaster.engine.mime.demo.ContentLenFilter
 
Plugins must implement the I_Plugin interface to be loadable by the PluginManager and must implement the I_AccessFilter 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 TestAccess.java only to force an XmlBlasterException
 
Constructor Summary
ContentLenFilter()
           
 
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.
 void initialize(ServerScope glob)
          This is called after instantiation of the plugin
 boolean match(SessionInfo receiver, MsgUnit msgUnit, Query query)
          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 TestAccess.java only to force an XmlBlasterException

Constructor Detail

ContentLenFilter

public ContentLenFilter()
Method Detail

initialize

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

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

init

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

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

getType

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

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

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_AccessFilter
Returns:
"ContentLenFilter"

getMimeTypes

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

Specified by:
getMimeTypes in interface I_AccessFilter
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_AccessFilter
Returns:
"1.0" (this is the default version number)

match

public boolean match(SessionInfo receiver,
                     MsgUnit msgUnit,
                     Query query)
              throws XmlBlasterException
Check if the filter rule matches for this message.

Specified by:
match in interface I_AccessFilter
Parameters:
msgUnit - The message to check
query - The max. message length as given by the subscriber/getter.
If null we use 1 MByte as max size
receiver - The session object describing the receiver, is never null.
Returns:
true If message is not too long
Throws:
see - I_AccessFilter#match()
XmlBlasterException - Is thrown on problems, for example if the MIME type does not fit to message content.
Take care throwing an exception, the message is not updated and an error is logged and the message is sent as dead letter. (see TopicHandler.java:1032). It is best to return 'false' instead and handle the situation yourself.
See Also:
I_AccessFilter#match(SessionInfo, SessionInfo, MsgUnit, Query)

shutdown

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

Specified by:
shutdown in interface I_AccessFilter
Specified by:
shutdown in interface I_Plugin

xmlBlaster 2.1.0 API

Copyright © 1999-2011 The xmlBlaster.org contributers.