private UnsafeValue<SSLContext, IllegalStateException> createLazySslContext(final DefaultSslContextProvider provider) { return Values.lazy(new UnsafeValue<SSLContext, IllegalStateException>() { @Override public SSLContext get() { return provider.getDefaultSslContext(); } }); }
private UnsafeValue<SSLContext, IllegalStateException> createLazySslContext(final DefaultSslContextProvider provider) { return Values.lazy(new UnsafeValue<SSLContext, IllegalStateException>() { @Override public SSLContext get() { return provider.getDefaultSslContext(); } }); }
/** * Creates new instance from root allResources. * * @param allResources Root resource of the resource model. */ private ResourceModel(List<Resource> rootResources, List<Resource> allResources) { this.resources = allResources; this.rootResources = rootResources; this.runtimeRootResourceModelValue = Values.lazy(new Value<RuntimeResourceModel>() { @Override public RuntimeResourceModel get() { return new RuntimeResourceModel(ResourceModel.this.resources); } }); }
/** * Creates new instance from root allResources. * * @param allResources Root resource of the resource model. */ private ResourceModel(List<Resource> rootResources, List<Resource> allResources) { this.resources = allResources; this.rootResources = rootResources; this.runtimeRootResourceModelValue = Values.lazy(new Value<RuntimeResourceModel>() { @Override public RuntimeResourceModel get() { return new RuntimeResourceModel(ResourceModel.this.resources); } }); }
private UnsafeValue<SSLContext, IllegalStateException> createLazySslContext(final DefaultSslContextProvider provider) { return Values.lazy(new UnsafeValue<SSLContext, IllegalStateException>() { @Override public SSLContext get() { return provider.getDefaultSslContext(); } }); }
/** * Create JAXB string reader provider. * * @param ps used to obtain {@link JAXBContext} and {@link Unmarshaller} {@link ContextResolver ContextResolvers} */ public JaxbStringReaderProvider(final Providers ps) { this.mtContext = Values.lazy(new Value<ContextResolver<JAXBContext>>() { @Override public ContextResolver<JAXBContext> get() { return ps.getContextResolver(JAXBContext.class, null); } }); this.mtUnmarshaller = Values.lazy(new Value<ContextResolver<Unmarshaller>>() { @Override public ContextResolver<Unmarshaller> get() { return ps.getContextResolver(Unmarshaller.class, null); } }); }
@Context public void setConfiguration(final Configuration config) { formattedOutput = Values.lazy(new Value<Boolean>() { @Override public Boolean get() { return PropertiesHelper.isProperty(config.getProperty(MessageProperties.XML_FORMAT_OUTPUT)); } }); xmlRootElementProcessing = Values.lazy(new Value<Boolean>() { @Override public Boolean get() { return PropertiesHelper.isProperty(config.getProperty(MessageProperties.JAXB_PROCESS_XML_ROOT_ELEMENT)); } }); }
/** * Creates a new constructor analyzer which accepts the class that is analyzed. * * @param clazz analyzed class. * @param annotations all annotations used for an injecting. */ public CachedConstructorAnalyzer(Class<T> clazz, Collection<Class<? extends Annotation>> annotations) { this.resolverAnnotations = annotations; this.constructor = Values.lazy((Value<Constructor<T>>) () -> getConstructorInternal(clazz)); }
ResourceMethodInvocationHandlerFactory(InjectionManager injectionManager) { this.providers = Values.lazy((Value<Set<ResourceMethodInvocationHandlerProvider>>) () -> Providers.getProviders(injectionManager, ResourceMethodInvocationHandlerProvider.class)); }
ResourceMethodInvocationHandlerFactory(InjectionManager injectionManager) { this.providers = Values.lazy((Value<Set<ResourceMethodInvocationHandlerProvider>>) () -> Providers.getProviders(injectionManager, ResourceMethodInvocationHandlerProvider.class)); }
/** * Lazily initialize {@link AsyncContext} for this * request processing context. * <p> * The {@code lazyContextValue} will be only invoked once during the first call to {@link #asyncContext()}. * As such, the asynchronous context for this request can be initialized lazily, on demand. * </p> * * @param lazyContextValue lazily initialized {@code AsyncContext} instance bound to this request processing context. */ // TODO figure out how to make this package-private. public void initAsyncContext(Value<AsyncContext> lazyContextValue) { asyncContextValueRef.set(Values.lazy(lazyContextValue)); }
/** * Injection constructor. * * @param defaultAnalyzer default HK2 class analyzer. * @param supplierResolvers configured injection resolvers. */ private JerseyClassAnalyzer(ClassAnalyzer defaultAnalyzer, Supplier<List<InjectionResolver>> supplierResolvers) { this.defaultAnalyzer = defaultAnalyzer; Value<Set<Class>> resolvers = () -> supplierResolvers.get().stream() .filter(InjectionResolver::isConstructorParameterIndicator) .map(InjectionResolver::getAnnotation) .collect(ImmutableCollectors.toImmutableSet()); this.resolverAnnotations = Values.lazy(resolvers); }
/** * Injection constructor. * * @param defaultAnalyzer default HK2 class analyzer. * @param supplierResolvers configured injection resolvers. */ private JerseyClassAnalyzer(ClassAnalyzer defaultAnalyzer, Supplier<List<InjectionResolver>> supplierResolvers) { this.defaultAnalyzer = defaultAnalyzer; Value<Set<Class>> resolvers = () -> supplierResolvers.get().stream() .filter(InjectionResolver::isConstructorParameterIndicator) .map(InjectionResolver::getAnnotation) .collect(ImmutableCollectors.toImmutableSet()); this.resolverAnnotations = Values.lazy(resolvers); }
/** * Lazily initialize {@link AsyncContext} for this * request processing context. * <p> * The {@code lazyContextValue} will be only invoked once during the first call to {@link #asyncContext()}. * As such, the asynchronous context for this request can be initialized lazily, on demand. * </p> * * @param lazyContextValue lazily initialized {@code AsyncContext} instance bound to this request processing context. */ // TODO figure out how to make this package-private. public void initAsyncContext(Value<AsyncContext> lazyContextValue) { asyncContextValueRef.set(Values.lazy(lazyContextValue)); }
/** * An implementation of {@link InjectionTarget} for classes that do not fulfill bean class requirements * (e.g. are abstract or non-static inner classes). Instances of these class can be injected using this implementation. If the * application attempts to {@link #produce(CreationalContext)} a new instance of the class, {@code CreationException} is * thrown. * * @param delegate CDI specific injection target. * @param bean bean as descriptor of the class which will be injected. * @param resolvers all resolvers that can provide a valued for Jersey-specific injection. */ public WrappingJerseyInjectionTarget(InjectionTarget<T> delegate, Bean<T> bean, Collection<InjectionResolver> resolvers) { this.bean = bean; this.delegate = delegate; this.resolvers = resolvers; this.injector = Values.lazy((Value<JerseyInstanceInjector<T>>) () -> new JerseyInstanceInjector<>(bean, this.resolvers)); }
@Override public void init(InjectionManager injectionManager, BootstrapBag bootstrapBag) { ServerBootstrapBag serverBag = (ServerBootstrapBag) bootstrapBag; // There are situation in which ComponentProviders are not needed therefore their entire initialization is wrapped // into a lazy block. LazyValue<Collection<ComponentProvider>> componentProviders = Values.lazy((Value<Collection<ComponentProvider>>) () -> getRankedComponentProviders().stream() .map(RankedProvider::getProvider) .peek(provider -> provider.initialize(injectionManager)) .collect(Collectors.toList())); serverBag.setComponentProviders(componentProviders); }
@Override public void init(InjectionManager injectionManager, BootstrapBag bootstrapBag) { ServerBootstrapBag serverBag = (ServerBootstrapBag) bootstrapBag; // There are situation in which ComponentProviders are not needed therefore their entire initialization is wrapped // into a lazy block. LazyValue<Collection<ComponentProvider>> componentProviders = Values.lazy((Value<Collection<ComponentProvider>>) () -> getRankedComponentProviders().stream() .map(RankedProvider::getProvider) .peek(provider -> provider.initialize(injectionManager)) .collect(Collectors.toList())); serverBag.setComponentProviders(componentProviders); }
private Resource(final Resource parent, final Data data) { this.parent = parent; this.data = data; this.name = Values.lazy(new Value<String>() { @Override public String get() { if (data.names.size() == 1) { return data.names.get(0); } else { // return merged name return "Merge of " + data.names.toString(); } } }); this.resourceMethods = immutableCopy(ResourceMethod.transform(Resource.this, data.resourceMethods)); this.locator = data.subResourceLocator == null ? null : new ResourceMethod(Resource.this, data.subResourceLocator); this.childResources = immutableCopy(Resource.transform(Resource.this, data.childResources)); }
@Override public void init(InjectionManager injectionManager, BootstrapBag bootstrapBag) { ServerBootstrapBag serverBag = (ServerBootstrapBag) bootstrapBag; // 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))); MultivaluedParameterExtractorFactory multiExtractor = new MultivaluedParameterExtractorFactory(lazyParamConverterFactory); serverBag.setMultivaluedParameterExtractorProvider(multiExtractor); injectionManager.register( Bindings.service(multiExtractor) .to(MultivaluedParameterExtractorProvider.class)); } }
@Override public void init(InjectionManager injectionManager, BootstrapBag bootstrapBag) { ServerBootstrapBag serverBag = (ServerBootstrapBag) bootstrapBag; // 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))); MultivaluedParameterExtractorFactory multiExtractor = new MultivaluedParameterExtractorFactory(lazyParamConverterFactory); serverBag.setMultivaluedParameterExtractorProvider(multiExtractor); injectionManager.register( Bindings.service(multiExtractor) .to(MultivaluedParameterExtractorProvider.class)); } }