Examples of MessageCallback


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

        new Runnable() {

          public void run() {
            // Declare the standard error client here.
            bus.subscribe("ClientErrorService",
                new MessageCallback() {

                  public void callback(Message message) {
                    String errorMessage = message.get(String.class, MessageParts.ErrorMessage);
                    PopupPanel popup = new PopupPanel();
                    popup.add(new HTML(errorMessage));
                    popup.center();
                  }
                }
            );

            // The main workspace listener           
            bus.subscribe(Workspace.SUBJECT, new MessageCallback() {

              public void callback(Message message)
              {
                switch(LayoutCommands.valueOf(message.getCommandType()))
                {
View Full Code Here

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

  public void start()
  {
      // listen for control messages
    bus.subscribe(INBOX,
        new MessageCallback()
        {
          public void callback(Message message)
          {
            System.out.println("Shoutbox service: "+ message.getCommandType());
View Full Code Here

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

    String initSubject = tool.getId() + ":init";

    final MessageBus bus = ErraiBus.get();

    if (!bus.isSubscribed(initSubject)) {
      bus.subscribe(initSubject, new MessageCallback() {
        public void callback(final Message message) {

          try {

            tool.provideWidget(new ProvisioningCallback()
View Full Code Here

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

  public SSEHandler(final MessageCallback messageCallback, final ClientMessageBusImpl clientMessageBus) {
    this.clientMessageBus = clientMessageBus;
    this.messageCallback = messageCallback;
    this.pollingHandler = HttpPollingHandler.newNoPollingInstance(messageCallback, clientMessageBus);

    sseAgentSubscription = clientMessageBus.subscribe(SSE_AGENT_SERVICE, new MessageCallback() {
      @Override
      public void callback(final Message message) {
        notifyConnected();
      }
    });
View Full Code Here

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

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

    if (!isSubscribed(DefaultErrorCallback.CLIENT_ERROR_SUBJECT)) {
      directSubscribe(DefaultErrorCallback.CLIENT_ERROR_SUBJECT, new MessageCallback() {
        @Override
        public void callback(final Message message) {
          final String errorTo = message.get(String.class, MessageParts.ErrorTo);
          if (errorTo == null) {
            managementConsole.displayError(message.get(String.class, MessageParts.ErrorMessage),
                message.get(String.class, MessageParts.AdditionalDetails), null);
          }
          else {
            message.toSubject(errorTo);
            message.sendNowWith(ClientMessageBusImpl.this);
          }
        }
      }, false);
    }

    if (!isSubscribed(BuiltInServices.ClientBus.name())) {
      directSubscribe(BuiltInServices.ClientBus.name(), new MessageCallback() {
        @Override
        @SuppressWarnings({"unchecked"})
        public void callback(final Message message) {
          BusCommand busCommand;
          if (message.getCommandType() == null) {
View Full Code Here

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

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

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

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

  public SSEHandler(final MessageCallback messageCallback, final ClientMessageBusImpl clientMessageBus) {
    this.clientMessageBus = clientMessageBus;
    this.messageCallback = messageCallback;
    this.pollingHandler = HttpPollingHandler.newNoPollingInstance(messageCallback, clientMessageBus);

    sseAgentSubscription = clientMessageBus.subscribe(SSE_AGENT_SERVICE, new MessageCallback() {
      @Override
      public void callback(final Message message) {
        notifyConnected();
      }
    });
View Full Code Here

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

  public void execute(final BootstrapContext context) {
    final ServerMessageBus bus = context.getBus();
    final boolean authenticationConfigured =
        context.getConfig().getResource(AuthenticationAdapter.class) != null;

    bus.subscribe(ErraiService.AUTHORIZATION_SVC_SUBJECT, new MessageCallback() {
      public void callback(Message message) {
        switch (SecurityCommands.valueOf(message.getCommandType())) {
          case AuthenticationScheme:
            if (authenticationConfigured) {

              /**
               * Respond with what credentials the authentication system requires.
               */
              //todo: we only support login/password for now

              createConversation(message)
                  .subjectProvided()
                  .command(SecurityCommands.AuthenticationScheme)
                  .with(SecurityParts.CredentialsRequired, "Name,Password")
                  .with(MessageParts.ReplyTo, ErraiService.AUTHORIZATION_SVC_SUBJECT)
                  .noErrorHandling().sendNowWith(bus);
            }
            else {
              createConversation(message)
                  .subjectProvided()
                  .command(SecurityCommands.AuthenticationNotRequired)
                  .noErrorHandling().sendNowWith(bus);
            }

            break;

          case AuthRequest:
            /**
             * Receive a challenge.
             */

            if (authenticationConfigured) {
              try {
                context.getConfig().getResource(AuthenticationAdapter.class)
                    .challenge(message);
              }
              catch (AuthenticationFailedException a) {
              }
            }
            break;

          case EndSession:
            if (authenticationConfigured) {
              context.getConfig().getResource(AuthenticationAdapter.class)
                  .endSession(message);
            }

            // reply in any case
            createConversation(message)
                .toSubject("LoginClient")
                .command(SecurityCommands.EndSession)
                .noErrorHandling()
                .sendNowWith(bus);

            break;
        }
      }
    });

    /**
     * The standard ServerEchoService.
     */
    bus.subscribe(ErraiService.SERVER_ECHO_SERVICE, new MessageCallback() {
      public void callback(Message c) {
        MessageBuilder.createConversation(c)
            .subjectProvided().noErrorHandling()
            .sendNowWith(bus);
      }
    });

    bus.subscribe(ErraiService.AUTHORIZATION_SERVICE, new MessageCallback() {
      public void callback(Message message) {
        AuthSubject subject = message.getResource(QueueSession.class, "Session")
            .getAttribute(AuthSubject.class, ErraiService.SESSION_AUTH_DATA);

        Message reply = MessageBuilder.createConversation(message).getMessage();
View Full Code Here

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

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

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

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

  // deferr notification of LoginClient in case
  // a workspace wants to override the authentication or authorization scheme
  private boolean deferredNotification;

  public SecurityService() {
    ErraiBus.get().subscribe(SUBJECT, new MessageCallback() {
      public void callback(Message msg) {

        switch (SecurityCommands.valueOf(msg.getCommandType())) {
          case AuthenticationScheme:
            if (authHandler == null) {
              //               msg.toSubject("LoginClient").sendNowWith(ErraiBus.get());
              return;
            }

            String credentialsRequired = msg.get(String.class, CredentialsRequired);
            String[] credentialNames = credentialsRequired.split(",");
            Credential[] credentials = new Credential[credentialNames.length];

            for (int i = 0; i < credentialNames.length; i++) {
              switch (CredentialTypes.valueOf(credentialNames[i])) {
                case Name:
                  credentials[i] = new NameCredential();
                  break;
                case Password:
                  credentials[i] = new PasswordCredential();
                  break;

                default:
                  //todo: throw a massive error here.
              }
            }

            // callback on externally provided login form
            // asking for the required credentials specified on the server side.
            authHandler.doLogin(credentials);

            // Create an authentication request and send the credentials
            Message challenge = createMessage()
                .toSubject("AuthenticationService")
                .command(SecurityCommands.AuthRequest)
                .with(MessageParts.ReplyTo, SUBJECT)
                .getMessage();

            for (int i = 0; i < credentialNames.length; i++) {
              switch (CredentialTypes.valueOf(credentialNames[i])) {
                case Name:
                  challenge.set(CredentialTypes.Name, credentials[i].getValue());
                  break;
                case Password:
                  challenge.set(CredentialTypes.Password, credentials[i].getValue());
                  break;
              }
            }

            challenge.sendNowWith(ErraiBus.get());

            break;
          case AuthenticationNotRequired:
            notifyLoginClient(msg);
            break;

          case FailedAuth:
            notifyLoginClient(msg);
            break;
          case SuccessfulAuth:
            if (authenticationContext != null && authenticationContext.isValid()) return;
            authenticationContext = createAuthContext(msg);
            notifyLoginClient(msg);

            break;
        }
      }
    });


    // listener for the authorization assignment
    ErraiBus.get().subscribe("AuthorizationListener",
        new MessageCallback() {
          public void callback(Message message) {

            authenticationContext = createAuthContext(message);

            if (!deferredNotification) {
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.