Exemplo n.º 1
0
 @Override
 public SubscriptionResponse addsubscription(
     final long subscriptionid, final String[] subscriptions, final String[] exclusions) {
   final Subscriber subscriber = this.subscribers.get(subscriptionid);
   if (subscriber == null) {
     return new SubscriptionResponse();
   } else {
     synchronized (subscriber.getModifyLock()) {
       if (exclusions != null) {
         final ArrayList<String> newExclusions =
             new ArrayList<String>(Arrays.asList(subscriber.getExclusions()));
         newExclusions.addAll(Arrays.asList(exclusions));
         subscriber.setExclusions(newExclusions.toArray(new String[] {}));
       }
       if (subscriptions != null) {
         final ArrayList<String> newSubscriptions =
             new ArrayList<String>(Arrays.asList(subscriber.getSubscriptions()));
         newSubscriptions.addAll(Arrays.asList(subscriptions));
         subscriber.setSubscriptions(newSubscriptions.toArray(new String[] {}));
       }
     }
     final SubscriptionResponse ret = new SubscriptionResponse(subscriber);
     ret.setSubscribed(true);
     return ret;
   }
 }
Exemplo n.º 2
0
 @Override
 public SubscriptionResponse subscribe(final String[] subscriptions, final String[] exclusions) {
   final Subscriber subscriber = new Subscriber(subscriptions, exclusions);
   this.subscribers.put(subscriber.getSubscriptionID(), subscriber);
   this.subscribersCleanupThread();
   final SubscriptionResponse ret = new SubscriptionResponse(subscriber);
   ret.setSubscribed(true);
   return ret;
 }
Exemplo n.º 3
0
 @Override
 public SubscriptionResponse getsubscription(final long subscriptionid) {
   final Subscriber subscriber = this.subscribers.get(subscriptionid);
   if (subscriber == null) {
     return new SubscriptionResponse();
   } else {
     final SubscriptionResponse ret = new SubscriptionResponse(subscriber);
     ret.setSubscribed(true);
     return ret;
   }
 }
Exemplo n.º 4
0
 @Override
 public SubscriptionResponse changesubscriptiontimeouts(
     final long subscriptionid, final long polltimeout, final long maxkeepalive) {
   final Subscriber subscriber = this.subscribers.get(subscriptionid);
   if (subscriber == null) {
     return new SubscriptionResponse();
   } else {
     subscriber.setMaxKeepalive(maxkeepalive);
     subscriber.setPollTimeout(polltimeout);
     subscriber.notifyListener();
     final SubscriptionResponse ret = new SubscriptionResponse(subscriber);
     ret.setSubscribed(true);
     return ret;
   }
 }