Package org.jboss.errai.bus.client.api

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


    if (!queueRunning) {
      JSONStreamEncoder.encode(new QueueStopMessage().getParts(), outstream);
      return;
    }

    Message m = null;

    checkSession();

    if (lock.tryAcquire()) {
      outstream.write('[');

      int payLoadSize = 0;
      try {

        if (wait) {
          m = queue.poll(45, TimeUnit.SECONDS);

        }
        else {
          m = queue.poll();
        }

        if (m instanceof HasEncoded) {
          outstream.write(((HasEncoded) m).getEncoded().getBytes());
        }
        else if (m instanceof QueueStopMessage) {
          JSONStreamEncoder.encode(m.getParts(), outstream);
          queueRunning = false;
          bus.closeQueue(this);
        }
        else if (m != null) {
          JSONStreamEncoder.encode(m.getParts(), outstream);
        }

        if (_windowPolling) {
          windowPolling = true;
          _windowPolling = false;
        }
        else if (windowPolling) {
          while (!queue.isEmpty() && payLoadSize < MAXIMUM_PAYLOAD_SIZE
                  && !isWindowExceeded()) {
            outstream.write(',');
            if ((m = queue.poll()) instanceof HasEncoded) {
              outstream.write(((HasEncoded) m).getEncoded().getBytes());
            }
            else {
              JSONStreamEncoder.encode(m.getParts(), outstream);
            }
            payLoadSize++;

            try {
              if (queue.isEmpty())
View Full Code Here


        sb.append(buffer.get());
      }
      buffer.rewind();
    }

    Message msg = createCommandMessage(session, sb.toString());
    if (msg != null) {
      try {
        service.store(msg);
      }
      catch (Exception e) {
View Full Code Here

    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();

        if (subject != null) {
          reply.set(SecurityParts.Roles, subject.toRolesString());
          reply.set(SecurityParts.Name, subject.getUsername());
        }

        reply.sendNowWith(bus);
      }
    });
  }
View Full Code Here

      /**
       * Prepare to send a message back to the client, informing it that a successful login has
       * been performed.
       */
      Message successfulMsg = MessageBuilder.createConversation(message)
          .subjectProvided()
          .command(SecurityCommands.SuccessfulAuth)
          .with(SecurityParts.Roles, authSubject.toRolesString())
          .with(SecurityParts.Name, name).getMessage();

      try {
        // TODO: Still used? Take a look at MetaDataScanner.getProperties() instead
        ResourceBundle bundle = ResourceBundle.getBundle("errai");
        String motdText = bundle.getString("errai.login_motd");

        /**
         * If the MOTD is configured, then add it to the message.
         */
        if (motdText != null) {
          successfulMsg.set(MessageParts.MessageText, motdText);
        }
      }
      catch (Exception e) {
        // do nothing.
      }

      /**
       * Transmit the message back to the client.
       */
      successfulMsg.sendNowWith(bus);
    }
    catch (LoginException e) {
      /**
       * The login failed. How upsetting. Life must go on, and we must inform the client of the
       * unfortunate news.
View Full Code Here

        sb.append(buffer.get());
      }
      buffer.rewind();
    }

    Message m = createCommandMessage(session, sb.toString());
    if (m != null) {
      try {
        service.store(m);
      }
      catch (Exception e) {
View Full Code Here

        }
        buffer.rewind();
      }


      Message msg = createCommandMessage(sessionProvider.getSession(request.getSession(),
          request.getHeader(ClientMessageBus.REMOTE_QUEUE_ID_HEADER)), sb.toString());
      if (msg != null) {
        try {
          service.store(msg);
        }
View Full Code Here

   * @return a <tt>MessageBuildSubject</tt> which essentially is a <tt>Message</tt>, but ensures that the user
   *         constructs messages properly
   */
  @SuppressWarnings({"unchecked"})
  public static MessageBuildSubject<MessageReplySendable> createConversation(Message message) {
    Message newMessage = provider.get();
    if (newMessage instanceof HasEncoded) {
      return new AbstractMessageBuilder<MessageReplySendable>(new HasEncodedConvMessageWrapper(message, newMessage)).start();
    }
    else {
      return new AbstractMessageBuilder<MessageReplySendable>(new ConversationMessageWrapper(message, newMessage)).start();
View Full Code Here

   * @return a <tt>MessageBuildSubject</tt> which essentially is a <tt>Message</tt>, but ensures that the user
   *         constructs messages properly
   */
  @SuppressWarnings({"unchecked"})
  public static MessageBuildCommand<MessageReplySendable> createConversation(Message message, String subject) {
    Message newMessage = provider.get();
    if (newMessage instanceof HasEncoded) {
      return new AbstractMessageBuilder<MessageReplySendable>(new HasEncodedConvMessageWrapper(message, newMessage))
        .start()
        .toSubject(subject);
    }
View Full Code Here

        sb.append(buffer.get());
      }
      buffer.rewind();
    }

    Message msg = createCommandMessage(sessionProvider.getSession(request.getSession(),
        request.getHeader(REMOTE_QUEUE_ID_HEADER)), sb.toString());
    if (msg != null) {
      try {
        service.store(msg);
      }
View Full Code 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;
View Full Code Here

TOP

Related Classes of org.jboss.errai.bus.client.api.Message

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.