Search in sources :

Example 1 with AsyncResponseProvider

use of org.jboss.resteasy.spi.AsyncResponseProvider in project resteasy by resteasy.

the class ServerHelper method addAsyncResponseProvider.

public void addAsyncResponseProvider(Class provider) {
    AsyncResponseProvider providerInstance = rpf.createProviderInstance((Class<? extends AsyncResponseProvider>) provider);
    addAsyncResponseProvider(providerInstance, provider);
}
Also used : AsyncResponseProvider(org.jboss.resteasy.spi.AsyncResponseProvider)

Example 2 with AsyncResponseProvider

use of org.jboss.resteasy.spi.AsyncResponseProvider in project resteasy by resteasy.

the class ResteasyProviderFactoryImpl method getContextData.

public <T> T getContextData(Class<T> rawType, Type genericType, Annotation[] annotations, boolean unwrapAsync) {
    T ret = (T) ResteasyContext.getContextDataMap().get(rawType);
    if (ret != null)
        return ret;
    ContextInjector contextInjector = getContextInjectors().get(genericType);
    boolean async = false;
    if (contextInjector == null && unwrapAsync) {
        contextInjector = getAsyncContextInjectors().get(Types.boxPrimitives(genericType));
        async = true;
    }
    if (contextInjector != null) {
        ret = (T) contextInjector.resolve(rawType, genericType, annotations);
        if (async && ret != null) {
            Type wrappedType = Types.getActualTypeArgumentsOfAnInterface(contextInjector.getClass(), ContextInjector.class)[0];
            Class<?> rawWrappedType = Types.getRawType(wrappedType);
            AsyncResponseProvider converter = getAsyncResponseProvider(rawWrappedType);
            // OK this is plain lying
            ret = (T) converter.toCompletionStage(ret);
        }
    }
    return ret;
}
Also used : MediaType(jakarta.ws.rs.core.MediaType) ParameterizedType(java.lang.reflect.ParameterizedType) RuntimeType(jakarta.ws.rs.RuntimeType) Type(java.lang.reflect.Type) AsyncResponseProvider(org.jboss.resteasy.spi.AsyncResponseProvider) ContextInjector(org.jboss.resteasy.spi.ContextInjector)

Example 3 with AsyncResponseProvider

use of org.jboss.resteasy.spi.AsyncResponseProvider in project resteasy by resteasy.

the class ServerHelper method addAsyncResponseProvider.

private void addAsyncResponseProvider(AsyncResponseProvider provider, Class providerClass) {
    Type asyncType = Types.getActualTypeArgumentsOfAnInterface(providerClass, AsyncResponseProvider.class)[0];
    Utils.injectProperties(rpf, provider.getClass(), provider);
    Class<?> asyncClass = Types.getRawType(asyncType);
    Map<Class<?>, AsyncResponseProvider> registry = getAsyncResponseProvidersForWrite();
    registry.put(asyncClass, provider);
    attachedAsyncResponseProviders = false;
    asyncResponseProviders = registry;
}
Also used : RuntimeType(jakarta.ws.rs.RuntimeType) Type(java.lang.reflect.Type) AsyncResponseProvider(org.jboss.resteasy.spi.AsyncResponseProvider)

Aggregations

AsyncResponseProvider (org.jboss.resteasy.spi.AsyncResponseProvider)3 RuntimeType (jakarta.ws.rs.RuntimeType)2 Type (java.lang.reflect.Type)2 MediaType (jakarta.ws.rs.core.MediaType)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 ContextInjector (org.jboss.resteasy.spi.ContextInjector)1