org.jboss.mx.util
Class JBossNotificationFilterSupport

java.lang.Object
  extended by org.jboss.mx.util.JBossNotificationFilterSupport
All Implemented Interfaces:
Serializable, NotificationFilter

public class JBossNotificationFilterSupport
extends Object
implements NotificationFilter, Serializable

A replacement for NotificationFilterSupport that avoids synchronization when reading the enabled notification types by using copy-on-write semantics. Reading operation operate on the latest snapshot of the enabledTypes. Mutating operations synchronize on 'this', only because of the addIfAbsent logic in enableType(). This could be avoided by using java.util.concurrent or EDU.oswego.cs.dl.util.concurrent directly, rather than org.jboss.util.CollectionsFactory. In any case, mutating operations are rare when dealing with NotificationFilters. The common usage is to configure it once and be done with it.

Since:
4.0.3
Version:
$Revision: 1.1.2.2 $
Author:
Dimitris Andreadis.
See Also:
Serialized Form

Constructor Summary
JBossNotificationFilterSupport()
          Default CTOR.
 
Method Summary
 void disableAllTypes()
          Disable all notification types.
 void disableType(String type)
          Disable a notification type.
 void enableType(String type)
          Enable a notification type.
 Vector getEnabledTypes()
          Get all the enabled notification types.
 boolean isNotificationEnabled(Notification notification)
          Test to see whether this notification is enabled
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JBossNotificationFilterSupport

public JBossNotificationFilterSupport()
Default CTOR. Create a filter that filters out all notification types.

Method Detail

disableAllTypes

public void disableAllTypes()
Disable all notification types. Rejects all notifications.


disableType

public void disableType(String type)
Disable a notification type.

Parameters:
type - the notification type to disable.

enableType

public void enableType(String type)
                throws IllegalArgumentException
Enable a notification type.

Parameters:
type - the notification type to enable.
Throws:
IllegalArgumentException - for a null type

getEnabledTypes

public Vector getEnabledTypes()
Get all the enabled notification types.

Returns a vector of enabled notification type.
An empty vector means all types disabled.

Returns:
the vector of enabled types.

toString

public String toString()
Overrides:
toString in class Object
Returns:
human readable string.

isNotificationEnabled

public boolean isNotificationEnabled(Notification notification)
Test to see whether this notification is enabled

Specified by:
isNotificationEnabled in interface NotificationFilter
Parameters:
notification - the notification to filter
Returns:
true when the notification should be sent, false otherwise
Throws:
IllegalArgumentException - for null notification.


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.