xmlBlaster 2.2.0 API

org.xmlBlaster.engine.mime
Interface I_AccessFilter

All Known Implementing Classes:
ContentLenFilter, DropIfNotDeliverable, DropIfNotDeliverableUniqueOnly, GnuRegexFilter, Sql92Filter, XPathFilter

public interface I_AccessFilter

This interface hides the real protocol used to check messages.

The interface may be used to filter messages on subscribe() or get() access. Only messages where the match() method returns true are sent via update() to the client

Note that you are not allowed to manipulate the content or XmlKey or QoS of a message with your plugin as this would affect all other subscribers (you are working on a reference to the original message).

The plugin with your filter rules must implement this interface.

Steps to add a new plugin:

Version:
$Revision: 1.10 $
Author:
xmlBlaster@marcelruff.info

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 types for which this plugin applies, "*" is for all mime types
 java.lang.String getName()
          Get a human readable name of this filter implementation
 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()
           
 

Method Detail

initialize

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

Parameters:
glob - The Global handle of this xmlBlaster server instance.

getName

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


getMimeTypes

java.lang.String[] getMimeTypes()
Get the content MIME types for which this plugin applies, "*" is for all mime types

Returns:
The supported mime types, for example return { "text/plain", "text/xml", "application/mytext" };

getMimeExtended

java.lang.String[] getMimeExtended()
Get the content MIME version number for which this plugin applies. The returned String array length must be the same as this of getMimeTypes(), the index corresponds to the index of getMimeTypes().
For example "stable" is the extended mime type of "application/mytext" (see getMimeTypes()).

Returns:
E.g. a string array like { "1.0", "1.3", "stable" }

match

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

Note that you are not allowed to manipulate the content or XmlKey or QoS of a message with your plugin as this would affect all other subscribers (you are working on a reference to the original message). You can find out the publisher name like msgUnit.getQosData().getSender()

Parameters:
receiver - The session object describing the receiver, is never null.
msgUnit - The message to check, is never null.
query - The query containing the filter rule on subscribe/get usually the client defines his own rule which is passed here.
null: If for a subscribe() or get() no rule is given, your plugin needs to have its own general rule or react how it likes.
Access the raw query string with query.getQuery(), you can parse it and store the prepared query with query.setPreparedQuery() - query.getPreparedQuery() to increase performance.
Returns:
true If the filter matches this message, else false
Throws:
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.

shutdown

void shutdown()

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.