javax.xml.ws.AsyncHandler Java Examples

The following examples show how to use javax.xml.ws.AsyncHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DispatchImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public final Future<?> invokeAsync(T param, AsyncHandler<T> asyncHandler) {
    Container old = ContainerResolver.getDefault().enterContainer(owner.getContainer());
    try {
        if (LOGGER.isLoggable(Level.FINE)) {
          dumpParam(param, "invokeAsync(T, AsyncHandler<T>)");
        }
        AsyncInvoker invoker = new DispatchAsyncInvoker(param);
        AsyncResponseImpl<T> ft = new AsyncResponseImpl<T>(invoker,asyncHandler);
        invoker.setReceiver(ft);
        invoker.setNonNullAsyncHandlerGiven(asyncHandler != null);

        ft.run();
        return ft;
    } finally {
        ContainerResolver.getDefault().exitContainer(old);
    }
}
 
Example #2
Source File: DispatchImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public final Future<?> invokeAsync(T param, AsyncHandler<T> asyncHandler) {
    Container old = ContainerResolver.getDefault().enterContainer(owner.getContainer());
    try {
        if (LOGGER.isLoggable(Level.FINE)) {
          dumpParam(param, "invokeAsync(T, AsyncHandler<T>)");
        }
        AsyncInvoker invoker = new DispatchAsyncInvoker(param);
        AsyncResponseImpl<T> ft = new AsyncResponseImpl<T>(invoker,asyncHandler);
        invoker.setReceiver(ft);
        invoker.setNonNullAsyncHandlerGiven(asyncHandler != null);

        ft.run();
        return ft;
    } finally {
        ContainerResolver.getDefault().exitContainer(old);
    }
}
 
Example #3
Source File: AsyncHTTPConduitTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testCallAsyncCallbackInvokedOnlyOnce() throws Exception {
    // This test is especially targeted for RHEL 6.8
    updateAddressPort(g, PORT_INV);
    int repeat = 100;
    final AtomicInteger count = new AtomicInteger(0);
    for (int i = 0; i < repeat; i++) {
        try {
            g.greetMeAsync(request, new AsyncHandler<GreetMeResponse>() {
                public void handleResponse(Response<GreetMeResponse> res) {
                    count.incrementAndGet();
                }
            }).get();
        } catch (Exception e) {
        }
    }
    Thread.sleep(1000);
    assertEquals("Callback should be invoked only once per request", repeat, count.intValue());
}
 
Example #4
Source File: Server.java    From cxf with Apache License 2.0 6 votes vote down vote up
public Future<?> greetMeAsync(final String requestType,
                              final AsyncHandler<GreetMeResponse> asyncHandler) {
    final ServerAsyncResponse<GreetMeResponse> r = new ServerAsyncResponse<>();
    new Thread() {
        public void run() {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                //ignore
            }
            GreetMeResponse resp = new GreetMeResponse();
            resp.setResponseType("Hello " + requestType);
            r.set(resp);
            asyncHandler.handleResponse(r);
        }
    } .start();
    return r;
}
 
Example #5
Source File: DispatchImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public final Future<?> invokeAsync(T param, AsyncHandler<T> asyncHandler) {
    Container old = ContainerResolver.getDefault().enterContainer(owner.getContainer());
    try {
        if (LOGGER.isLoggable(Level.FINE)) {
          dumpParam(param, "invokeAsync(T, AsyncHandler<T>)");
        }
        AsyncInvoker invoker = new DispatchAsyncInvoker(param);
        AsyncResponseImpl<T> ft = new AsyncResponseImpl<T>(invoker,asyncHandler);
        invoker.setReceiver(ft);
        invoker.setNonNullAsyncHandlerGiven(asyncHandler != null);

        ft.run();
        return ft;
    } finally {
        ContainerResolver.getDefault().exitContainer(old);
    }
}
 
Example #6
Source File: GreeterImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
public Future<?> greetMeSometimeAsync(final String me,
                                       final AsyncHandler<GreetMeSometimeResponse> asyncHandler) {
    LOG.info("Executing operation greetMeSometimeAsync asynchronously");
    System.out.println("Executing operation greetMeSometimeAsync asynchronously\n");
    final ServerAsyncResponse<GreetMeSometimeResponse> r
        = new ServerAsyncResponse<>();
    new Thread() {
        public void run() {
            GreetMeSometimeResponse resp = new GreetMeSometimeResponse();
            resp.setResponseType("How are you " + me);
            r.set(resp);
            System.out.println("Responding on background thread\n");
            asyncHandler.handleResponse(r);
        }
    } .start();

    return r;
}
 
Example #7
Source File: NettyHttpConduitTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testCallAsyncCallbackInvokedOnlyOnce() throws Exception {
    updateAddressPort(g, PORT);
    int repeat = 20;
    final AtomicInteger count = new AtomicInteger(0);
    for (int i = 0; i < repeat; i++) {
        try {
            g.greetMeAsync(request, new AsyncHandler<GreetMeResponse>() {
                public void handleResponse(Response<GreetMeResponse> res) {
                    count.incrementAndGet();
                }
            }).get();
        } catch (Exception e) {
        }
    }
    assertEquals("Callback should be invoked only once per request", repeat, count.intValue());
}
 
Example #8
Source File: SSLNettyClientTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testInvocation() throws Exception {
    setupTLS(g);
    setAddress(g, address);
    String response = g.greetMe("test");
    assertEquals("Get a wrong response", "Hello test", response);

    GreetMeResponse resp = (GreetMeResponse)g.greetMeAsync("asyncTest", new AsyncHandler<GreetMeResponse>() {
        public void handleResponse(Response<GreetMeResponse> res) {
            try {
                res.get().getResponseType();
            } catch (InterruptedException | ExecutionException e) {
                e.printStackTrace();
            }
        }
    }).get();
    assertEquals("Hello asyncTest", resp.getResponseType());

    MyLaterResponseHandler handler = new MyLaterResponseHandler();
    g.greetMeLaterAsync(1000, handler).get();
    // need to check the result here
    assertEquals("Hello, finally!", handler.getResponse().getResponseType());

}
 
Example #9
Source File: JaxWsClientProxy.java    From cxf with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private Object invokeAsync(Method method, final BindingOperationInfo oi, Object[] params) throws Exception {

    client.setExecutor(getClient().getEndpoint().getExecutor());

    AsyncHandler<Object> handler;
    if (params.length > 0 && params[params.length - 1] instanceof AsyncHandler) {
        handler = (AsyncHandler<Object>)params[params.length - 1];
        Object[] newParams = new Object[params.length - 1];
        System.arraycopy(params, 0, newParams, 0, newParams.length);
        params = newParams;
    } else {
        handler = null;
    }
    ClientCallback callback = new JaxwsClientCallback<Object>(handler, this) {
        @Override
        protected Throwable mapThrowable(Throwable t) {
            if (t instanceof Exception) {
                t = mapException(null, oi, (Exception)t);
            }
            return t;
        }
    };

    Response<Object> ret = new JaxwsResponseCallback<>(callback);
    client.invoke(callback, oi, params);
    return ret;
}
 
Example #10
Source File: AsyncMethodHandler.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
protected final Response<Object> doInvoke(Object proxy, Object[] args, AsyncHandler handler) {

        AsyncInvoker invoker = new SEIAsyncInvoker(proxy, args);
        invoker.setNonNullAsyncHandlerGiven(handler != null);
        AsyncResponseImpl<Object> ft = new AsyncResponseImpl<Object>(invoker,handler);
        invoker.setReceiver(ft);
        ft.run();
        return ft;
    }
 
Example #11
Source File: Server.java    From cxf with Apache License 2.0 5 votes vote down vote up
public Future<?> invokeAsync(final StreamSource s, final AsyncHandler<Source> asyncHandler) {
    final ServerAsyncResponse<Source> r = new ServerAsyncResponse<>();
    new Thread() {
        public void run() {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                // ignore
            }
            r.set(s);
            asyncHandler.handleResponse(r);
        }
    } .start();
    return r;
}
 
Example #12
Source File: AsyncMethodHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected final Response<Object> doInvoke(Object proxy, Object[] args, AsyncHandler handler) {

        AsyncInvoker invoker = new SEIAsyncInvoker(proxy, args);
        invoker.setNonNullAsyncHandlerGiven(handler != null);
        AsyncResponseImpl<Object> ft = new AsyncResponseImpl<Object>(invoker,handler);
        invoker.setReceiver(ft);
        ft.run();
        return ft;
    }
 
Example #13
Source File: AsyncMethodHandler.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected final Response<Object> doInvoke(Object proxy, Object[] args, AsyncHandler handler) {

        AsyncInvoker invoker = new SEIAsyncInvoker(proxy, args);
        invoker.setNonNullAsyncHandlerGiven(handler != null);
        AsyncResponseImpl<Object> ft = new AsyncResponseImpl<Object>(invoker,handler);
        invoker.setReceiver(ft);
        ft.run();
        return ft;
    }
 
Example #14
Source File: StatefulGreeterImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
public Future<?> pingMeAsync(AsyncHandler<PingMeResponse> asyncHandler) {
    return null;
}
 
Example #15
Source File: PerRequestAnnotationGreeterImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
public Future<?> pingMeAsync(AsyncHandler<PingMeResponse> asyncHandler) {
    return null;
}
 
Example #16
Source File: AnotherDerivedGreeterImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
public Future<?> greetMeAsync(String requestType, AsyncHandler<GreetMeResponse> asyncHandler) {
    return null;
    /*not called */
}
 
Example #17
Source File: PerRequestAnnotationGreeterImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
public Future<?> greetMeAsync(String requestType, AsyncHandler<GreetMeResponse> asyncHandler) {
    return null;
}
 
Example #18
Source File: GreeterSessionImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
public Future<?> sayHiAsync(AsyncHandler<SayHiResponse> asyncHandler) {
    return null;
}
 
Example #19
Source File: GreeterSessionImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
public Future<?> pingMeAsync(AsyncHandler<PingMeResponse> asyncHandler) {
    return null;
}
 
Example #20
Source File: AbstractGreeterImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
public Future<?>  greetMeSometimeAsync(String requestType,
                                       AsyncHandler<GreetMeSometimeResponse> asyncHandler) {
    return null;
    /*not called */
}
 
Example #21
Source File: GreeterImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
public Future<?>  greetMeSometimeAsync(String requestType,
                                       AsyncHandler<GreetMeSometimeResponse> asyncHandler) {
    return null;
}
 
Example #22
Source File: GreeterSessionImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
public Future<?> sayHiAsync(AsyncHandler<SayHiResponse> asyncHandler) {
    return null;
}
 
Example #23
Source File: GreeterSessionImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
public Future<?> pingMeAsync(AsyncHandler<PingMeResponse> asyncHandler) {
    return null;
}
 
Example #24
Source File: GreeterSessionImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
public Future<?> greetMeAsync(String requestType, AsyncHandler<GreetMeResponse> asyncHandler) {
    return null;
}
 
Example #25
Source File: GreeterImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
public Future<?> testDocLitFaultAsync(String faultType,
                                      AsyncHandler<TestDocLitFaultResponse> asyncHandler) {
    return null;
}
 
Example #26
Source File: SessionAnnotationGreeterImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
public Future<?> pingMeAsync(AsyncHandler<PingMeResponse> asyncHandler) {
    return null;
}
 
Example #27
Source File: GreeterImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
public Future<?> sayHiAsync(AsyncHandler<SayHiResponse> asyncHandler) {
    return null;
}
 
Example #28
Source File: GreeterImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
public Future<?> greetMeLaterAsync(long requestType, AsyncHandler<GreetMeLaterResponse> asyncHandler) {
    return null;
}
 
Example #29
Source File: AnotherDerivedGreeterImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
public Future<?> testNillableAsync(String nillElem,
                                   int intElem,
                                   AsyncHandler<TestNillableResponse> asyncHandler) {
    return null;
}
 
Example #30
Source File: AddNumberImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
public Future<?> addNumbers3Async(int number1, int number2,
                                  AsyncHandler<AddNumbersResponse> asyncHandler) {
    return null;
}