Package org.jboss.errai.bus.client.framework

Examples of org.jboss.errai.bus.client.framework.DeliveryPlan


   * @param subject - the subject of the subscription
   * @param rule    - the <tt>BooleanRoutingRule</tt> instance specifying the routing rules
   */
  @Override
  public void addRule(final String subject, final BooleanRoutingRule rule) {
    DeliveryPlan plan = subscriptions.get(subject);
    if (plan == null) {
      throw new RuntimeException("no such subject: " + subject);
    }

    subscriptions.put(subject, new RuleDelegateMessageCallback(plan, rule));
View Full Code Here


  @Override
  public Subscription subscribe(final String subject, final MessageCallback receiver) {
    if (reservedNames.contains(subject))
      throw new IllegalArgumentException("cannot modify or subscribe to reserved service: " + subject);

    final DeliveryPlan plan = createOrAddDeliveryPlan(subject, receiver);

    globalSubscriptions.add(subject);

    fireSubscribeListeners(new SubscriptionEvent(false, null, plan.getTotalReceivers(), true, subject));

    return new Subscription() {
      @Override
      public void remove() {
        if (removeFromDeliveryPlan(subject, receiver).getTotalReceivers() == 0) {
          globalSubscriptions.remove(subject);
          subscriptions.remove(subject);
        }
        else {
          boolean nonRemote = true;
          for (MessageCallback callback : plan.getDeliverTo()) {
            if (!(callback instanceof RemoteMessageCallback)) {
              nonRemote = false;
              break;
            }
          }
View Full Code Here

    if (reservedNames.contains(subject))
      throw new IllegalArgumentException("cannot modify or subscribe to reserved service: " + subject);

    final String toSubscribe = "local:".concat(subject);

    final DeliveryPlan plan = createOrAddDeliveryPlan(toSubscribe, receiver);

    fireSubscribeListeners(new SubscriptionEvent(false, false, true, true, plan.getTotalReceivers(), "InBus", toSubscribe));

    return new Subscription() {
      @Override
      public void remove() {
        removeFromDeliveryPlan(toSubscribe, receiver);
View Full Code Here

  private DeliveryPlan createOrAddDeliveryPlan(final String subject, final MessageCallback receiver) {
    if (receiver == null) {
      throw new NullPointerException("message callback cannot but null");
    }

    DeliveryPlan plan = subscriptions.get(subject);

    if (plan == null) {
      subscriptions.put(subject, plan = DeliveryPlan.newDeliveryPlan(receiver));
    }
    else {
      subscriptions.put(subject, plan.newDeliveryPlanWith(receiver));
    }

    return plan;
  }
View Full Code Here

    return plan;
  }

  private DeliveryPlan removeFromDeliveryPlan(final String subject, final MessageCallback receiver) {
    DeliveryPlan plan = subscriptions.get(subject);

    if (plan != null) {
      subscriptions.put(subject, plan = plan.newDeliveryPlanWithOut(receiver));
      fireUnsubscribeListeners(
              new SubscriptionEvent(false, "InBus", plan.getTotalReceivers(), false, subject));
    }

    return plan;
  }
View Full Code Here

   * @param rule
   *     - the <tt>BooleanRoutingRule</tt> instance specifying the routing rules
   */
  @Override
  public void addRule(final String subject, final BooleanRoutingRule rule) {
    final DeliveryPlan plan = subscriptions.get(subject);
    if (plan == null) {
      throw new RuntimeException("no such subject: " + subject);
    }

    subscriptions.put(subject, new RuleDelegateMessageCallback(plan, rule));
View Full Code Here

  @Override
  public Subscription subscribe(final String subject, final MessageCallback receiver) {
    if (reservedNames.contains(subject))
      throw new IllegalArgumentException("cannot modify or subscribe to reserved service: " + subject);

    final DeliveryPlan plan = createOrAddDeliveryPlan(subject, receiver);

    globalSubscriptions.add(subject);

    fireSubscribeListeners(new SubscriptionEvent(false, null, plan.getTotalReceivers(), true, subject));

    return new Subscription() {
      @Override
      public void remove() {
        if (removeFromDeliveryPlan(subject, receiver).getTotalReceivers() == 0) {
          globalSubscriptions.remove(subject);
          subscriptions.remove(subject);
        }
        else {
          boolean nonRemote = true;
          for (final MessageCallback callback : plan.getDeliverTo()) {
            if (!(callback instanceof RemoteMessageCallback)) {
              nonRemote = false;
              break;
            }
          }
View Full Code Here

    if (reservedNames.contains(subject))
      throw new IllegalArgumentException("cannot modify or subscribe to reserved service: " + subject);

    final String toSubscribe = "local:".concat(subject);

    final DeliveryPlan plan = createOrAddDeliveryPlan(toSubscribe, receiver);

    fireSubscribeListeners(
        new SubscriptionEvent(false, false, true, true, plan.getTotalReceivers(), "InBus", toSubscribe)
    );

    return new Subscription() {
      @Override
      public void remove() {
View Full Code Here

  private DeliveryPlan createOrAddDeliveryPlan(final String subject, final MessageCallback receiver) {
    if (receiver == null) {
      throw new NullPointerException("message callback cannot but null");
    }

    DeliveryPlan plan = subscriptions.get(subject);

    if (plan == null) {
      subscriptions.put(subject, plan = DeliveryPlan.newDeliveryPlan(receiver));
    }
    else {
      subscriptions.put(subject, plan.newDeliveryPlanWith(receiver));
    }

    return plan;
  }
View Full Code Here

    return plan;
  }

  private DeliveryPlan removeFromDeliveryPlan(final String subject, final MessageCallback receiver) {
    DeliveryPlan plan = subscriptions.get(subject);

    if (plan != null) {
      subscriptions.put(subject, plan = plan.newDeliveryPlanWithOut(receiver));
      fireUnsubscribeListeners(
          new SubscriptionEvent(false, "InBus", plan.getTotalReceivers(), false, subject));
    }

    return plan;
  }
View Full Code Here

TOP

Related Classes of org.jboss.errai.bus.client.framework.DeliveryPlan

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.