public void run() {
      try {
        invokeNow(_msg, _response);
      } catch (Exception e) {
        _response.setException(e);
      }

      if (_handler != null) _handler.handleResponse(_response);
    }
  @Override
  public void handleException(Map<String, Object> ctx, final Throwable ex) {
    context = ctx;
    exception = ex;
    if (handler != null) {
      handler.handleResponse(
          new Response<T>() {

            public Map<String, Object> getContext() {
              return context;
            }

            public boolean cancel(boolean mayInterruptIfRunning) {
              cancelled = true;
              return true;
            }

            public T get() throws InterruptedException, ExecutionException {
              throw new ExecutionException(ex);
            }

            public T get(long timeout, TimeUnit unit)
                throws InterruptedException, ExecutionException, TimeoutException {

              throw new ExecutionException(ex);
            }

            public boolean isCancelled() {
              return cancelled;
            }

            public boolean isDone() {
              return true;
            }
          });
    }
    done = true;
    synchronized (this) {
      notifyAll();
    }
  }
  public void handleResponse(Map<String, Object> ctx, Object[] res) {
    context = ctx;
    result = res;
    if (handler != null) {
      handler.handleResponse(
          new Response<T>() {

            public Map<String, Object> getContext() {
              return context;
            }

            public boolean cancel(boolean mayInterruptIfRunning) {
              cancelled = true;
              return true;
            }

            @SuppressWarnings("unchecked")
            public T get() throws InterruptedException, ExecutionException {
              return (T) result[0];
            }

            @SuppressWarnings("unchecked")
            public T get(long timeout, TimeUnit unit)
                throws InterruptedException, ExecutionException, TimeoutException {
              return (T) result[0];
            }

            public boolean isCancelled() {
              return cancelled;
            }

            public boolean isDone() {
              return true;
            }
          });
    }
    done = true;
    synchronized (this) {
      notifyAll();
    }
  }