Examples of AsyncResponse


Examples of javax.ws.rs.container.AsyncResponse

            ClassResourceInfo cri =
                (ClassResourceInfo)message.getExchange().get(JAXRSUtils.ROOT_RESOURCE_CLASS);
            if (cri != null) {
                cri.clearThreadLocalProxies();
            }
            AsyncResponse ar = (AsyncResponse)message.getExchange().get(AsyncResponse.class);
            if (ar != null) {
                ((AsyncResponseImpl)ar).reset();
            }
        }
           
View Full Code Here

Examples of javax.ws.rs.container.AsyncResponse

    }

    public Object invoke(Exchange exchange, Object request) {
        Response response = exchange.get(Response.class);
        if (response == null) {
            AsyncResponse asyncResp = exchange.get(AsyncResponse.class);
            if (asyncResp != null) {
                AsyncResponseImpl asyncImpl = (AsyncResponseImpl)asyncResp;
                asyncImpl.prepareContinuation();
                asyncImpl.handleTimeout();
                return handleAsyncResponse(exchange, asyncImpl.getResponseObject());
View Full Code Here

Examples of javax.ws.rs.container.AsyncResponse

    public Object invoke(Exchange exchange, Object request) {
        MessageContentsList responseList = checkExchangeForResponse(exchange);
        if (responseList != null) {
            return responseList;
        }
        AsyncResponse asyncResp = exchange.get(AsyncResponse.class);
        if (asyncResp != null) {
            AsyncResponseImpl asyncImpl = (AsyncResponseImpl)asyncResp;
            asyncImpl.prepareContinuation();
            asyncImpl.handleTimeout();
            return handleAsyncResponse(exchange, asyncImpl.getResponseObject());
View Full Code Here

Examples of javax.ws.rs.container.AsyncResponse

            ClassResourceInfo cri =
                (ClassResourceInfo)message.getExchange().get(JAXRSUtils.ROOT_RESOURCE_CLASS);
            if (cri != null) {
                cri.clearThreadLocalProxies();
            }
            AsyncResponse ar = (AsyncResponse)message.getExchange().get(AsyncResponse.class);
            if (ar != null) {
                ((AsyncResponseImpl)ar).reset();
            }
        }
           
View Full Code Here

Examples of javax.ws.rs.container.AsyncResponse

    }

    @POST
    @Path("timeout")
    public void setTimeOut(final Integer millis) throws InterruptedException {
        final AsyncResponse asyncResponse = queue.take();

        final boolean timeout1 = asyncResponse.setTimeout(millis, TimeUnit.MILLISECONDS);
        asyncResponse.setTimeoutHandler(new TimeoutHandler() {

            @Override
            public void handleTimeout(final AsyncResponse asyncResponse) {
                final boolean timeout2 = asyncResponse.setTimeout(millis, TimeUnit.MILLISECONDS);
                asyncResponse.setTimeoutHandler(new TimeoutHandler() {

                    @Override
                    public void handleTimeout(final AsyncResponse asyncResponse) {
                        asyncResponse.resume("timeout1=" + timeout1 + "_timeout2=" + timeout2 + "_handled");
                    }
                });
            }
        });
    }
View Full Code Here

Examples of javax.ws.rs.container.AsyncResponse

    }

    @POST
    @Path("timeout")
    public void setTimeout(final String stage) throws Exception {
        final AsyncResponse async = stages[Integer.parseInt(stage)].take();

        async.setTimeoutHandler(new TimeoutHandler() {
            @Override
            public void handleTimeout(final AsyncResponse response) {
                response.cancel();
            }
        });
        async.setTimeout(200L, TimeUnit.MILLISECONDS);

        stages[Integer.parseInt(stage) + 1].add(async);
    }
View Full Code Here

Examples of javax.ws.rs.container.AsyncResponse

    }

    @POST
    @Path("timeout")
    public void setTimeOut(final Integer millis) throws InterruptedException {
        final AsyncResponse asyncResponse = queue.take();

        final boolean timeout1 = asyncResponse.setTimeout(millis, TimeUnit.MILLISECONDS);
        asyncResponse.setTimeoutHandler(new TimeoutHandler() {

            @Override
            public void handleTimeout(final AsyncResponse asyncResponse) {
                final boolean timeout2 = asyncResponse.setTimeout(millis, TimeUnit.MILLISECONDS);
                asyncResponse.setTimeoutHandler(new TimeoutHandler() {

                    @Override
                    public void handleTimeout(final AsyncResponse asyncResponse) {
                        asyncResponse.resume("timeout1=" + timeout1 + "_timeout2=" + timeout2 + "_handled");
                        asyncResponse.cancel();
                    }
                });
            }
        });
    }
View Full Code Here

Examples of javax.ws.rs.container.AsyncResponse

        QUEUE_EXECUTOR.submit(new Runnable() {

            @Override
            public void run() {
                try {
                    final AsyncResponse suspendedResponse = suspended.take();
                    LOGGER.log(DEBUG, "Resuming GET context {0} with a message <{1}> on thread {2}.",
                            new Object[] {suspendedResponse.toString(), message, Thread.currentThread().getName()});
                    suspendedResponse.resume(message);
                } catch (InterruptedException ex) {
                    LOGGER.log(Level.SEVERE,
                            "Waiting for a sending a message <" + message + "> has been interrupted.", ex);
                }
            }
View Full Code Here

Examples of javax.ws.rs.container.AsyncResponse

         * @return true if the URI was correctly absolutized, false if the URI is relative or differs from the expected URI
         */
        @GET
        @Path("locationAsyncFinish")
        public Boolean locationAsyncFinish() throws InterruptedException {
            AsyncResponse asyncResponse = suspended.poll(2000, TimeUnit.MILLISECONDS);

            URI uri = getUriBuilder().segment("locationAsyncFinish").build();
            Response result = Response.created(uri).build();
            boolean wasEqual = result.getLocation().equals(uriInfo.getAbsolutePath());

            asyncResponse.resume(result);
            return wasEqual;
        }
View Full Code Here

Examples of javax.ws.rs.container.AsyncResponse

    }

    @POST
    @ManagedAsync
    public String postMessage(final Message message) throws InterruptedException {
        final AsyncResponse asyncResponse = suspended.take();
        asyncResponse.resume(message);
        return "Sent!";
    }
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.