public abstract class AbstractBinder extends Object implements Binder
Binder
interface dedicated to keep some level of code compatibility between previous HK2
implementation and new DI SPI.
Currently, there are supported only bind method and more complicated method where HK2 interfaces are required were omitted.
Constructor and Description |
---|
AbstractBinder() |
Modifier and Type | Method and Description |
---|---|
Binding |
bind(Binding binding)
Binds the provided binding and return the same instance.
|
<T> ClassBinding<T> |
bind(Class<T> serviceType)
Start building a new class-based service binding.
|
<T> InstanceBinding<T> |
bind(T service)
Start building a new instance-based service binding.
|
<T extends InjectionResolver> |
bind(T resolver)
Start building a new injection resolver binding.
|
<T> ClassBinding<T> |
bindAsContract(Class<T> serviceType)
Start building a new class-based service binding.
|
<T> ClassBinding<T> |
bindAsContract(GenericType<T> serviceType)
Start building a new generic type-based service binding.
|
ClassBinding<Object> |
bindAsContract(Type serviceType)
Start building a new generic type-based service binding.
|
<T> SupplierClassBinding<T> |
bindFactory(Class<? extends Supplier<T>> supplierType)
Start building a new supplier class-based service binding.
|
<T> SupplierClassBinding<T> |
bindFactory(Class<? extends Supplier<T>> supplierType,
Class<? extends Annotation> supplierScope)
Start building a new supplier class-based service binding.
|
<T> SupplierInstanceBinding<T> |
bindFactory(Supplier<T> factory)
Start building a new supplier instance-based service binding.
|
protected abstract void |
configure()
Implement to provide binding definitions using the exposed binding methods.
|
protected <T> javax.inject.Provider<T> |
createManagedInstanceProvider(Class<T> clazz)
Creates a new instance of
Provider which is able to retrieve a managed instance registered in
InjectionManager . |
Collection<Binding> |
getBindings()
Gets a collection of descriptors registered in this jersey binder.
|
void |
install(AbstractBinder... binders)
Adds all binding definitions from the binders to the binding configuration.
|
protected abstract void configure()
protected final <T> javax.inject.Provider<T> createManagedInstanceProvider(Class<T> clazz)
Provider
which is able to retrieve a managed instance registered in
InjectionManager
. If InjectionManager
is null
at the time of calling Provider.get()
then
IllegalStateException
is thrown.T
- type of the managed instance returned using provider.clazz
- class of managed instance.public <T> ClassBinding<T> bind(Class<T> serviceType)
Does NOT bind the service type itself as a contract type.
T
- service type.serviceType
- service class.public Binding bind(Binding binding)
binding
- binding.public <T> ClassBinding<T> bindAsContract(Class<T> serviceType)
Binds the service type itself as a contract type.
T
- service type.serviceType
- service class.public <T> ClassBinding<T> bindAsContract(GenericType<T> serviceType)
Binds the generic service type itself as a contract type.
T
- service type.serviceType
- generic service type information.public ClassBinding<Object> bindAsContract(Type serviceType)
Binds the generic service type itself as a contract type.
serviceType
- generic service type information.public <T> InstanceBinding<T> bind(T service)
singleton-scoped
.
Does NOT bind the service type itself as a contract type.
T
- service type.service
- service instance.public <T> SupplierClassBinding<T> bindFactory(Class<? extends Supplier<T>> supplierType, Class<? extends Annotation> supplierScope)
T
- service type.supplierType
- service supplier class.supplierScope
- factory scope.public <T> SupplierClassBinding<T> bindFactory(Class<? extends Supplier<T>> supplierType)
The supplier itself is bound in a per-lookup scope.
T
- service type.supplierType
- service supplier class.public <T> SupplierInstanceBinding<T> bindFactory(Supplier<T> factory)
T
- service type.factory
- service instance.public <T extends InjectionResolver> InjectionResolverBinding<T> bind(T resolver)
singleton-scoped
.
There is no need to provide any additional information. Other method on Binding
will be ignored.
T
- type of the injection resolver.resolver
- injection resolver instance.public final void install(AbstractBinder... binders)
binders
- binders whose binding definitions should be configured.public Collection<Binding> getBindings()
Binder
getBindings
in interface Binder
Copyright © 2007-2024, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.