use of org.glassfish.jersey.internal.inject.ContextInjectionResolver in project jersey by jersey.
the class ParameterInjectionBinder method configure.
@Override
public void configure() {
// Param converter providers
// TODO: Replace by non-di version
bind(new ParamConverters.AggregatedProvider()).to(ParamConverterProvider.class);
Provider<ContainerRequest> requestProvider = Injections.getProvider(injectionManager, ContainerRequest.class);
Provider<AsyncContext> asyncContextProvider = Injections.getProvider(injectionManager, AsyncContext.class);
Function<Class<? extends Configuration>, Configuration> clientConfigProvider = clientConfigClass -> Injections.getOrCreate(injectionManager, clientConfigClass);
// Param Converters must be initialized Lazy and created at the time of the call on extractor
LazyValue<ParamConverterFactory> lazyParamConverterFactory = Values.lazy((Value<ParamConverterFactory>) () -> new ParamConverterFactory(Providers.getProviders(injectionManager, ParamConverterProvider.class), Providers.getCustomProviders(injectionManager, ParamConverterProvider.class)));
LazyValue<Configuration> lazyConfiguration = Values.lazy((Value<Configuration>) () -> injectionManager.getInstance(Configuration.class));
MultivaluedParameterExtractorFactory paramExtractor = new MultivaluedParameterExtractorFactory(lazyParamConverterFactory);
bind(paramExtractor).to(MultivaluedParameterExtractorProvider.class);
// Parameter injection value providers
AsyncResponseValueSupplierProvider asyncSupplier = new AsyncResponseValueSupplierProvider(asyncContextProvider);
bindValueSupplier(asyncSupplier);
CookieParamValueSupplierProvider cookieSupplier = new CookieParamValueSupplierProvider(paramExtractor, requestProvider);
bindValueSupplier(cookieSupplier);
EntityParamValueSupplierProvider entitySupplier = new EntityParamValueSupplierProvider(paramExtractor, requestProvider);
bindValueSupplier(entitySupplier);
FormParamValueSupplierProvider formSupplier = new FormParamValueSupplierProvider(paramExtractor, requestProvider);
bindValueSupplier(formSupplier);
HeaderParamValueSupplierProvider headerSupplier = new HeaderParamValueSupplierProvider(paramExtractor, requestProvider);
bindValueSupplier(headerSupplier);
MatrixParamValueSupplierProvider matrixSupplier = new MatrixParamValueSupplierProvider(paramExtractor, requestProvider);
bindValueSupplier(matrixSupplier);
PathParamValueSupplierProvider pathSupplier = new PathParamValueSupplierProvider(paramExtractor, requestProvider);
bindValueSupplier(pathSupplier);
QueryParamValueSupplierProvider querySupplier = new QueryParamValueSupplierProvider(paramExtractor, requestProvider);
bindValueSupplier(querySupplier);
WebTargetValueSupplierProvider webTargetSupplier = new WebTargetValueSupplierProvider(requestProvider, lazyConfiguration, clientConfigProvider);
bindValueSupplier(webTargetSupplier);
BeanParamValueSupplierProvider beanSupplier = new BeanParamValueSupplierProvider(paramExtractor, requestProvider, injectionManager);
bindValueSupplier(beanSupplier);
// Register InjectionResolvers with param providers
// TODO: RENAME INJECTION RESOLVER
bind(new ParamInjectionResolver<>(cookieSupplier, CookieParam.class));
bind(new ParamInjectionResolver<>(formSupplier, FormParam.class));
bind(new ParamInjectionResolver<>(headerSupplier, HeaderParam.class));
bind(new ParamInjectionResolver<>(matrixSupplier, MatrixParam.class));
bind(new ParamInjectionResolver<>(querySupplier, QueryParam.class));
bind(new ParamInjectionResolver<>(pathSupplier, PathParam.class));
bind(new ParamInjectionResolver<>(asyncSupplier, Suspended.class));
bind(new ParamInjectionResolver<>(webTargetSupplier, Uri.class));
bind(new ParamInjectionResolver<>(beanSupplier, BeanParam.class));
// Delegated value supplier for Context InjectionResolver which is implemented directly in DI provider
ContextInjectionResolver contextInjectionResolver = injectionManager.getInstance(ContextInjectionResolver.class);
bind(new DelegatedInjectionValueSupplierProvider(contextInjectionResolver, injectionManager::createForeignDescriptor)).to(ValueSupplierProvider.class);
}
Aggregations