1 package org.jboss.mx.remoting.event; 2 3 import javax.management.Notification ; 4 import javax.management.NotificationFilter ; 5 6 12 public class CompositeEventFilter implements NotificationFilter 13 { 14 static final long serialVersionUID = -4670317046721324670L; 15 public static final int AND = 0; 16 public static final int OR = 1; 17 18 protected int operator = AND; 19 protected NotificationFilter filters[]; 20 21 24 public CompositeEventFilter(NotificationFilter filters[], int operator) 25 { 26 this.filters = filters; 27 this.operator = operator; 28 } 29 30 33 public CompositeEventFilter(NotificationFilter filters[]) 34 { 35 this(filters, AND); 36 } 37 38 public boolean isNotificationEnabled(Notification event) 39 { 40 Class cl = event.getClass(); 41 for(int c = 0; c < filters.length; c++) 42 { 43 if(operator == AND) 44 { 45 if(filters[c] != null && filters[c].isNotificationEnabled(event) == false) 46 { 47 return false; 48 } 49 } 50 else 51 { 52 if(filters[c] != null && filters[c].isNotificationEnabled(event)) 53 { 54 return true; 55 } 56 } 57 } 58 return (operator == AND ? true : false); 59 } 60 } 61 62 | Popular Tags |