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);
}
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;
}
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;
}
Aggregations