class JaxwsClientCallback extends ClientCallback {

    public void handleResponse(Map<String, Object> ctx, Object[] res) {
        context = ctx;
        
        // The handler has to be called *before* future completes
        if (handler != null) {
            handler.handleResponse(new Response<T>() {
                protected boolean cancelled;
                
                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)res[0];
                }

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

                public boolean isCancelled() {
                    return cancelled;
                }

                public boolean isDone() {
                    return true;
                }

            });
        }
        
        delegate.complete(res);
        
        synchronized (this) {
            notifyAll();
        }
    }

      JaxwsClientCallback(final AsyncHandler<T> handler, Object p);

}