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