1 18 package org.apache.activemq.network; 19 20 import java.util.concurrent.CopyOnWriteArraySet ; 21 import java.util.concurrent.atomic.AtomicInteger ; 22 23 import org.apache.activemq.command.ConsumerId; 24 import org.apache.activemq.command.ConsumerInfo; 25 26 import java.util.Set ; 27 28 33 public class DemandSubscription{ 34 private ConsumerInfo remoteInfo; 35 private ConsumerInfo localInfo; 36 private Set remoteSubsIds = new CopyOnWriteArraySet (); 37 private AtomicInteger dispatched = new AtomicInteger (0); 38 39 DemandSubscription(ConsumerInfo info){ 40 remoteInfo=info; 41 localInfo=info.copy(); 42 localInfo.setBrokerPath(info.getBrokerPath()); 43 remoteSubsIds.add(info.getConsumerId()); 44 } 45 46 51 public boolean add(ConsumerId id){ 52 return remoteSubsIds.add(id); 53 } 54 55 60 public boolean remove(ConsumerId id){ 61 return remoteSubsIds.remove(id); 62 } 63 64 67 public boolean isEmpty(){ 68 return remoteSubsIds.isEmpty(); 69 } 70 71 72 75 public int getDispatched(){ 76 return dispatched.get(); 77 } 78 79 82 public void setDispatched(int dispatched){ 83 this.dispatched.set(dispatched); 84 } 85 86 89 public int incrementDispatched(){ 90 return dispatched.incrementAndGet(); 91 } 92 93 96 public ConsumerInfo getLocalInfo(){ 97 return localInfo; 98 } 99 100 103 public void setLocalInfo(ConsumerInfo localInfo){ 104 this.localInfo=localInfo; 105 } 106 107 110 public ConsumerInfo getRemoteInfo(){ 111 return remoteInfo; 112 } 113 114 117 public void setRemoteInfo(ConsumerInfo remoteInfo){ 118 this.remoteInfo=remoteInfo; 119 } 120 121 } 122 | Popular Tags |