|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.glassfish.jersey.internal.inject.Providers
public class Providers
Utility class providing a set of utility methods for easier and more type-safe interaction with HK2 injection layer.
| Method Summary | ||
|---|---|---|
static boolean |
checkProviderRuntime(Class<?> provider,
ConstrainedTo.Type runtimeConstraint,
boolean scanned,
boolean isResource)
Check the provider whether it is appropriate correctly configured for client or server
runtime. |
|
static
|
factoryOf(T instance)
Wrap an instance into a HK2 service factory. |
|
static Set<Class<?>> |
filterByConstraint(Set<Class<?>> providers,
ConstrainedTo.Type currentRuntime,
Set<Class<?>> registeredClasses)
Filter provider instances removing all providers not targeted to the currentRuntime. |
|
static Set<Object> |
filterInstancesByConstraint(Set<Object> providerInstances,
ConstrainedTo.Type currentRuntime,
Set<Class<?>> registeredClasses)
Filter provider instances removing all providers not targeted to the currentRuntime. |
|
static
|
getAllProviders(ServiceLocator locator,
Class<T> contract)
Get the iterable of all providers (custom and default) registered for the given service provider contract in the underlying HK2 service locator container. |
|
static
|
getAllProviders(ServiceLocator locator,
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 HK2 service locator container ordered based on the given comparator. |
|
static
|
getAllProviders(ServiceLocator locator,
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 HK2 service locator container. |
|
static
|
getAllRankedProviders(ServiceLocator locator,
Class<T> contract)
Get the iterable of all providers (custom and default) registered for the given service provider
contract in the underlying HK2 service locator container. |
|
static
|
getCustomProviders(ServiceLocator locator,
Class<T> contract)
Get the set of all custom providers registered for the given service provider contract in the underlying HK2 service locator container. |
|
static Set<Class<?>> |
getProviderContracts(Class<?> clazz)
Returns provider contracts recognized by Jersey that are implemented by the clazz. |
|
static
|
getProviders(ServiceLocator locator,
Class<T> contract)
Get the set of default providers registered for the given service provider contract in the underlying HK2 service locator container. |
|
static
|
getProviders(ServiceLocator locator,
Class<T> contract,
Comparator<T> comparator)
Get the set of all providers registered for the given service provider contract in the underlying HK2 locator container. |
|
static boolean |
isProvider(Class<?> clazz)
Returns true if the given class is a provider (implements specific interfaces). |
|
static
|
sortRankedProviders(RankedComparator<T> comparator,
Iterable<RankedProvider<T>>... providerIterables)
Sorts given providers with ranked comparator. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <T> Factory<T> factoryOf(T instance)
T - Java type if the contract produced by the provider and factory.instance - instance to be wrapped into (and provided by) the factory.
public static <T> Set<T> getProviders(ServiceLocator locator,
Class<T> contract)
HK2 service locator container.
T - service provider contract Java type.locator - underlying HK2 service locator.contract - service provider contract.
public static <T> Set<T> getCustomProviders(ServiceLocator locator,
Class<T> contract)
HK2 service locator container.
T - service provider contract Java type.locator - underlying HK2 service locator.contract - service provider contract.
public static <T> Iterable<T> getAllProviders(ServiceLocator locator,
Class<T> contract)
HK2 service locator container.
T - service provider contract Java type.locator - underlying HK2 service locator.contract - service provider contract.
public static <T> Iterable<RankedProvider<T>> getAllRankedProviders(ServiceLocator locator,
Class<T> contract)
providers (custom and default) registered for the given service provider
contract in the underlying HK2 service locator container.
T - service provider contract Java type.locator - underlying HK2 service locator.contract - service provider contract.
public static <T> Iterable<T> sortRankedProviders(RankedComparator<T> comparator,
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. Return value is never null.
public static <T> Iterable<T> getAllProviders(ServiceLocator locator,
Class<T> contract,
RankedComparator<T> comparator)
providers (custom and default) registered for the given service
provider contract in the underlying HK2 service locator container.
T - service provider contract Java type.locator - underlying HK2 service locator.contract - service provider contract.comparator - comparator to sort the providers with.
public static <T> Iterable<T> getAllProviders(ServiceLocator locator,
Class<T> contract,
Comparator<T> comparator)
HK2 service locator container ordered based on the given comparator.
T - service provider contract Java type.locator - underlying HK2 service locator.contract - service provider contract.comparator - comparator to be used for sorting the returned providers.
comparator.
public static <T> SortedSet<T> getProviders(ServiceLocator locator,
Class<T> contract,
Comparator<T> comparator)
HK2 locator container.
T - service provider contract Java type.locator - underlying HK2 service locator.contract - service provider contract.comparator - contract comparator used for ordering contracts in the
set.
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 Set<Object> filterInstancesByConstraint(Set<Object> providerInstances,
ConstrainedTo.Type currentRuntime,
Set<Class<?>> registeredClasses)
currentRuntime.
The provider applicability to a runtime is determined based on the @ConstraintTo
restriction placed on the contract interface as well as any @ConstrainedTo restrictions
placed on the contract implementation class.
A warning is logged for all providers that have been filtered out.
providerInstances - providers to be filtered.currentRuntime - current runtime.registeredClasses - classes which were explicitly registered and not found by the classpath scanning
or any other kind of class scanning.
public static Set<Class<?>> filterByConstraint(Set<Class<?>> providers,
ConstrainedTo.Type currentRuntime,
Set<Class<?>> registeredClasses)
currentRuntime.
The provider applicability to a runtime is determined based on the @ConstraintTo
restriction placed on the contract interface as well as any @ConstrainedTo restrictions
placed on the contract implementation class.
A warning is logged for all providers that have been filtered out.
providers - providers to be filtered.currentRuntime - current runtime.registeredClasses - classes which were explicitly registered and not found by the classpath scanning or any other
kind of class scanning.
public static boolean checkProviderRuntime(Class<?> provider,
ConstrainedTo.Type runtimeConstraint,
boolean scanned,
boolean isResource)
provider whether it is appropriate correctly configured for client or server
runtime.
If a problem occurs a warning is logged and if the provider is not usable at all in the current runtime
false is returned. For classes found during provider scanning (scanned=true) certain warnings are completely
ignored (e.g. providers constrained to the client runtime and found by server-side class path
scanning will be silently ignored and no warning will be logged).
provider - the class of the provider being checked.runtimeConstraint - current runtime (client or server).scanned - false if the class was explicitly registered; true if the class has been
discovered
during any form of provider scanning.isResource - true if the provider is also a resource class.
true if provider is fine and can be used false otherwise.public static boolean isProvider(Class<?> clazz)
true if the given class is a provider (implements specific interfaces).
See getProviderContracts(java.lang.Class>).
clazz - class to test.
true if the class is provider, false otherwise.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||