1 package com.ubermq.jms.common.routing.impl; 2 3 import com.ubermq.jms.common.datagram.*; 4 import com.ubermq.jms.common.routing.*; 5 import com.ubermq.kernel.*; 6 import java.io.*; 7 8 13 public class SelectorSourceSpec 14 implements SourceSpec 15 { 16 private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(SelectorSourceSpec.class); 17 18 private SourceSpec delegate; 19 private Selector selector; 20 21 public SelectorSourceSpec(SourceSpec delegate, Selector selector) 22 { 23 this.delegate = delegate; 24 this.selector = selector; 25 log.debug("selector is " + this.selector.toString()); 26 } 27 28 41 public boolean matches(SourceDescriptor other) 42 { 43 if (this.delegate.matches(other)) 44 { 45 if (other instanceof MessageDatagramSourceDescriptor) 46 { 47 MessageDatagramSourceDescriptor mdsd = (MessageDatagramSourceDescriptor)other; 48 49 log.debug("delegate would forward " + mdsd + " checking selector..."); 50 boolean accept = selector.accept(mdsd.getMessageDatagram()); 51 log.debug("selector says " + accept); 52 return accept; 53 } 54 else 55 { 56 log.debug("Unknown source descriptor: " + other); 57 return false; 58 } 59 } 60 else 61 return false; 62 } 63 64 69 public boolean isIdempotentForEqualDescriptors() 70 { 71 return false; 72 } 73 74 public String getDisplayName() 75 { 76 return this.delegate.getDisplayName() + " (with " + selector.toString() + ")"; 77 } 78 79 public boolean equals(Object obj) 80 { 81 return this.delegate.equals(obj); 82 } 83 public int hashCode() 84 { 85 return this.delegate.hashCode(); 86 } 87 public boolean isMoreSpecificThan(SourceSpec other) 88 { 89 return this.delegate.isMoreSpecificThan(other); 90 } 91 public String toString() 92 { 93 return this.delegate.toString(); 94 } 95 } 96 | Popular Tags |