Package org.glassfish.jersey.process.internal

Examples of org.glassfish.jersey.process.internal.RequestScope


    }

    @Override
    public Response invoke() throws ProcessingException, WebApplicationException {
        final ClientRuntime runtime = request().getClientRuntime();
        final RequestScope requestScope = runtime.getRequestScope();
        return requestScope.runInScope(new Producer<Response>() {
            @Override
            public Response call() throws ProcessingException {
                return new InboundJaxrsResponse(runtime.invoke(requestContext), requestScope);
            }
        });
View Full Code Here


    public <T> T invoke(final Class<T> responseType) throws ProcessingException, WebApplicationException {
        if (responseType == null) {
            throw new IllegalArgumentException(LocalizationMessages.RESPONSE_TYPE_IS_NULL());
        }
        final ClientRuntime runtime = request().getClientRuntime();
        final RequestScope requestScope = runtime.getRequestScope();
        return requestScope.runInScope(new Producer<T>() {
            @Override
            public T call() throws ProcessingException {
                try {
                    return translate(runtime.invoke(requestContext), requestScope, responseType);
                } catch (ProcessingException ex) {
View Full Code Here

    public <T> T invoke(final GenericType<T> responseType) throws ProcessingException, WebApplicationException {
        if (responseType == null) {
            throw new IllegalArgumentException(LocalizationMessages.RESPONSE_TYPE_IS_NULL());
        }
        final ClientRuntime runtime = request().getClientRuntime();
        final RequestScope requestScope = runtime.getRequestScope();
        return requestScope.runInScope(new Producer<T>() {
            @Override
            public T call() throws ProcessingException {
                try {
                    return translate(runtime.invoke(requestContext), requestScope, responseType);
                } catch (ProcessingException ex) {
View Full Code Here

    public void testProviders() throws Exception {
        final ServiceLocator locator = Injections.createLocator(new ContextInjectionResolver.Binder(), new TestBinder(),
                new MessagingBinders.MessageBodyProviders(null, RuntimeType.SERVER), new Binder());

        TestBinder.initProviders(locator);
        RequestScope scope = locator.getService(RequestScope.class);

        scope.runInScope(new Callable<Object>() {

            @Override
            public Object call() throws Exception {
                Providers instance = locator.getService(Providers.class);
View Full Code Here

    }

    @Override
    public Response invoke() throws ProcessingException, WebApplicationException {
        final ClientRuntime runtime = request().getClientRuntime();
        final RequestScope requestScope = runtime.getRequestScope();
        return requestScope.runInScope(new Producer<Response>() {
            @Override
            public Response call() throws ProcessingException {
                return new InboundJaxrsResponse(runtime.invoke(requestContext), requestScope);
            }
        });
View Full Code Here

    public <T> T invoke(final Class<T> responseType) throws ProcessingException, WebApplicationException {
        if (responseType == null) {
            throw new IllegalArgumentException(LocalizationMessages.RESPONSE_TYPE_IS_NULL());
        }
        final ClientRuntime runtime = request().getClientRuntime();
        final RequestScope requestScope = runtime.getRequestScope();
        return requestScope.runInScope(new Producer<T>() {
            @Override
            public T call() throws ProcessingException {
                try {
                    return translate(runtime.invoke(requestContext), requestScope, responseType);
                } catch (final ProcessingException ex) {
View Full Code Here

    public <T> T invoke(final GenericType<T> responseType) throws ProcessingException, WebApplicationException {
        if (responseType == null) {
            throw new IllegalArgumentException(LocalizationMessages.RESPONSE_TYPE_IS_NULL());
        }
        final ClientRuntime runtime = request().getClientRuntime();
        final RequestScope requestScope = runtime.getRequestScope();
        return requestScope.runInScope(new Producer<T>() {
            @Override
            public T call() throws ProcessingException {
                try {
                    return translate(runtime.invoke(requestContext), requestScope, responseType);
                } catch (final ProcessingException ex) {
View Full Code Here

                        bindAsContract(MyInjectablePerRequest.class).in(RequestScoped.class);
                        bindAsContract(MyInjectableSingleton.class).in(Singleton.class);
                    }
                });

        final RequestScope requestScope = locator.getService(RequestScope.class);

        final MyInjectableSingleton myInjectableSingleton = locator.getService(MyInjectableSingleton.class);
        assertEquals(myInjectableSingleton, locator.getService(MyInjectableSingleton.class));

        final MyInjectablePerRequest myInjectablePerRequest = requestScope.runInScope(new Callable<MyInjectablePerRequest>() {

            @Override
            public MyInjectablePerRequest call() throws Exception {
                final MyInjectablePerRequest myInjectablePerRequest = locator.getService(MyInjectablePerRequest.class);
                assertEquals(myInjectablePerRequest, locator.getService(MyInjectablePerRequest.class));
                return myInjectablePerRequest;
            }
        });

        requestScope.runInScope(new Runnable() {

            @Override
            public void run() {
                assertNotSame(myInjectablePerRequest, locator.getService(MyInjectablePerRequest.class));
            }
View Full Code Here

        Injections.addBinding(
                Injections.newBinder(MyInjectableSingleton.class).to(MyInjectableSingleton.class).in(Singleton.class),
                dc);
        dc.commit();

        final RequestScope requestScope = locator.getService(RequestScope.class);

        final MyInjectableSingleton myInjectableSingleton = locator.getService(MyInjectableSingleton.class);
        assertEquals(myInjectableSingleton, locator.getService(MyInjectableSingleton.class));

        final MyInjectablePerRequest myInjectablePerRequest = requestScope.runInScope(new Callable<MyInjectablePerRequest>() {
            @Override
            public MyInjectablePerRequest call() throws Exception {
                final MyInjectablePerRequest myInjectablePerRequest = locator.getService(MyInjectablePerRequest.class);
                assertEquals(myInjectablePerRequest, locator.getService(MyInjectablePerRequest.class));
                return myInjectablePerRequest;
            }
        });

        requestScope.runInScope(new Runnable() {
            @Override
            public void run() {
                assertNotSame(myInjectablePerRequest, locator.getService(MyInjectablePerRequest.class));
            }
        });
View Full Code Here

    }

    @Override
    public Response invoke() throws ProcessingException, WebApplicationException {
        final ClientRuntime runtime = request().getClientRuntime();
        final RequestScope requestScope = runtime.getRequestScope();
        return requestScope.runInScope(new Producer<Response>() {
            @Override
            public Response call() throws ProcessingException {
                return new ScopedJaxrsResponse(runtime.invoke(requestContext), requestScope);
            }
        });
View Full Code Here

TOP

Related Classes of org.glassfish.jersey.process.internal.RequestScope

Copyright © 2018 www.massapicom. 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.