Search in sources :

Example 1 with RequestScopedInitializer

use of org.glassfish.jersey.server.spi.RequestScopedInitializer in project jersey by jersey.

the class RequestResponseWrapperProvider method getRequestScopedInitializerProvider.

@Override
public RequestScopedInitializerProvider getRequestScopedInitializerProvider() {
    return new RequestScopedInitializerProvider() {

        @Override
        public RequestScopedInitializer get(final RequestContextProvider context) {
            return new RequestScopedInitializer() {

                @Override
                public void initialize(InjectionManager injectionManager) {
                    ServiceLocator locator = ((HK2InjectionManager) injectionManager).getServiceLocator();
                    locator.<Ref<HttpServletRequest>>getService(REQUEST_TYPE).set(finalWrap(context.getHttpServletRequest()));
                    locator.<Ref<HttpServletResponse>>getService(RESPONSE_TYPE).set(finalWrap(context.getHttpServletResponse()));
                }
            };
        }
    };
}
Also used : RequestScopedInitializer(org.glassfish.jersey.server.spi.RequestScopedInitializer) ServiceLocator(org.glassfish.hk2.api.ServiceLocator) HttpServletRequest(javax.servlet.http.HttpServletRequest) RequestScopedInitializerProvider(org.glassfish.jersey.servlet.internal.spi.RequestScopedInitializerProvider) HttpServletResponse(javax.servlet.http.HttpServletResponse) HK2InjectionManager(org.glassfish.jersey.hk2.HK2InjectionManager) RequestContextProvider(org.glassfish.jersey.servlet.internal.spi.RequestContextProvider) InjectionManager(org.glassfish.jersey.internal.inject.InjectionManager) HK2InjectionManager(org.glassfish.jersey.hk2.HK2InjectionManager)

Example 2 with RequestScopedInitializer

use of org.glassfish.jersey.server.spi.RequestScopedInitializer in project jersey by jersey.

the class ReferencesInitializer method apply.

/**
     * Initialize the request references using the incoming request processing context.
     *
     * @param context incoming request context.
     * @return same (unmodified) request context.
     */
@Override
public RequestProcessingContext apply(final RequestProcessingContext context) {
    processingContextRefProvider.get().set(context);
    final RequestScopedInitializer requestScopedInitializer = context.request().getRequestScopedInitializer();
    if (requestScopedInitializer != null) {
        requestScopedInitializer.initialize(injectionManager);
    }
    return context;
}
Also used : RequestScopedInitializer(org.glassfish.jersey.server.spi.RequestScopedInitializer)

Aggregations

RequestScopedInitializer (org.glassfish.jersey.server.spi.RequestScopedInitializer)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)1 HK2InjectionManager (org.glassfish.jersey.hk2.HK2InjectionManager)1 InjectionManager (org.glassfish.jersey.internal.inject.InjectionManager)1 RequestContextProvider (org.glassfish.jersey.servlet.internal.spi.RequestContextProvider)1 RequestScopedInitializerProvider (org.glassfish.jersey.servlet.internal.spi.RequestScopedInitializerProvider)1