Class Hk2Helper
java.lang.Object
org.glassfish.jersey.inject.hk2.Hk2Helper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static voidBind descriptors to Hk2-likeBinder.(package private) static voidBind descriptors to Hk2-likeBinder.(package private) static voidbind(AbstractHk2InjectionManager injectionManager, Binder jerseyBinder) Bind a translated Jersey-likeBinderto HK2-likeBinder.private static voidbindBinding(org.glassfish.hk2.api.ServiceLocator locator, org.glassfish.hk2.api.DynamicConfiguration dc, org.glassfish.hk2.api.ActiveDescriptor<?> activeDescriptor, Set<AliasBinding> aliases) Binds a new instanceBindingusing the information from the Jersey descriptorInstanceBinding.private static voidbindBinding(org.glassfish.hk2.api.ServiceLocator locator, org.glassfish.hk2.api.DynamicConfiguration dc, Binding<?, ?> binding) Binds the single descriptor using an externalDynamicConfiguration.private static voidbindBinding(org.glassfish.hk2.api.ServiceLocator locator, Binding<?, ?> binding) Binds the single descriptor using a singleDynamicConfiguration.private static voidbindSupplierClassBinding(org.glassfish.hk2.api.ServiceLocator locator, SupplierClassBinding<?> binding) Registers a new instanceBinderusing the information from the Jersey bindingSupplierClassBinding.private static voidbindSupplierInstanceBinding(org.glassfish.hk2.api.ServiceLocator locator, SupplierInstanceBinding<?> binding) Registers a new instanceBinderusing the information from the Jersey bindingSupplierInstanceBinding.private static org.glassfish.hk2.utilities.AliasDescriptor<?> createAlias(org.glassfish.hk2.api.ServiceLocator locator, org.glassfish.hk2.api.ActiveDescriptor<?> descriptor, AliasBinding alias) Creates the alias object to a provided descriptor.private static org.glassfish.hk2.utilities.BindercreateBinder(Consumer<org.glassfish.hk2.utilities.binding.AbstractBinder> bindConsumer) Creates a new binder and automatically use it to bind the the descriptors inbindConsumer.private static org.glassfish.hk2.api.DynamicConfigurationgetDynamicConfiguration(org.glassfish.hk2.api.ServiceLocator locator) GetsDynamicConfigurationServiceobject fromHK2 Locatorand creates a new object ofDynamicConfigurationto bind new services.private static voidsetupSupplierFactoryBridge(Binding<?, ?> binding, org.glassfish.hk2.utilities.binding.ServiceBindingBuilder<?> builder) private static Class<? extends Annotation> transformScope(Class<? extends Annotation> scope) Transforms Jersey scopes/annotations to HK2 equivalents.(package private) static org.glassfish.hk2.api.ActiveDescriptor<?> translateToActiveDescriptor(ClassBinding<?> desc) private static org.glassfish.hk2.api.ActiveDescriptor<?> (package private) static org.glassfish.hk2.api.ActiveDescriptor<?> translateToActiveDescriptor(InstanceBinding<?> desc, Type... contracts) private static org.glassfish.hk2.api.ActiveDescriptor<?> wrapInjectionResolver(InjectionResolverBinding resolverDescriptor)
-
Constructor Details
-
Hk2Helper
Hk2Helper()
-
-
Method Details
-
bind
Bind a translated Jersey-likeBinderto HK2-likeBinder.- Parameters:
injectionManager- HK2 injection manager.jerseyBinder- Jersey-like binder.
-
bind
Bind descriptors to Hk2-likeBinder.- Parameters:
locator- HK2 locator.binding- single descriptor.
-
bind
-
getDynamicConfiguration
private static org.glassfish.hk2.api.DynamicConfiguration getDynamicConfiguration(org.glassfish.hk2.api.ServiceLocator locator) GetsDynamicConfigurationServiceobject fromHK2 Locatorand creates a new object ofDynamicConfigurationto bind new services.- Parameters:
locator- HK2 locator.- Returns:
- new instance of
DynamicConfigurationto bind new services.
-
bindBinding
Binds the single descriptor using a singleDynamicConfiguration.- Parameters:
locator- HK2 injection manager.binding- Jersey descriptor as a holder of information about an injection point.
-
bindBinding
private static void bindBinding(org.glassfish.hk2.api.ServiceLocator locator, org.glassfish.hk2.api.DynamicConfiguration dc, Binding<?, ?> binding) Binds the single descriptor using an externalDynamicConfiguration.- Parameters:
locator- HK2 injection manager.dc- HK2 Dynamic configuration to bind the object.binding- Jersey descriptor as a holder of information about an injection point.
-
wrapInjectionResolver
private static org.glassfish.hk2.api.ActiveDescriptor<?> wrapInjectionResolver(InjectionResolverBinding resolverDescriptor) -
bindSupplierInstanceBinding
private static void bindSupplierInstanceBinding(org.glassfish.hk2.api.ServiceLocator locator, SupplierInstanceBinding<?> binding) Registers a new instanceBinderusing the information from the Jersey bindingSupplierInstanceBinding.- Parameters:
locator- HK2 instance manager.binding- Jersey descriptor as a holder of information about an injection point.
-
bindSupplierClassBinding
private static void bindSupplierClassBinding(org.glassfish.hk2.api.ServiceLocator locator, SupplierClassBinding<?> binding) Registers a new instanceBinderusing the information from the Jersey bindingSupplierClassBinding.- Parameters:
locator- HK2 instance manager.binding- Jersey descriptor as a holder of information about an injection point.
-
setupSupplierFactoryBridge
private static void setupSupplierFactoryBridge(Binding<?, ?> binding, org.glassfish.hk2.utilities.binding.ServiceBindingBuilder<?> builder) -
translateToActiveDescriptor
-
bindBinding
private static void bindBinding(org.glassfish.hk2.api.ServiceLocator locator, org.glassfish.hk2.api.DynamicConfiguration dc, org.glassfish.hk2.api.ActiveDescriptor<?> activeDescriptor, Set<AliasBinding> aliases) Binds a new instanceBindingusing the information from the Jersey descriptorInstanceBinding.Along with a new instance, the method is able to register aliases belonging to the new service.
- Parameters:
locator- HK2 injection manager.dc- HK2 Dynamic configuration to bind the object.activeDescriptor- HK2 active descriptor.aliases- aliases belonging to the given descriptor.
-
translateToActiveDescriptor
static org.glassfish.hk2.api.ActiveDescriptor<?> translateToActiveDescriptor(InstanceBinding<?> desc, Type... contracts) -
translateToActiveDescriptor
private static org.glassfish.hk2.api.ActiveDescriptor<?> translateToActiveDescriptor(InjectionResolverBinding<?> desc) -
createAlias
private static org.glassfish.hk2.utilities.AliasDescriptor<?> createAlias(org.glassfish.hk2.api.ServiceLocator locator, org.glassfish.hk2.api.ActiveDescriptor<?> descriptor, AliasBinding alias) Creates the alias object to a provided descriptor.- Parameters:
locator- locator used to create an alias.descriptor- descriptor which the alias belongs to.alias- source of the alias information.- Returns:
- populated alias object, ready to bindBinder using
DynamicConfiguration.
-
createBinder
private static org.glassfish.hk2.utilities.Binder createBinder(Consumer<org.glassfish.hk2.utilities.binding.AbstractBinder> bindConsumer) Creates a new binder and automatically use it to bind the the descriptors inbindConsumer.- Parameters:
bindConsumer- consumer used to process the defined operation with a binder.- Returns:
- populated binder.
-
transformScope
Transforms Jersey scopes/annotations to HK2 equivalents.- Parameters:
scope- Jersey scope/annotation.- Returns:
- HK2 equivalent scope/annotation.
-