Examples of AsyncInvoker


Examples of com.sun.xml.internal.ws.client.AsyncInvoker

     * Obtains the value to return from the response message.
     */
    abstract T toReturnValue(Packet response);

    public final Response<T> invokeAsync(T param) {
        AsyncInvoker invoker = new DispatchAsyncInvoker(param);
        AsyncResponseImpl<T> ft = new AsyncResponseImpl<T>(invoker,null);
        invoker.setReceiver(ft);
        // TODO: Do we set this executor on Engine and run the AsyncInvoker in this thread ?
        owner.getExecutor().execute(ft);
        return ft;
    }
View Full Code Here

Examples of com.sun.xml.internal.ws.client.AsyncInvoker

        owner.getExecutor().execute(ft);
        return ft;
    }

    public final Future<?> invokeAsync(T param, AsyncHandler<T> asyncHandler) {
        AsyncInvoker invoker = new DispatchAsyncInvoker(param);
        AsyncResponseImpl<T> ft = new AsyncResponseImpl<T>(invoker,asyncHandler);
        invoker.setReceiver(ft);

        // temp needed so that unit tests run and complete otherwise they may
        //not. Need a way to put this in the test harness or other way to do this
        //todo: as above
        ExecutorService exec = (ExecutorService) owner.getExecutor();
View Full Code Here

Examples of com.sun.xml.internal.ws.client.AsyncInvoker

    }

    protected final Response<Object> doInvoke(Object proxy, Object[] args, AsyncHandler handler) {

        AsyncInvoker invoker = new SEIAsyncInvoker(proxy, args);
        AsyncResponseImpl<Object> ft = new AsyncResponseImpl<Object>(invoker,handler);
        invoker.setReceiver(ft);
        // TODO: Do we set this executor on Engine and run the AsyncInvoker in this thread ?
        owner.getExecutor().execute(ft);
        return ft;
    }
View Full Code Here

Examples of com.sun.xml.internal.ws.client.AsyncInvoker

    }

    protected final Response<Object> doInvoke(Object proxy, Object[] args, AsyncHandler handler) {

        AsyncInvoker invoker = new SEIAsyncInvoker(proxy, args);
        AsyncResponseImpl<Object> ft = new AsyncResponseImpl<Object>(invoker,handler);
        invoker.setReceiver(ft);
        ft.run();
        return ft;
    }
View Full Code Here

Examples of com.sun.xml.ws.client.AsyncInvoker

      
    }

    protected final Response<Object> doInvoke(Object proxy, Object[] args, AsyncHandler handler) {
       
        AsyncInvoker invoker = new SEIAsyncInvoker(proxy, args);
        AsyncResponseImpl<Object> ft = new AsyncResponseImpl<Object>(invoker,handler);
        invoker.setReceiver(ft);
        // TODO: Do we set this executor on Engine and run the AsyncInvoker in this thread ?
        owner.getExecutor().execute(ft);
        return ft;
    }
View Full Code Here

Examples of com.sun.xml.ws.client.AsyncInvoker

//      
//    }

    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;
    }
View Full Code Here

Examples of javax.ws.rs.client.AsyncInvoker

    public void testAsyncPost() throws ExecutionException, InterruptedException {
        GenericType<Response> generic = new GenericType<Response>(Response.class);
        Entity entity = Entity.entity("entity", MediaType.WILDCARD_TYPE);

        WebTarget target = target("resource");
        final AsyncInvoker async = target.request().async();

        Response response = async.post(entity, generic).get();
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("entity", response.readEntity(String.class));
    }
View Full Code Here

Examples of javax.ws.rs.client.AsyncInvoker

    @Test
    public void testAsyncGet() throws ExecutionException, InterruptedException {
        GenericType<Response> generic = new GenericType<Response>(Response.class);

        WebTarget target = target("resource");
        final AsyncInvoker async = target.request().async();
        Response response = async.get(generic).get();
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("get", response.readEntity(String.class));
    }
View Full Code Here

Examples of javax.ws.rs.client.AsyncInvoker

        Client client = ClientBuilder.newClient(jerseyConfig);
        runCustomExecutorTestSync(client);
    }

    private void runCustomExecutorTestAsync(Client client) throws InterruptedException, ExecutionException {
        AsyncInvoker async = client.target(getBaseUri()).path("resource").request().async();

        Future<Response> f1 = async.post(text("post"));
        final Response response = f1.get();
        final String entity = response.readEntity(String.class);
        assertEquals("AsyncRequest-post", entity);
    }
View Full Code Here

Examples of javax.ws.rs.client.AsyncInvoker

        }
    }

    @Test
    public void testClientThreadPool() throws Exception {
        final AsyncInvoker invoker = ClientBuilder
                .newClient(new ClientConfig().property(ClientProperties.ASYNC_THREADPOOL_SIZE, 9))
                .target(getBaseUri())
                .path("threadpool")
                .request()
                .async();

        final CountDownLatch latch = new CountDownLatch(100);
        final int threadCount = Thread.activeCount();

        final List<Thread> threads = new ArrayList<Thread>(20);
        for (int i = 0; i < 20; i++) {
            threads.add(new Thread(new Runnable() {
                @Override
                public void run() throws RuntimeException {
                    for (int i = 0; i < 5; i++) {
                        try {
                            assertThat(invoker.get().get().readEntity(String.class), equalTo("GET"));
                            assertThat(Thread.activeCount() - threadCount - 20, lessThanOrEqualTo(10));
                            latch.countDown();
                        } catch (final InterruptedException e) {
                            fail();
                        } catch (final ExecutionException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.