xmlBlaster 2.2.0 API

org.xmlBlaster.contrib.mime
Class DropIfNotDeliverable

java.lang.Object
  extended by org.xmlBlaster.contrib.mime.DropIfNotDeliverable
All Implemented Interfaces:
I_AccessFilter, I_ConnectionStatusListener, I_Plugin

public class DropIfNotDeliverable
extends java.lang.Object
implements I_Plugin, I_AccessFilter, I_ConnectionStatusListener

Throw away callback messages and unsubscribe all subscriptions if a client gows to polling.

If a client callback goes to polling, this plugin removes all existing subscriptions and clears all messages in the callback queue.
The client needs to add a filter Qos to its SubscribeQos to activate the plugin.
In a next step we could add configuration parameters to only remove specific subscriptions (and not remove other callback queue entries).

Configuration example (put to xmlBlaster.properties):

 MimeAccessPlugin[DropIfNotDeliverable][1.0]=\
   org.xmlBlaster.contrib.mime.DropIfNotDeliverable,dropper.types=*
 
dropper.types=* is default and activates the plugin for any published message where a subscriber has set this filter,
dropper.types=text/xml;application/xml would for example limit the plugin to such messages having his mime type declared on publish

A typical subscribeQos is for example:

<qos>
   <multiSubscribe>false</multiSubscribe>
   <local>false</local>
   <initialUpdate>false</initialUpdate>
   <updateOneway>false</updateOneway>
   <notify>false</notify>
   <persistent>false</persistent>
   <filter type='DropIfNotDeliverable'>
    <![CDATA[_]]>
   </filter>
</qos>
  

The query statement '_' is ignored by this plugin.

This plugin is a singleton and loaded once only for multiple subscribers configuring it

Author:
Marcel Ruff
See Also:
The mime.plugin.accessfilter requirement

Field Summary
private  Global glob
           
private static java.util.logging.Logger log
           
private  java.lang.String ME
           
static java.lang.String MIME_TYPES
           
private  java.lang.String[] mimeTypes
           
private  PluginInfo pluginInfo
           
 
Constructor Summary
DropIfNotDeliverable()
           
 
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, currently { "*" }.
 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 serverScope)
          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.
 void toAlive(I_DispatchManager dispatchManager, ConnectionStateEnum oldState)
           
 void toAliveSync(I_DispatchManager dispatchManager, ConnectionStateEnum oldState)
           
 void toDead(I_DispatchManager dispatchManager, ConnectionStateEnum oldState, XmlBlasterException xmlBlasterException)
           
 void toPolling(I_DispatchManager dispatchManager, ConnectionStateEnum oldState)
           
 
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 Global glob

log

private static java.util.logging.Logger log

mimeTypes

private java.lang.String[] mimeTypes

pluginInfo

private PluginInfo pluginInfo

MIME_TYPES

public static final java.lang.String MIME_TYPES
See Also:
Constant Field Values
Constructor Detail

DropIfNotDeliverable

public DropIfNotDeliverable()
Method Detail

initialize

public void initialize(ServerScope serverScope)
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 (enforced by I_Plugin).

Specified by:
init in interface I_Plugin
Throws:
XmlBlasterException
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:
"DropIfNotDeliverable"

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:
"DropIfNotDeliverable"

getMimeTypes

public java.lang.String[] getMimeTypes()
Get the content MIME type for which this plugin applies, currently { "*" }. Is configurable with dropper.types=text/xml;image/svg+xml;application/xml

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
Description copied from interface: I_AccessFilter
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()

Specified by:
match in interface I_AccessFilter
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

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

toAlive

public void toAlive(I_DispatchManager dispatchManager,
                    ConnectionStateEnum oldState)
Specified by:
toAlive in interface I_ConnectionStatusListener

toAliveSync

public void toAliveSync(I_DispatchManager dispatchManager,
                        ConnectionStateEnum oldState)
Specified by:
toAliveSync in interface I_ConnectionStatusListener

toDead

public void toDead(I_DispatchManager dispatchManager,
                   ConnectionStateEnum oldState,
                   XmlBlasterException xmlBlasterException)
Specified by:
toDead in interface I_ConnectionStatusListener
xmlBlasterException - Can be null

toPolling

public void toPolling(I_DispatchManager dispatchManager,
                      ConnectionStateEnum oldState)
Specified by:
toPolling in interface I_ConnectionStatusListener

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.