Sonic Management API

com.sonicsw.mf.jmx.client
Class ExpressionBasedNotificationFilter

java.lang.Object
  extended by com.sonicsw.mf.jmx.client.ExpressionBasedNotificationFilter
All Implemented Interfaces:
java.io.Serializable, NotificationFilter

public class ExpressionBasedNotificationFilter
extends java.lang.Object
implements NotificationFilter, java.io.Serializable

This implementation of the javax.management.NotificationFilter interface provides a filter that uses regular expressions to determine which notifications should be sent to associated listeners. The filter is a powerful alternative to the JMX supplied NotificationFilterSupport class, providing the ability to filter on both the notification type and the attribute values of Sonic notifications.

The filter allows specification of a single expression for the notification type and a single expression per attribute. When a notification is tested against the filter (see isNotificationEnabled) the result of testing each expression are AND'd together to form an aggregate result. For example if a type expression such as "application\.session\.Subscribe" and attribute expressions for the attributes "TopicName" and "UserName" of "App1|App2" and "Guest" respectively are specified, then the listener would be sent only application.session.Subscribe notifications that are associated with JMS subscriptions to topics "App1" or "App2" and where the subscribing client's user name is "Guest".

Notifications will not be sent to associated listeners if an attribute expression is specified for an attribute that does not exist in the notification or the attribute exists but its value is null.

All filter expressions are case sensitive.

This filter uses the Java regular expression library when available (J2SE 1.4 or greater) or the GNU regular expression library if not. The libraries must appear on the classpath of the Sonic container hosting the source MBean, but are not generally required on the classpath of the listening management client.

See Also:
Serialized Form

Constructor Summary
ExpressionBasedNotificationFilter()
           
 
Method Summary
 void clearAllAttributeExpressions()
          Clear all previously defined attribute name expressions.
 boolean equals(java.lang.Object obj)
          Compares to see if the given object matches the notification filter.
 java.util.Map getAttributeExpressions()
          Gets previously set attribute expressions keyed by attribute name.
 java.lang.String getTypeExpression()
          Gets a previously set name expression (or null if a name expression has not be set).
 boolean isNotificationEnabled(Notification notification)
          Invoked before sending the specified notification to the listener.
 void setAttributeExpression(java.lang.String attributeName, java.lang.String expression)
          Enable notifications with an attribute that matches the specified expression (and any defined type or other attribute expressions) to be sent to the listener.
 void setTypeExpression(java.lang.String expression)
          Enable notifications the type of which matches the specified expression (and any defined attribute expressions) to be sent to the listener.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionBasedNotificationFilter

public ExpressionBasedNotificationFilter()
Method Detail

clearAllAttributeExpressions

public void clearAllAttributeExpressions()
Clear all previously defined attribute name expressions.


equals

public boolean equals(java.lang.Object obj)
Compares to see if the given object matches the notification filter.

A match will occur if the given object is an ExpressionBasedNotificationFilter with the same type expression and same set of attribute expressions.

Overrides:
equals in class java.lang.Object
Parameters:
obj - The reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.

getAttributeExpressions

public java.util.Map getAttributeExpressions()
Gets previously set attribute expressions keyed by attribute name.


getTypeExpression

public java.lang.String getTypeExpression()
Gets a previously set name expression (or null if a name expression has not be set).


isNotificationEnabled

public boolean isNotificationEnabled(Notification notification)
Description copied from interface: NotificationFilter
Invoked before sending the specified notification to the listener.

Specified by:
isNotificationEnabled in interface NotificationFilter
Parameters:
notification - The notification to be sent.
Returns:
true if the notification has to be sent to the listener, false otherwise.

setAttributeExpression

public void setAttributeExpression(java.lang.String attributeName,
                                   java.lang.String expression)
Enable notifications with an attribute that matches the specified expression (and any defined type or other attribute expressions) to be sent to the listener. Setting the expression to null clears a previously set expression for the given attribute name.


setTypeExpression

public void setTypeExpression(java.lang.String expression)
Enable notifications the type of which matches the specified expression (and any defined attribute expressions) to be sent to the listener. Setting the expression to null clears a previously set expression.


Sonic Management API

Copyright © 2001-2011 Progress Software Corporation. All Rights Reserved.
HTML formatted on 12-Aug-2011.