public final class Providers extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
checkProviderRuntime(Class<?> component,
ContractProvider model,
RuntimeType runtimeConstraint,
boolean scanned,
boolean isResource)
Check the
component whether it is appropriate correctly configured for client or server
runtime . |
static void |
ensureContract(Class<?> contract,
Class<?>... implementations)
Ensure the supplied implementation classes implement the expected contract.
|
static <T> Iterable<T> |
getAllProviders(InjectionManager injectionManager,
Class<T> contract)
Get the iterable of all providers (custom and default) registered for the given service provider contract
in the underlying
injection manager container. |
static <T> Iterable<T> |
getAllProviders(InjectionManager injectionManager,
Class<T> contract,
Comparator<T> comparator)
Get the iterable of all providers (custom and default) registered for the given service provider contract
in the underlying
injection manager container ordered based on the given comparator . |
static <T> Iterable<T> |
getAllProviders(InjectionManager injectionManager,
Class<T> contract,
RankedComparator<T> comparator)
Get the sorted iterable of all
providers (custom and default) registered for the given service
provider contract in the underlying injection manager container. |
static <T> Iterable<RankedProvider<T>> |
getAllRankedProviders(InjectionManager injectionManager,
Class<T> contract)
Get the iterable of all
providers (custom and default) registered for the given service provider
contract in the underlying injection manager container. |
static <T> Iterable<T> |
getAllRankedSortedProviders(InjectionManager injectionManager,
Class<T> contract)
Get the iterable of all providers (custom and default) registered for the given service provider contract in the underlying
injection manager container and automatically sorted using
ranked comparator . |
static <T> Collection<ServiceHolder<T>> |
getAllServiceHolders(InjectionManager injectionManager,
Class<T> contract)
Get collection of all
ServiceHolder s bound for providers (custom and default) registered for the given service
provider contract in the underlying injection manager container. |
static <T> Set<T> |
getCustomProviders(InjectionManager injectionManager,
Class<T> contract)
Get the set of all custom providers registered for the given service provider contract
in the underlying
injection manager container. |
static Set<Class<?>> |
getProviderContracts(Class<?> clazz)
Returns provider contracts recognized by Jersey that are implemented by the
clazz . |
static <T> Set<T> |
getProviders(InjectionManager injectionManager,
Class<T> contract)
Get the set of default providers registered for the given service provider contract
in the underlying
injection manager container. |
static boolean |
isJaxRsProvider(Class<?> clazz)
Returns
true if given component class is a JAX-RS provider. |
static boolean |
isProvider(Class<?> clazz)
Returns
true if the given component class is a provider (implements specific interfaces). |
static boolean |
isSupportedContract(Class<?> type)
Check if the given Java type is a Jersey-supported contract.
|
static <T> Iterable<T> |
mergeAndSortRankedProviders(RankedComparator<T> comparator,
Iterable<Iterable<RankedProvider<T>>> providerIterables)
Merge and sort given providers with
ranked comparator . |
static <T> Iterable<T> |
sortRankedProviders(RankedComparator<T> comparator,
Iterable<RankedProvider<T>> providers)
Sort given providers with
ranked comparator . |
public static <T> Set<T> getProviders(InjectionManager injectionManager, Class<T> contract)
injection manager
container.T
- service provider contract Java type.injectionManager
- underlying injection manager.contract
- service provider contract.public static <T> Set<T> getCustomProviders(InjectionManager injectionManager, Class<T> contract)
injection manager
container.
Returned providers are sorted based on Priority
(lower Priority
value is higher priority,
see Priorities
.
T
- service provider contract Java type.injectionManager
- underlying injection manager.contract
- service provider contract.public static <T> Iterable<T> getAllProviders(InjectionManager injectionManager, Class<T> contract)
injection manager
container.T
- service provider contract Java type.injectionManager
- underlying injection manager.contract
- service provider contract.public static <T> Iterable<RankedProvider<T>> getAllRankedProviders(InjectionManager injectionManager, Class<T> contract)
providers
(custom and default) registered for the given service provider
contract in the underlying injection manager
container.T
- service provider contract Java type.injectionManager
- underlying injection manager.contract
- service provider contract.null
.public static <T> Iterable<T> sortRankedProviders(RankedComparator<T> comparator, Iterable<RankedProvider<T>> providers)
ranked comparator
.T
- service provider contract Java type.comparator
- comparator to sort the providers with.providers
- providers to be sorted.iterable
instance containing given providers.
The returned value is never null
.public static <T> Iterable<T> getAllRankedSortedProviders(InjectionManager injectionManager, Class<T> contract)
injection manager
container and automatically sorted using
ranked comparator
.T
- service provider contract Java type.injectionManager
- underlying injection manager.contract
- service provider contract.null
.public static <T> Iterable<T> mergeAndSortRankedProviders(RankedComparator<T> comparator, Iterable<Iterable<RankedProvider<T>>> providerIterables)
ranked comparator
.T
- service provider contract Java type.comparator
- comparator to sort the providers with.providerIterables
- providers to be sorted.iterable
instance containing given providers.
The returned value is never null
.public static <T> Iterable<T> getAllProviders(InjectionManager injectionManager, Class<T> contract, RankedComparator<T> comparator)
providers
(custom and default) registered for the given service
provider contract in the underlying injection manager
container.T
- service provider contract Java type.injectionManager
- underlying injection manager.contract
- service provider contract.comparator
- comparator to sort the providers with.public static <T> Collection<ServiceHolder<T>> getAllServiceHolders(InjectionManager injectionManager, Class<T> contract)
ServiceHolder
s bound for providers (custom and default) registered for the given service
provider contract in the underlying injection manager
container.T
- service provider contract Java type.injectionManager
- underlying injection manager.contract
- service provider contract.public static boolean isJaxRsProvider(Class<?> clazz)
true
if given component class is a JAX-RS provider.clazz
- class to check.true
if the class is a JAX-RS provider, false
otherwise.public static <T> Iterable<T> getAllProviders(InjectionManager injectionManager, Class<T> contract, Comparator<T> comparator)
injection manager
container ordered based on the given comparator
.T
- service provider contract Java type.injectionManager
- underlying injection manager.contract
- service provider contract.comparator
- comparator to be used for sorting the returned providers.comparator
.public static Set<Class<?>> getProviderContracts(Class<?> clazz)
clazz
.
Recognized provider contracts include all JAX-RS providers as well as all Jersey SPI
components annotated with @Contract
annotation.clazz
- class to extract the provider interfaces from.public static boolean checkProviderRuntime(Class<?> component, ContractProvider model, RuntimeType runtimeConstraint, boolean scanned, boolean isResource)
component
whether it is appropriate correctly configured for client or server
runtime
.
If a problem occurs a warning is logged and if the component is not usable at all in the current runtime
false
is returned. For classes found during component scanning (scanned=true) certain warnings are
completely ignored (e.g. components constrained to
the client runtime and found by
server-side class path scanning will be silently ignored and no warning will be logged).
component
- the class of the component being checked.model
- model of the component.runtimeConstraint
- current runtime (client or server).scanned
- false
if the component type has been registered explicitly;
true
if the class has been discovered during any form of component scanning.isResource
- true
if the component is also a resource class.true
if component is acceptable for use in the given runtime type, false
otherwise.public static boolean isSupportedContract(Class<?> type)
type
- contract type.true
if given type is a Jersey-supported contract, false
otherwise.public static boolean isProvider(Class<?> clazz)
true
if the given component class is a provider (implements specific interfaces).
See getProviderContracts(java.lang.Class<?>)
.clazz
- class to test.true
if the class is provider, false
otherwise.public static void ensureContract(Class<?> contract, Class<?>... implementations)
contract
- contract that is expected to be implemented by the implementation classes.implementations
- contract implementations.IllegalArgumentException
- in case any of the implementation classes does not
implement the expected contract.Copyright © 2007-2024, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.