Examples of MessageCallback


Examples of org.jboss.errai.bus.client.api.MessageCallback

        final String errorTo =
            message.getSubject() + "." + message.getCommandType() + ":Errors:" + ((id == null) ? uniqueNumber() : id);

        if (remoteCallback != null) {
          bus.subscribe(replyTo,
              new MessageCallback() {
                @Override
                public void callback(Message message) {
                  bus.unsubscribeAll(replyTo);
                  if (DefaultRemoteCallBuilder.this.message.getErrorCallback() != null) {
                    bus.unsubscribeAll(errorTo);
                  }
                  remoteCallback.callback(message.get(responseType, "MethodReply"));
                }
              }
          );
          message.set(MessageParts.ReplyTo, replyTo);
        }

        if (message.getErrorCallback() != null) {
          bus.subscribe(errorTo,
              new MessageCallback() {
                @Override
                public void callback(Message m) {
                  bus.unsubscribeAll(errorTo);
                  if (remoteCallback != null) {
                    bus.unsubscribeAll(replyTo);
View Full Code Here

Examples of org.jboss.errai.bus.client.api.MessageCallback

                  public boolean error(Message message, Throwable throwable) {
                    throwable.printStackTrace();
                    return true;
                  }
                })
                .repliesTo(new MessageCallback() {
                  public void callback(Message message) {
                    Window.alert("From Server: " + message.get(String.class, MessageParts.Value));
                  }
                })
                .sendNowWith(bus);
View Full Code Here

Examples of org.jboss.errai.bus.client.api.MessageCallback

                                  final MessageCallback callback,
                                  final boolean local,
                                  final WrappedCallbackHolder callbackHolder) {
    final boolean isNew = !isSubscribed(subject);

    final MessageCallback cb = new MessageCallback() {
      @Override
      public void callback(Message message) {
        try {
          callback.callback(message);
        }
View Full Code Here

Examples of org.jboss.errai.bus.client.api.MessageCallback

    if (isRemoteCommunicationEnabled()) {
      remoteSubscribe(BuiltInServices.ServerEchoService.name());
    }

    directSubscribe(BuiltInServices.ClientBus.name(), new MessageCallback() {
      @Override
      @SuppressWarnings({"unchecked"})
      public void callback(final Message message) {
        switch (BusCommands.valueOf(message.getCommandType())) {
          case RemoteSubscribe:
            if (message.hasPart(MessageParts.SubjectsList)) {
              LogUtil.log("remote services available: " + message.get(List.class, MessageParts.SubjectsList));

              for (String subject : (List<String>) message.get(List.class, MessageParts.SubjectsList)) {
                remoteSubscribe(subject);
              }
            }
            else {
              remoteSubscribe(message.get(String.class, Subject));
            }
            break;

          case RemoteUnsubscribe:
            unsubscribeAll(message.get(String.class, Subject));
            break;

          case CapabilitiesNotice:
            LogUtil.log("received capabilities notice from server. supported capabilities of remote: "
                    + message.get(String.class, MessageParts.CapabilitiesFlags));

            final String[] capabilites = message.get(String.class, MessageParts.CapabilitiesFlags).split(",");

            for (String capability : capabilites) {
              switch (Capabilities.valueOf(capability)) {
                case WebSockets:
                  webSocketUrl = message.get(String.class, MessageParts.WebSocketURL);
                  webSocketToken = message.get(String.class, MessageParts.WebSocketToken);
                  webSocketUpgradeAvailable = true;
                  break;
                case LongPollAvailable:

                  LogUtil.log("initializing long poll subsystem");
                  receiveCommCallback = new LongPollRequestCallback();
                  break;
                case NoLongPollAvailable:
                  receiveCommCallback = new ShortPollRequestCallback();
                  if (message.hasPart(MessageParts.PollFrequency)) {
                    POLL_FREQUENCY = message.get(Integer.class, MessageParts.PollFrequency);
                  }
                  else {
                    POLL_FREQUENCY = 500;
                  }
                  break;
              }
            }

            break;

          case RemoteMonitorAttach:
            break;

          case FinishStateSync:
            if (isInitialized()) {
              return;
            }

            new Timer() {
              @Override
              public void run() {
                LogUtil.log("received FinishStateSync message. preparing to bring up the federation");

                stateSyncInProgress = true;

                for (Runnable deferredSubscr : deferredSubscriptions) {
                  deferredSubscr.run();
                }

                List<String> subjects = new ArrayList<String>();
                for (String s : subscriptions.keySet()) {
                  if (s.startsWith("local:")) continue;
                  if (!remotes.containsKey(s)) subjects.add(s);
                }

                sessionId = message.get(String.class, MessageParts.ConnectionSessionKey);

                remoteSubscribe(BuiltInServices.ServerBus.name());

                encodeAndTransmit(CommandMessage.createWithParts(new HashMap<String, Object>())
                        .toSubject(BuiltInServices.ServerBus.name())
                        .command(RemoteSubscribe)
                        .set(MessageParts.SubjectsList, subjects)
                        .set(PriorityProcessing, "1"));

                encodeAndTransmit(CommandMessage.createWithParts(new HashMap<String, Object>())
                        .toSubject(BuiltInServices.ServerBus.name())
                        .command(BusCommands.FinishStateSync)
                        .set(PriorityProcessing, "1"));


                /**
                 * ... also send RemoteUnsubscribe signals.
                 */
                addSubscribeListener(new SubscribeListener() {
                  @Override
                  public void onSubscribe(SubscriptionEvent event) {
                    if (event.isLocalOnly() || event.getSubject().startsWith("local:")
                            || remotes.containsKey(event.getSubject())) {
                      return;
                    }

                    if (event.isNew()) {
                      encodeAndTransmit(CommandMessage.createWithParts(new HashMap<String, Object>())
                              .toSubject(BuiltInServices.ServerBus.name())
                              .command(RemoteSubscribe)
                              .set(Subject, event.getSubject())
                              .set(PriorityProcessing, "1"));
                    }
                  }
                });

                addUnsubscribeListener(new UnsubscribeListener() {
                  @Override
                  public void onUnsubscribe(SubscriptionEvent event) {
                    encodeAndTransmit(CommandMessage.createWithParts(new HashMap<String, Object>())
                            .toSubject(BuiltInServices.ServerBus.name())
                            .command(RemoteUnsubscribe)
                            .set(Subject, event.getSubject())
                            .set(PriorityProcessing, "1"));
                  }
                });

                subscribe(DefaultErrorCallback.CLIENT_ERROR_SUBJECT, new MessageCallback() {
                  @Override
                  public void callback(Message message) {
                    String errorTo = message.get(String.class, MessageParts.ErrorTo);
                    if (errorTo == null) {
                      logError(message.get(String.class, MessageParts.ErrorMessage),
View Full Code Here

Examples of org.jboss.errai.bus.client.api.MessageCallback

        if (isApplicationScoped(entry.getKey())) {
          /**
           * Register the endpoint as a ApplicationScoped bean.
           */
          bus.subscribe(svcName, new MessageCallback() {
            volatile Object targetBean;

            public void callback(Message message) {
              if (targetBean == null) {
                targetBean = Util.lookupCallbackBean(beanManager, type);
              }

              try {
                contextManager.activateRequestContext();
                callMethod.invoke(targetBean, message);
              }
              catch (Exception e) {
                ErrorHelper.sendClientError(bus, message, "Error dispatching service", e);
              }
              finally {
                contextManager.deactivateRequestContext();
              }
            }
          });
        }
        else {
          /**
           * Register the endpoint as a passivating scoped bean.
           */
          bus.subscribe(svcName, new MessageCallback() {
            public void callback(Message message) {
              try {
                contextManager.activateRequestContext();
                contextManager.activateSessionContext(message);

                callMethod.invoke(Util.lookupCallbackBean(beanManager, type), message);
              }
              catch (Exception e) {
                ErrorHelper.sendClientError(bus, message, "Error dispatching service", e);
              }
              finally {
                contextManager.deactivateRequestContext();
              }
            }
          });
        }
      }
    }

    for (final AnnotatedType<?> type : managedTypes.getServiceEndpoints()) {
      // Discriminate on @Command
      Map<String, Method> commandPoints = new HashMap<String, Method>();
      for (final AnnotatedMethod method : type.getMethods()) {
        if (method.isAnnotationPresent(Command.class)) {
          Command command = method.getAnnotation(Command.class);
          for (String cmdName : command.value()) {
            if (cmdName.equals(""))
              cmdName = method.getJavaMember().getName();
            commandPoints.put(cmdName, method.getJavaMember());
          }
        }
      }

      log.info("Register MessageCallback: " + type);
      final String subjectName = Util.resolveServiceName(type.getJavaClass());

      if (isApplicationScoped(type)) {
        /**
         * Create callback for application scope.
         */

        bus.subscribe(subjectName, new MessageCallback() {
          volatile MessageCallback callback;

          public void callback(final Message message) {
            if (callback == null) {
              callback = (MessageCallback) Util.lookupCallbackBean(beanManager, type.getJavaClass());
            }

            contextManager.activateSessionContext(message);
            contextManager.activateRequestContext();
            contextManager.activateConversationContext(message);
            try {
              callback.callback(message);
            }
            finally {
              contextManager.deactivateRequestContext();
              contextManager.deactivateConversationContext(message);
            }
          }
        });
      }
      else {
        /**
         * Map passitivating scope.
         */
        bus.subscribe(subjectName, new MessageCallback() {
          public void callback(final Message message) {
            contextManager.activateSessionContext(message);
            contextManager.activateRequestContext();
            //                        contextManager.activateConversationContext(message);
            try {
View Full Code Here

Examples of org.jboss.errai.bus.client.api.MessageCallback

        }
      }
    }

    final RemoteServiceCallback delegate = new RemoteServiceCallback(epts);
    bus.subscribe(remoteIface.getName() + ":RPC", new MessageCallback() {
      public void callback(Message message) {
        try {
          CDIExtensionPoints.this.contextManager.activateRequestContext();
          delegate.callback(message);
        }
View Full Code Here

Examples of org.jboss.errai.bus.client.api.MessageCallback

    transmissionbuffer = buffer;

    /**
     * Define the default ServerBus service used for intrabus communication.
     */
    subscribe(BuiltInServices.ServerBus.name(), new MessageCallback() {
      @Override
      @SuppressWarnings({"unchecked", "SynchronizationOnLocalVariableOrMethodParameter"})
      public void callback(final Message message) {
        try {
          final QueueSession session = getSession(message);
View Full Code Here

Examples of org.jboss.errai.bus.client.api.MessageCallback

    this.menu = menu;
    this.setPadding(5);

    ErraiBus.get().subscribe(
        Workspace.SUBJECT,
        new MessageCallback()
        {
          public void callback(final Message message)
          {
            switch(LayoutCommands.valueOf(message.getCommandType()))
            {
View Full Code Here

Examples of org.jboss.errai.bus.client.api.MessageCallback

    super(new BoxLayout(BoxLayout.Orientation.HORIZONTAL));
    //this.setStyleName("bpm-header");

    createInfoPanel();

    ErraiBus.get().subscribe("appContext.login", new MessageCallback()
    {     
      public void callback(Message message)
      {
        AuthenticationContext authContext =
            Registry.get(SecurityService.class).getAuthenticationContext();
View Full Code Here

Examples of org.jboss.errai.bus.client.api.MessageCallback

    public void engageOffer(String client, String subject, ShoutboxCallback callback) {
        this.delegate = callback;

        // shout box example
        bus.subscribe(subject,
                new MessageCallback() {
                    public void callback(Message message) {
                        System.out.println("Shoutbox client: " + message.getCommandType());
                        switch (ShoutboxCmd.valueOf(message.getCommandType())) {
                            case SUBMIT_OFFER: // provider enters the game
                                delegate.offerSubmitted(message.get(String.class, ShoutboxCmdParts.PROVIDER));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.