1 package org.jboss.mx.remoting.event; 2 3 import java.io.Serializable ; 4 import javax.management.BadAttributeValueExpException ; 5 import javax.management.BadBinaryOpValueExpException ; 6 import javax.management.BadStringOperationException ; 7 import javax.management.InvalidApplicationException ; 8 import javax.management.MBeanServer ; 9 import javax.management.ObjectName ; 10 import javax.management.QueryExp ; 11 12 19 public class CompositeQueryExp implements QueryExp , Serializable 20 { 21 static final long serialVersionUID = 6918797787135545210L; 22 23 public static final int AND = 0; 24 public static final int OR = 1; 25 26 private int operator; 27 private QueryExp exps[]; 28 29 34 public CompositeQueryExp(QueryExp exp[]) 35 { 36 this(exp, AND); 37 } 38 39 public CompositeQueryExp(QueryExp exp[], int operator) 40 { 41 this.exps = exp; 42 this.operator = operator; 43 } 44 45 public boolean apply(ObjectName objectName) throws BadStringOperationException , BadBinaryOpValueExpException , BadAttributeValueExpException , InvalidApplicationException 46 { 47 for(int c = 0; c < exps.length; c++) 48 { 49 if(exps[c] != null) 50 { 51 boolean value = exps[c].apply(objectName); 52 if(value && operator == OR) 53 { 54 return true; 55 } 56 else if(!value && operator == AND) 57 { 58 return false; 59 } 60 } 61 } 62 return (operator == AND) ? true : false; 63 } 64 65 public void setMBeanServer(MBeanServer mBeanServer) 66 { 67 for(int c = 0; c < exps.length; c++) 68 { 69 if(exps[c] != null) 70 { 71 exps[c].setMBeanServer(mBeanServer); 72 } 73 } 74 } 75 } 76 | Popular Tags |