All the methods in this class are safe to use by multiple concurrent threads.
| Modifier and Type | Class and Description |
|---|---|
| private static class | ServiceProvider.Selector
A filter and a comparator for processing the stream of service providers. |
| Modifier and Type | Field and Description |
|---|---|
| private static final AtomicReference | current
The current service provider, or |
| private static final String | LEGACY_NAMED_ANNOTATION
Class name of JSR-330 annotation for naming a service provider. |
| private static final String | LEGACY_PRIORITY_ANNOTATION
Class name of JSR-250 annotation for assigning a priority level to a service provider. |
| private static final String | NAMED_ANNOTATION
Class name of Jakarta Dependency Injection annotation for naming a service provider. |
| private static final String | PRIORITY_ANNOTATION
Class name of Jakarta Common Annotation for assigning a priority level to a service provider. |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public static final List | Returns: all service providers available for the current thread's context class loader.Returns the list of all service providers available for the current thread's context class loader. |
| public static final ServiceProvider | |
| public abstract FormatService | |
| public int | Returns: the provider's priority (default is 0).Allows to define a priority for a registered |
| public abstract < the type of the Q extends QuantityQuantity instances created by the factory | Returns: theQuantityFactory for the given typethe quantity type quantity)Returns a factory for the given |
| public abstract SystemOfUnitsService | |
| public static ServiceProvider | Returns: theServiceProvider with the specified namethe name of the service provider to return name)Returns the |
| public static final ServiceProvider | Returns: the replaced provider, or null.the new provider)ServiceProviderReplaces the current |
| current | back to summary |
|---|---|
| private static final AtomicReference<ServiceProvider> current The current service provider, or Implementation Note We do not cache a list of all service providers because that list depends
indirectly on the thread invoking the | |
| LEGACY_NAMED_ANNOTATION | back to summary |
|---|---|
| private static final String LEGACY_NAMED_ANNOTATION Class name of JSR-330 annotation for naming a service provider. We use reflection for keeping JSR-330 an optional dependency. | |
| LEGACY_PRIORITY_ANNOTATION | back to summary |
|---|---|
| private static final String LEGACY_PRIORITY_ANNOTATION Class name of JSR-250 annotation for assigning a priority level to a service provider. We use reflection for keeping JSR-250 an optional dependency. | |
| NAMED_ANNOTATION | back to summary |
|---|---|
| private static final String NAMED_ANNOTATION Class name of Jakarta Dependency Injection annotation for naming a service provider. We use reflection for keeping Jakata Injection an optional dependency. | |
| PRIORITY_ANNOTATION | back to summary |
|---|---|
| private static final String PRIORITY_ANNOTATION Class name of Jakarta Common Annotation for assigning a priority level to a service provider. We use reflection for keeping Jakarta Annotations an optional dependency. | |
| ServiceProvider | back to summary |
|---|---|
| protected ServiceProvider() Creates a new service provider. Only to be used by subclasses. | |
| available | back to summary |
|---|---|
| public static final List Returns the list of all service providers available for the current thread's context class loader. The current service provider is always the first item in the returned list. Other service providers after the first item may depend on the caller thread (see service loader API note).
| |
| current | back to summary |
|---|---|
| public static final ServiceProvider current() Returns the current
If there are no providers available, an IllegalStateException is thrown.
Otherwise the provider with the highest priority is used
or the one explicitly designated via
| |
| getFormatService | back to summary |
|---|---|
| public abstract FormatService getFormatService() Returns the service to obtain
| |
| getPriority | back to summary |
|---|---|
| public int getPriority() Allows to define a priority for a registered If the jakarta.annotation.Priority annotation (from Jakarta Annotations)
or javax.annotation.Priority annotation (from JSR-250) is present on the
| |
| getQuantityFactory | back to summary |
|---|---|
| public abstract <Q extends Quantity Returns a factory for the given
| |
| getSystemOfUnitsService | back to summary |
|---|---|
| public abstract SystemOfUnitsService getSystemOfUnitsService() Returns the service to obtain a
| |
| of | back to summary |
|---|---|
| public static ServiceProvider of(String name) Returns the Implementors are encouraged to provide an
| |
| setCurrent | back to summary |
|---|---|
| public static final ServiceProvider setCurrent(ServiceProvider provider) Replaces the current
| |
| Modifier and Type | Field and Description |
|---|---|
| private final Method | legacyNameGetter
The |
| private final Method | legacyPriorityGetter
The |
| private final Method | nameGetter
The |
| private final Method | priorityGetter
The |
| private final String | toSearch
The name of the provider to search, or |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public int | compare(final ServiceProvider
the first object to be compared. p1, final ServiceProvider the second object to be compared. p2)Implements java. |
| private static Object | Returns: the value, ornull if none.class of the provider on which to invoke annotation provider, Method value().the preferred getter, Method value() method to invoke, or null.an alternative fallback)value() method to invoke, or null.Invokes the |
| private static Method | Returns: thevalue() method, or null if the annotation class was not found.name of the class from which to get the classname)value() method.Returns the |
| private int | |
| private Stream | stream()
Gets all |
| public boolean | test(final ServiceProvider
the input argument provider)Implements java. true if the given service provider has the name we are looking for.
|
| legacyNameGetter | back to summary |
|---|---|
| private final Method legacyNameGetter The | |
| legacyPriorityGetter | back to summary |
|---|---|
| private final Method legacyPriorityGetter The | |
| nameGetter | back to summary |
|---|---|
| private final Method nameGetter The | |
| priorityGetter | back to summary |
|---|---|
| private final Method priorityGetter The | |
| toSearch | back to summary |
|---|---|
| private final String toSearch The name of the provider to search, or | |
| Selector | back to summary |
|---|---|
| pack-priv Selector(String name) Creates a new filter and comparator for a stream of service providers.
| |
| compare | back to summary |
|---|---|
| public int compare(final ServiceProvider p1, final ServiceProvider p2) Implements java. Compares the given service providers for order based on their priority.
The priority of each provider is determined as documented by
| |
| getValue | back to summary |
|---|---|
| private static Object getValue(final Class<?> provider, Method getter, Method fallback) Invokes the | |
| getValueMethod | back to summary |
|---|---|
| private static Method getValueMethod(final String classname) throws NoSuchMethodException Returns the | |
| priority | back to summary |
|---|---|
| private int priority(final ServiceProvider provider) Returns the priority of the given service provider.
This method looks for the jakarta.annotation.Priority and javax.annotation.Priority
annotations in that order, and if none are found falls back on | |
| stream | back to summary |
|---|---|
| private Stream Gets all | |
| test | back to summary |
|---|---|
| public boolean test(final ServiceProvider provider) Implements java. Returns
| |