1 22 package org.jboss.mq; 23 24 import java.io.Serializable ; 25 26 import javax.jms.InvalidSelectorException ; 27 import javax.jms.JMSException ; 28 29 import org.jboss.mq.selectors.Selector; 30 31 40 public class Subscription implements Serializable 41 { 42 44 45 private static final long serialVersionUID = -4045603824932803577L; 46 47 49 50 public int subscriptionId; 51 52 53 public SpyDestination destination; 54 55 56 public String messageSelector; 57 58 59 public boolean destroyDurableSubscription; 60 61 62 public boolean noLocal; 63 64 65 public transient Selector selector; 66 67 68 public transient ConnectionToken connectionToken; 69 70 71 public transient Object clientConsumer; 72 73 75 77 79 85 public Selector getSelector() throws InvalidSelectorException 86 { 87 if (messageSelector == null || messageSelector.trim().length() == 0) 88 return null; 89 90 if (selector == null) 91 selector = new Selector(messageSelector); 92 93 return selector; 94 } 95 96 103 public boolean accepts(SpyMessage.Header header) throws JMSException 104 { 105 if (header.jmsDestination instanceof SpyTopic && noLocal && header.producerClientId.equals(connectionToken.getClientID())) 106 return false; 107 108 Selector ms = getSelector(); 109 if (ms != null && !ms.test(header)) 110 return false; 111 return true; 112 } 113 114 119 public Subscription myClone() 120 { 121 Subscription result = new Subscription(); 122 124 result.subscriptionId = subscriptionId; 125 result.destination = destination; 126 result.messageSelector = messageSelector; 127 result.destroyDurableSubscription = destroyDurableSubscription; 128 result.noLocal = noLocal; 129 130 return result; 131 } 132 133 135 public String toString() 136 { 137 StringBuffer buffer = new StringBuffer (100); 138 buffer.append("Subscription[subId=").append(subscriptionId); 139 if (connectionToken != null) 140 buffer.append("connection=").append(connectionToken); 141 buffer.append(" destination=").append(destination); 142 buffer.append(" messageSelector=").append(messageSelector); 143 if (noLocal) 144 buffer.append(" NoLocal"); 145 else 146 buffer.append(" Local"); 147 if (destroyDurableSubscription) 148 buffer.append(" Destroy"); 149 else 150 buffer.append(" Create"); 151 152 buffer.append(']'); 153 return buffer.toString(); 154 } 155 156 158 160 162 164 } | Popular Tags |