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

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


        for (int i = 0; i < pkg.length; i++) {
            Map<String, Object> parts = decodeToMap(pkg[i]);
            parts.remove(MessageParts.SessionID.name());

            Message msg = CommandMessage.createWithParts(parts)
                    .setResource("Session", session);

            if (parts.containsKey("__MarshalledTypes")) {
                TypeDemarshallHelper.demarshallAll((String) parts.get("__MarshalledTypes"), msg);
            }

            msg.setFlag(RoutingFlags.FromRemote);

            c[i] = msg;
        }

        return c;
View Full Code Here


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

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

        bus.subscribe("AuthorizationService", 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);
            }
        });

        configurator.configure(this);
        dispatcher = configurator.getConfiguredDispatcher();
View Full Code Here

        for (int i = 0; i < pkg.length; i++) {
            Map<String, Object> parts = decodeToMap(pkg[i]);
            parts.remove(MessageParts.SessionID.name());

            Message msg = CommandMessage.createWithParts(parts)
                    .setResource("Session", session);

            if (parts.containsKey("__MarshalledTypes")) {
                TypeDemarshallHelper.demarshallAll((String) parts.get("__MarshalledTypes"), msg);
            }
View Full Code Here

                  .command(BusCommands.RemoteSubscribe)
                  .with(MessageParts.SubjectsList, new HashSet(globalSubscriptions))
                  .with(MessageParts.PriorityProcessing, "1")
                  .noErrorHandling().sendNowWith(ServerMessageBusImpl.this, false);

              final Message msg = ConversationMessage.create(message)
                  .toSubject(BuiltInServices.ClientBus.name())
                  .command(BusCommands.CapabilitiesNotice);

              final StringBuilder capabilitiesBuffer = new StringBuilder(25);

              final boolean first;
              if (ErraiServiceConfigurator.LONG_POLLING) {
                capabilitiesBuffer.append(Capabilities.LongPollAvailable.name());
                first = false;
              }
              else {
                capabilitiesBuffer.append(Capabilities.NoLongPollAvailable.name());
                first = false;
                msg.set(MessageParts.PollFrequency, ErraiServiceConfigurator.HOSTED_MODE_TESTING ? 50 : 250);
              }

              if (webSocketServer || webSocketServlet) {
                if (!first) {
                  capabilitiesBuffer.append(',');
                }
                capabilitiesBuffer.append(Capabilities.WebSockets.name());
                /**
                 * Advertise where the client can find a websocket.
                 */

                final String webSocketURL;

                final HttpServletRequest request = message.getResource(HttpServletRequest.class, HttpServletRequest.class.getName());

                if (webSocketServlet) {
                  webSocketURL = "ws://" + request.getHeader("Host") + webSocketPath;
                }
                else {
                  webSocketURL = "ws://" + request.getServerName() + ":" + webSocketPort + webSocketPath;
                }
                msg.set(MessageParts.WebSocketURL, webSocketURL);
                msg.set(MessageParts.WebSocketToken, WebSocketTokenManager.getNewOneTimeToken(session));
              }

              msg.set(MessageParts.CapabilitiesFlags, capabilitiesBuffer.toString());

              send(msg, false);

              createConversation(message)
                  .toSubject(BuiltInServices.ClientBus.name())
View Full Code Here

      synchronized (queue) {
        if (deferredQueue.containsKey(queue)) {
          final List<Message> deferredMessages = deferredQueue.get(queue);
          final Iterator<Message> dmIter = deferredMessages.iterator();

          Message m;
          while (dmIter.hasNext()) {
            if ((m = dmIter.next()).hasPart(MessageParts.PriorityProcessing.toString())) {
              queue.offer(m);
              dmIter.remove();
            }
View Full Code Here

  }
 
  public static String encodeMessages(Queue<Message> messages) {
    StringBuilder sbuf = new StringBuilder("[");
    boolean first = true;
    Message m;
    while ((m = messages.poll()) != null) {
      if (!first) {
        sbuf.append(',');
      }
      sbuf.append(encodeMessage(m));
View Full Code Here

    activityTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
      public void valueChanged(ListSelectionEvent e) {
        detailsModel.clear();

        Message m = UiHelper.uglyReEncode((String) tableModel.getValueAt(activityTable.getSelectedRow(), 1));
        if (m == null) return;

        for (Map.Entry<String, Object> entry : m.getParts().entrySet()) {
          detailsModel.addPart(entry.getKey(), entry.getValue());
        }

        detailsModel.fireTableRowsUpdated(0, m.getParts().size() - 1);
        detailsModel.fireTableDataChanged();
      }
    });

    detailsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
View Full Code Here

  public static Message uglyReEncode(String message) {
    if (message == null) return null;
    Map<String, Object> parts = (Map<String, Object>) JSONDecoder.decode(message);

    Message newMessage = CommandMessage.createWithParts(parts);
//        if (parts.containsKey(SerializationParts.MARSHALLED_TYPES)) {
//            TypeDemarshallHelper.demarshallAll((String) parts.get(SerializationParts.MARSHALLED_TYPES), newMessage);
//        }
    return newMessage;
  }
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.