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

Examples of org.jboss.errai.bus.client.framework.ClientMessageBusImpl$ProtocolCommandProcessor


   * Debugging functions.
   */
  private void displayStatus() {
    displayUtilityTitle("ErraiBus Transport Status");

    final ClientMessageBusImpl bus = (ClientMessageBusImpl) ErraiBus.get();

    final boolean federatedApp = BusToolsCli.isRemoteCommunicationEnabled();

    logger.info("Bus State               : " + (bus.getState()));
    logger.info("Wire Protocol           : V3.JSON");
    logger.info("Active Channel          : " + (!federatedApp ? "None" : (bus.getTransportHandler())));

    logger.info(SEP);
    final TransportStatistics stats = bus.getTransportHandler().getStatistics();

    logger.info("Channel Details:");
    if (federatedApp) {
      logger.info("  Channel Description   : " + (stats.getTransportDescription()));
      if (stats.isFullDuplex()) {
        logger.info("  Endpoint (RX/TX)      : " + (stats.getRxEndpoint()));
      }
      else {
        logger.info("  Endpoint (RX)         : " + (stats.getRxEndpoint()));
        logger.info("  Endpoint (TX)         : " + (stats.getTxEndpoint()));
      }
      logger.info("  Pending Transmissions : " + (stats.getPendingMessages()));
      logger.info("");
      logger.info("  TX Count              : " + (stats.getMessagesSent()));
      logger.info("  RX Count              : " + (stats.getMessagesReceived()));
      final long connectedTime = stats.getConnectedTime();
      if (connectedTime == -1) {
        logger.info("  Time Connected        : Not Connected.");
      }
      else {
        logger.info("  Time Connected        : " + ((System.currentTimeMillis() - connectedTime) / 1000) + " secs.");
      }
      logger.info("  Last Activity (TX/RX) : " + ((System.currentTimeMillis() - stats.getLastTransmissionTime()) / 1000) + " secs ago.");
      final int measuredLatency = stats.getMeasuredLatency();
      logger.info("  Measured Latency      : " + (measuredLatency == -1 ? "N/A" : measuredLatency + "ms"));
    }
    else {
      logger.info("  <No transport configured>");
    }

    logger.info(SEP);

    logger.info("Available Handlers:");
    final Collection<TransportHandler> allAvailableHandlers = bus.getAllAvailableHandlers();

    if (allAvailableHandlers.isEmpty()) {
      logger.info(" [none]");
    }
    for (final TransportHandler handler : allAvailableHandlers) {
      if (handler.isUsable()) {
        logger.info("  > " + handler.getStatistics().getTransportDescription() + " " + (handler == bus.getTransportHandler() ? "**" : ""));
      }
    }
    logger.info("Unavailable Handlers");
    for (final TransportHandler handler : allAvailableHandlers) {
      if (!handler.isUsable()) {
View Full Code Here


* @author Christian Sadilek <csadilek@redhat.com>
*/
public class CDIClientBootstrap implements EntryPoint {
  public void onModuleLoad() {
    InitVotes.waitFor(CDIClientBootstrap.class);
    final ClientMessageBusImpl bus = (ClientMessageBusImpl) ErraiBus.get();

    final Runnable busReadyEvent = new Runnable() {
      public void run() {
        if (bus.isRemoteCommunicationEnabled()) {
          MessageBuilder.createMessage().toSubject(CDI.SERVER_DISPATCHER_SUBJECT)
                  .command(CDICommands.AttachRemote)
                  .done()
                  .sendNowWith(bus);
        }
        else {
          InitVotes.waitFor(CDI.class);
          CDI.activate();
        }

        CDI.fireEvent(new BusReadyEvent());
      }

      public String toString() {
        return "BusReadyEvent";
      }
    };

    bus.addPostInitTask(busReadyEvent);

    if (!bus.isSubscribed(CDI.CLIENT_DISPATCHER_SUBJECT)) {
      bus.subscribe(CDI.CLIENT_DISPATCHER_SUBJECT, new MessageCallback() {
        public void callback(Message message) {
          switch (CDICommands.valueOf(message.getCommandType())) {
            case RemoteSubscribe:
              CDI.addRemoteEventTypes(message.get(String[].class, MessageParts.Value));
              bus.addPostInitTask(new Runnable() {
                @Override
                public void run() {
                  CDI.activate();
                }

                public String toString() {
                  return "CDI service activate";
                }
              });
              break;
            case CDIEvent:
              CDI.consumeEventFromMessage(message);
              break;
          }
        }
      });
    }

    /*
     * Register an initialization lister to run the bus ready event.  This will be added
     * post-initialization, so it is designed to fire on bus reconnection events.
     */
    bus.addPostInitTask(new Runnable() {
      public void run() {
        bus.addPreInitializationListener(new PreInitializationListener() {
          public void beforeInitialization() {
            bus.addPostInitTask(busReadyEvent);
          }
        });
      }
    });
    InitVotes.voteFor(CDIClientBootstrap.class);
View Full Code Here

TOP

Related Classes of org.jboss.errai.bus.client.framework.ClientMessageBusImpl$ProtocolCommandProcessor

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.