public CommandAwareRpcDispatcher(
      Channel channel,
      JGroupsTransport transport,
      ExecutorService asyncExecutor,
      TimeService timeService,
      InboundInvocationHandler globalHandler) {
    this.server_obj = transport;
    this.asyncExecutor = asyncExecutor;
    this.transport = transport;
    this.timeService = timeService;
    this.handler = globalHandler;

    // MessageDispatcher superclass constructors will call start() so perform all init here
    this.setMembershipListener(transport);
    this.setChannel(channel);
    // If existing up handler is a muxing up handler, setChannel(..) will not have replaced it
    UpHandler handler = channel.getUpHandler();
    if (handler instanceof Muxer<?>) {
      @SuppressWarnings("unchecked")
      Muxer<UpHandler> mux = (Muxer<UpHandler>) handler;
      mux.setDefaultHandler(this.prot_adapter);
    }
    channel.addChannelListener(this);
    asyncDispatching(true);
  }
 /**
  * Sets the given UpHandler as the UpHandler for the channel, or, if the channel already has a
  * Muxer installed as it's UpHandler, sets the given handler as the Muxer's {@link
  * Muxer#setDefaultHandler(Object) default handler}. If the relevant handler is already installed,
  * the <code>canReplace</code> controls whether this method replaces it (after logging a WARN) or
  * simply leaves <code>handler</code> uninstalled.
  *
  * <p>Passing <code>false</code> as the <code>canReplace</code> value allows callers to use this
  * method to install defaults without concern about inadvertently overriding
  *
  * @param handler the UpHandler to install
  * @param canReplace <code>true</code> if an existing Channel upHandler or Muxer default upHandler
  *     can be replaced; <code>false</code> if this method shouldn't install
  */
 protected void installUpHandler(UpHandler handler, boolean canReplace) {
   UpHandler existing = channel.getUpHandler();
   if (existing == null) {
     channel.setUpHandler(handler);
   } else if (existing instanceof Muxer<?>) {
     @SuppressWarnings("unchecked")
     Muxer<UpHandler> mux = (Muxer<UpHandler>) existing;
     if (mux.getDefaultHandler() == null) {
       mux.setDefaultHandler(handler);
     } else if (canReplace) {
       log.warn(
           "Channel Muxer already has a default up handler installed ("
               + mux.getDefaultHandler()
               + ") but now it is being overridden");
       mux.setDefaultHandler(handler);
     }
   } else if (canReplace) {
     log.warn(
         "Channel already has an up handler installed ("
             + existing
             + ") but now it is being overridden");
     channel.setUpHandler(handler);
   }
 }