Class ProviderBinder
- java.lang.Object
-
- org.glassfish.jersey.internal.inject.ProviderBinder
-
public class ProviderBinder extends java.lang.Object
Class used for registration of the custom providers into injection manager.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 inProviders
class.
-
-
Field Summary
Fields Modifier and Type Field Description private InjectionManager
injectionManager
-
Constructor Summary
Constructors Constructor Description ProviderBinder(InjectionManager injectionManager)
Create new provider binder instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bindClasses(java.lang.Class<?>... classes)
Register/bind custom provider classes.void
bindClasses(java.lang.Iterable<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
bindInstances(java.lang.Iterable<java.lang.Object> instances)
Register/bind custom provider instances.void
bindInstances(java.util.Collection<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, javax.ws.rs.RuntimeType constrainedTo, java.util.Set<java.lang.Class<?>> registeredClasses, InjectionManager injectionManager)
Bind all providers contained inproviderBag
(classes and instances) using injection manager.static void
bindProviders(ComponentBag componentBag, InjectionManager injectionManager)
Bind all providers contained inproviderBag
(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)
-
-
-
Field Detail
-
injectionManager
private final InjectionManager injectionManager
-
-
Constructor Detail
-
ProviderBinder
public ProviderBinder(InjectionManager injectionManager)
Create new provider binder instance.- Parameters:
injectionManager
- the binder will use to bind the providers into.
-
-
Method Detail
-
bindProvider
public static void bindProvider(java.lang.Class<?> providerClass, ContractProvider model, InjectionManager injectionManager)
Bind contract provider model to a provider class using the supplied injection manager.- Parameters:
providerClass
- provider class.model
- contract provider model.
-
createProviderBinders
private static java.util.Collection<Binder> createProviderBinders(java.lang.Class<?> providerClass, ContractProvider model)
-
bindProvider
public static void bindProvider(java.lang.Object providerInstance, ContractProvider model, InjectionManager injectionManager)
Bind contract provider model to a provider instance using the supplied injection manager.Scope value specified in the
contract provider model
is ignored as instances can only be bound as "singletons".- Parameters:
providerInstance
- provider instance.model
- contract provider model.
-
createProviderBinders
private static java.util.Collection<Binder> createProviderBinders(java.lang.Object providerInstance, ContractProvider model)
-
bindProviders
public static void bindProviders(ComponentBag componentBag, InjectionManager injectionManager)
Bind all providers contained inproviderBag
(classes and instances) using injection manager. Configuration is also committed.- Parameters:
componentBag
- bag of provider classes and instances.injectionManager
- injection manager the binder will use to bind the providers into.
-
bindProviders
public static void bindProviders(ComponentBag componentBag, javax.ws.rs.RuntimeType constrainedTo, java.util.Set<java.lang.Class<?>> registeredClasses, InjectionManager injectionManager)
Bind all providers contained inproviderBag
(classes and instances) using injection manager. Configuration is also committed.- Parameters:
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.
-
createInstanceBinders
private static <T> java.util.Collection<Binder> createInstanceBinders(T instance)
-
bindInstances
public void bindInstances(java.lang.Iterable<java.lang.Object> instances)
Register/bind custom provider instances. Registered providers will be handled always as Singletons.- Parameters:
instances
- custom provider instances.
-
bindInstances
public void bindInstances(java.util.Collection<java.lang.Object> instances)
Register/bind custom provider instances. Registered providers will be handled always as Singletons.- Parameters:
instances
- custom provider instances.
-
bindClasses
public void bindClasses(java.lang.Class<?>... classes)
Register/bind custom provider classes. Registered providers will be handled always as Singletons unless annotated byPerLookup
.- Parameters:
classes
- custom provider classes.
-
bindClasses
public void bindClasses(java.lang.Iterable<java.lang.Class<?>> classes)
Register/bind custom provider classes. Registered providers will be handled always as Singletons unless annotated byPerLookup
.- Parameters:
classes
- custom provider classes.
-
bindClasses
public void bindClasses(java.util.Collection<java.lang.Class<?>> classes)
Register/bind custom provider classes. Registered providers will be handled always as Singletons unless annotated byPerLookup
.- Parameters:
classes
- custom provider classes.
-
bindClasses
public void bindClasses(java.util.Collection<java.lang.Class<?>> classes, boolean bindResources)
Register/bind custom provider classes that may also be resources. Registered providers/resources will be handled always as Singletons unless annotated byPerLookup
.If
bindAsResources
is set totrue
, the providers will also be bound as resources.- Parameters:
classes
- custom provider classes.bindResources
- iftrue
, the provider classes will also be bound as resources.
-
createClassBinders
private <T> Binder createClassBinders(java.lang.Class<T> clazz, boolean isResource)
-
getProviderScope
private java.lang.Class<? extends java.lang.annotation.Annotation> getProviderScope(java.lang.Class<?> clazz)
-
-