Class BindingBuilderFactory
java.lang.Object
org.glassfish.hk2.utilities.binding.BindingBuilderFactory
HK2 injection binding utility methods.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addBinding
(BindingBuilder<?> builder, DynamicConfiguration configuration) Add a binding represented by the binding builder to the HK2 dynamic configuration.static void
addBinding
(BindingBuilder<?> builder, DynamicConfiguration configuration, HK2Loader defaultLoader) Add a binding represented by the binding builder to the HK2 dynamic configuration.static <T> ServiceBindingBuilder
<T> Get a new class-based service binding builder.static <T> ScopedBindingBuilder
<T> newBinder
(T service) Get a new instance-based service binding builder.static <T> ServiceBindingBuilder
<T> newFactoryBinder
(Class<? extends Factory<T>> factoryType) Get a new factory class-based service binding builder.static <T> ServiceBindingBuilder
<T> newFactoryBinder
(Class<? extends Factory<T>> factoryType, Class<? extends Annotation> factoryScope) Get a new factory class-based service binding builder.static <T> ServiceBindingBuilder
<T> newFactoryBinder
(Factory<T> factory) Get a new factory instance-based service binding builder.
-
Constructor Details
-
BindingBuilderFactory
public BindingBuilderFactory()
-
-
Method Details
-
addBinding
Add a binding represented by the binding builder to the HK2 dynamic configuration.- Parameters:
builder
- binding builder.configuration
- HK2 dynamic configuration.
-
addBinding
public static void addBinding(BindingBuilder<?> builder, DynamicConfiguration configuration, HK2Loader defaultLoader) Add a binding represented by the binding builder to the HK2 dynamic configuration.- Parameters:
builder
- binding builder.configuration
- HK2 dynamic configuration.defaultLoader
- default HK2 service loader that should be used to load the service class in case a custom loader has not been set.
-
newFactoryBinder
public static <T> ServiceBindingBuilder<T> newFactoryBinder(Class<? extends Factory<T>> factoryType, Class<? extends Annotation> factoryScope) Get a new factory class-based service binding builder.- Type Parameters:
T
- service type.- Parameters:
factoryType
- service factory class.factoryScope
- factory scope.- Returns:
- initialized binding builder.
-
newFactoryBinder
public static <T> ServiceBindingBuilder<T> newFactoryBinder(Class<? extends Factory<T>> factoryType) Get a new factory class-based service binding builder. The factory itself is bound in aper-lookup
scope.- Type Parameters:
T
- service type.- Parameters:
factoryType
- service factory class.- Returns:
- initialized binding builder.
-
newFactoryBinder
Get a new factory instance-based service binding builder.- Type Parameters:
T
- service type.- Parameters:
factory
- service instance.- Returns:
- initialized binding builder.
-
newBinder
Get a new class-based service binding builder. Does NOT bind the service type itself as a contract type.- Type Parameters:
T
- service type.- Parameters:
serviceType
- service class.- Returns:
- initialized binding builder.
-
newBinder
Get a new instance-based service binding builder. The binding is naturally considered to be asingleton-scoped
. Does NOT bind the service type itself as a contract type.- Type Parameters:
T
- service type.- Parameters:
service
- service instance.- Returns:
- initialized binding builder.
-