public class ProviderBinder
extends java.lang.Object
Custom providers are classes that implements specific JAX-RS or Jersey
SPI interfaces (e.g. MessageBodyReader
) and are
supplied by the user. These providers will be bound into the injection manager
annotated by a @Custom
qualifier annotation.
Use the @Custom
qualifier annotation to retrieve these providers
from injection manager. You may also use a one of the provider accessor utility
method defined in Providers
class.
Modifier and Type | Field and Description |
---|---|
private InjectionManager |
injectionManager |
Constructor and Description |
---|
ProviderBinder(InjectionManager injectionManager)
Create new provider binder instance.
|
Modifier and Type | Method and Description |
---|---|
void |
bindClasses(java.lang.Class<?>... classes)
Register/bind custom provider classes.
|
void |
bindClasses(java.util.Collection<java.lang.Class<?>> classes)
Register/bind custom provider classes.
|
void |
bindClasses(java.util.Collection<java.lang.Class<?>> classes,
boolean bindResources)
Register/bind custom provider classes that may also be resources.
|
void |
bindClasses(java.lang.Iterable<java.lang.Class<?>> classes)
Register/bind custom provider classes.
|
void |
bindInstances(java.util.Collection<java.lang.Object> instances)
Register/bind custom provider instances.
|
void |
bindInstances(java.lang.Iterable<java.lang.Object> instances)
Register/bind custom provider instances.
|
static void |
bindProvider(java.lang.Class<?> providerClass,
ContractProvider model,
InjectionManager injectionManager)
Bind contract provider model to a provider class using the supplied injection manager.
|
static void |
bindProvider(java.lang.Object providerInstance,
ContractProvider model,
InjectionManager injectionManager)
Bind contract provider model to a provider instance using the supplied injection manager.
|
static void |
bindProviders(ComponentBag componentBag,
InjectionManager injectionManager)
Bind all providers contained in
providerBag (classes and instances) using injection manager. |
static void |
bindProviders(ComponentBag componentBag,
javax.ws.rs.RuntimeType constrainedTo,
java.util.Set<java.lang.Class<?>> registeredClasses,
InjectionManager injectionManager)
Bind all providers contained in
providerBag (classes and instances) using injection manager. |
private <T> Binder |
createClassBinders(java.lang.Class<T> clazz,
boolean isResource) |
private static <T> java.util.Collection<Binder> |
createInstanceBinders(T instance) |
private static java.util.Collection<Binder> |
createProviderBinders(java.lang.Class<?> providerClass,
ContractProvider model) |
private static java.util.Collection<Binder> |
createProviderBinders(java.lang.Object providerInstance,
ContractProvider model) |
private java.lang.Class<? extends java.lang.annotation.Annotation> |
getProviderScope(java.lang.Class<?> clazz) |
private final InjectionManager injectionManager
public ProviderBinder(InjectionManager injectionManager)
injectionManager
- the binder will use to bind the providers into.public static void bindProvider(java.lang.Class<?> providerClass, ContractProvider model, InjectionManager injectionManager)
providerClass
- provider class.model
- contract provider model.private static java.util.Collection<Binder> createProviderBinders(java.lang.Class<?> providerClass, ContractProvider model)
public static void bindProvider(java.lang.Object providerInstance, ContractProvider model, InjectionManager injectionManager)
Scope value specified in the contract provider model
is ignored as instances can only be bound as "singletons".
providerInstance
- provider instance.model
- contract provider model.private static java.util.Collection<Binder> createProviderBinders(java.lang.Object providerInstance, ContractProvider model)
public static void bindProviders(ComponentBag componentBag, InjectionManager injectionManager)
providerBag
(classes and instances) using injection manager. Configuration is
also committed.componentBag
- bag of provider classes and instances.injectionManager
- injection manager the binder will use to bind the providers into.public static void bindProviders(ComponentBag componentBag, javax.ws.rs.RuntimeType constrainedTo, java.util.Set<java.lang.Class<?>> registeredClasses, InjectionManager injectionManager)
providerBag
(classes and instances) using injection manager. Configuration is
also committed.componentBag
- bag of provider classes and instances.constrainedTo
- current runtime (client or server).registeredClasses
- classes which are manually registered by the user (not found by the classpath scanning).injectionManager
- injection manager the binder will use to bind the providers into.private static <T> java.util.Collection<Binder> createInstanceBinders(T instance)
public void bindInstances(java.lang.Iterable<java.lang.Object> instances)
instances
- custom provider instances.public void bindInstances(java.util.Collection<java.lang.Object> instances)
instances
- custom provider instances.public void bindClasses(java.lang.Class<?>... classes)
PerLookup
.classes
- custom provider classes.public void bindClasses(java.lang.Iterable<java.lang.Class<?>> classes)
PerLookup
.classes
- custom provider classes.public void bindClasses(java.util.Collection<java.lang.Class<?>> classes)
PerLookup
.classes
- custom provider classes.public void bindClasses(java.util.Collection<java.lang.Class<?>> classes, boolean bindResources)
PerLookup
.
If bindAsResources
is set to true
, the providers will also be bound
as resources.
classes
- custom provider classes.bindResources
- if true
, the provider classes will also be bound as
resources.private <T> Binder createClassBinders(java.lang.Class<T> clazz, boolean isResource)
private java.lang.Class<? extends java.lang.annotation.Annotation> getProviderScope(java.lang.Class<?> clazz)