Class AbstractBinder
- java.lang.Object
-
- org.glassfish.jersey.internal.inject.AbstractBinder
-
- All Implemented Interfaces:
Binder
- Direct Known Subclasses:
ClientBinder
,CompositeBinder
,EntityFilteringBinder
,ExternalRequestScopeConfigurator.NoopExternalRequestScopeBinder
,JacksonFilteringFeature.Binder
,JaxbMessagingBinder
,JaxbParamConverterBinder
,JettyHttpContainer.JettyBinder
,MappableExceptionWrapperInterceptor.Binder
,MessagingBinders.HeaderDelegateProviders
,MessagingBinders.MessageBodyProviders
,MonitoringContainerListener.Binder
,OAuth1SignatureFeature.Binder
,PersistenceUnitBinder
,RequestProcessingConfigurator.ServerProcessingBinder
,ServerBinder
,ServiceFinderBinder
,SimpleContainer.SimpleBinder
,WebComponent.WebComponentBinder
public abstract class AbstractBinder extends java.lang.Object implements Binder
Implementation ofBinder
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.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
configured
private InjectionManager
injectionManager
private java.util.List<AbstractBinder>
installed
private java.util.List<Binding>
internalBindings
-
Constructor Summary
Constructors Constructor Description AbstractBinder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <T> ClassBinding<T>
bind(java.lang.Class<T> serviceType)
Start building a new class-based service binding.Binding
bind(Binding binding)
Binds the provided binding and return the same instance.<T> InstanceBinding<T>
bind(T service)
Start building a new instance-based service binding.<T> ClassBinding<T>
bindAsContract(java.lang.Class<T> serviceType)
Start building a new class-based service binding.ClassBinding<java.lang.Object>
bindAsContract(java.lang.reflect.Type serviceType)
Start building a new generic type-based service binding.<T> ClassBinding<T>
bindAsContract(javax.ws.rs.core.GenericType<T> serviceType)
Start building a new generic type-based service binding.<T> SupplierClassBinding<T>
bindFactory(java.lang.Class<? extends java.util.function.Supplier<T>> supplierType)
Start building a new supplier class-based service binding.<T> SupplierClassBinding<T>
bindFactory(java.lang.Class<? extends java.util.function.Supplier<T>> supplierType, java.lang.Class<? extends java.lang.annotation.Annotation> supplierScope)
Start building a new supplier class-based service binding.<T> SupplierInstanceBinding<T>
bindFactory(java.util.function.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(java.lang.Class<T> clazz)
Creates a new instance ofProvider
which is able to retrieve a managed instance registered inInjectionManager
.java.util.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.private void
invokeConfigure()
(package private) void
setInjectionManager(InjectionManager injectionManager)
SetsInjectionManager
to be able to create instance providers using the injection manager.
-
-
-
Field Detail
-
internalBindings
private java.util.List<Binding> internalBindings
-
installed
private java.util.List<AbstractBinder> installed
-
injectionManager
private InjectionManager injectionManager
-
configured
private boolean configured
-
-
Method Detail
-
configure
protected abstract void configure()
Implement to provide binding definitions using the exposed binding methods.
-
setInjectionManager
void setInjectionManager(InjectionManager injectionManager)
SetsInjectionManager
to be able to create instance providers using the injection manager.InjectionManager
should be called before the invocation ofconfigure()
, otherwise immediate invocationProvider.get()
returns- Parameters:
injectionManager
- injection manager to create a provider.
-
createManagedInstanceProvider
protected final <T> javax.inject.Provider<T> createManagedInstanceProvider(java.lang.Class<T> clazz)
Creates a new instance ofProvider
which is able to retrieve a managed instance registered inInjectionManager
. IfInjectionManager
isnull
at the time of callingProvider.get()
thenIllegalStateException
is thrown.- Type Parameters:
T
- type of the managed instance returned using provider.- Parameters:
clazz
- class of managed instance.- Returns:
- provider with instance of managed instance.
-
bind
public <T> ClassBinding<T> bind(java.lang.Class<T> serviceType)
Start building a new class-based service binding.Does NOT bind the service type itself as a contract type.
- Type Parameters:
T
- service type.- Parameters:
serviceType
- service class.- Returns:
- initialized binding builder.
-
bind
public Binding bind(Binding binding)
Binds the provided binding and return the same instance.- Parameters:
binding
- binding.- Returns:
- the same provided binding.
-
bindAsContract
public <T> ClassBinding<T> bindAsContract(java.lang.Class<T> serviceType)
Start building a new class-based service binding.Binds the service type itself as a contract type.
- Type Parameters:
T
- service type.- Parameters:
serviceType
- service class.- Returns:
- initialized binding builder.
-
bindAsContract
public <T> ClassBinding<T> bindAsContract(javax.ws.rs.core.GenericType<T> serviceType)
Start building a new generic type-based service binding.Binds the generic service type itself as a contract type.
- Type Parameters:
T
- service type.- Parameters:
serviceType
- generic service type information.- Returns:
- initialized binding builder.
-
bindAsContract
public ClassBinding<java.lang.Object> bindAsContract(java.lang.reflect.Type serviceType)
Start building a new generic type-based service binding.Binds the generic service type itself as a contract type.
- Parameters:
serviceType
- generic service type information.- Returns:
- initialized binding builder.
-
bind
public <T> InstanceBinding<T> bind(T service)
Start building a new instance-based service binding. 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.
-
bindFactory
public <T> SupplierClassBinding<T> bindFactory(java.lang.Class<? extends java.util.function.Supplier<T>> supplierType, java.lang.Class<? extends java.lang.annotation.Annotation> supplierScope)
Start building a new supplier class-based service binding.- Type Parameters:
T
- service type.- Parameters:
supplierType
- service supplier class.supplierScope
- factory scope.- Returns:
- initialized binding builder.
-
bindFactory
public <T> SupplierClassBinding<T> bindFactory(java.lang.Class<? extends java.util.function.Supplier<T>> supplierType)
Start building a new supplier class-based service binding.The supplier itself is bound in a per-lookup scope.
- Type Parameters:
T
- service type.- Parameters:
supplierType
- service supplier class.- Returns:
- initialized binding builder.
-
bindFactory
public <T> SupplierInstanceBinding<T> bindFactory(java.util.function.Supplier<T> factory)
Start building a new supplier instance-based service binding.- Type Parameters:
T
- service type.- Parameters:
factory
- service instance.- Returns:
- initialized binding builder.
-
bind
public <T extends InjectionResolver> InjectionResolverBinding<T> bind(T resolver)
Start building a new injection resolver binding. The injection resolver is naturally considered to be asingleton-scoped
.There is no need to provide any additional information. Other method on
Binding
will be ignored.- Type Parameters:
T
- type of the injection resolver.- Parameters:
resolver
- injection resolver instance.- Returns:
- initialized binding builder.
-
install
public final void install(AbstractBinder... binders)
Adds all binding definitions from the binders to the binding configuration.- Parameters:
binders
- binders whose binding definitions should be configured.
-
getBindings
public java.util.Collection<Binding> getBindings()
Description copied from interface:Binder
Gets a collection of descriptors registered in this jersey binder.- Specified by:
getBindings
in interfaceBinder
- Returns:
- collection of descriptors.
-
invokeConfigure
private void invokeConfigure()
-
-