Top Description Inners Fields Constructors Methods
org.glassfish.tyrus.core

public final Class ServiceFinder<T>

extends Object
implements Iterable<T>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable
Type Parameters
<T>
the type of the service instance.
Imports
java.io.BufferedReader, .IOException, .InputStream, .InputStreamReader, java.lang.reflect.Array, .ReflectPermission, java.net.URL, .URLConnection, java.security.AccessController, .PrivilegedActionException, java.util.ArrayList, .Enumeration, .Iterator, .List, .NoSuchElementException, .Set, .TreeSet, java.util.logging.Level, .Logger, org.glassfish.tyrus.core.l10n.LocalizationMessages

A simple service-provider lookup mechanism. A service is a well-known set of interfaces and (usually abstract) classes. A service provider is a specific implementation of a service. The classes in a provider typically implement the interfaces and subclass the classes defined in the service itself. Service providers may be installed in an implementation of the Java platform in the form of extensions, that is, jar files placed into any of the usual extension directories. Providers may also be made available by adding them to the applet or application class path or by some other platform-specific means.

In this lookup mechanism a service is represented by an interface or an abstract class. (A concrete class may be used, but this is not recommended.) A provider of a given service contains one or more concrete classes that extend this service class with data and code specific to the provider. This provider class will typically not be the entire provider itself but rather a proxy that contains enough information to decide whether the provider is able to satisfy a particular request together with code that can create the actual provider on demand. The details of provider classes tend to be highly service-specific; no single class or interface could possibly unify them, so no such class has been defined. The only requirement enforced here is that provider classes must have a zero-argument constructor so that they may be instantiated during lookup.

The default service provider registration/lookup mechanism based on META-INF/services files is described below. For environments, where the basic mechanism is not suitable, clients can enforce a different approach by setting their custom ServiceIteratorProvider by calling setIteratorProvider. The call must be made prior to any lookup attempts.

A service provider identifies itself by placing a provider-configuration file in the resource directory META-INF/services. The file's name should consist of the fully-qualified name of the abstract service class. The file should contain a list of fully-qualified concrete provider-class names, one per line. Space and tab characters surrounding each name, as well as blank lines, are ignored. The comment character is '#' (0x23); on each line all characters following the first comment character are ignored. The file must be encoded in UTF-8.

If a particular concrete provider class is named in more than one configuration file, or is named in the same configuration file more than once, then the duplicates will be ignored. The configuration file naming a particular provider need not be in the same jar file or other distribution unit as the provider itself. The provider must be accessible from the same class loader that was initially queried to locate the configuration file; note that this is not necessarily the class loader that found the file.

Example: Suppose we have a service class named java.io.spi.CharCodec. It has two abstract methods:

  public abstract CharEncoder getEncoder(String encodingName);
  public abstract CharDecoder getDecoder(String encodingName);

Each method returns an appropriate object or null if it cannot translate the given encoding. Typical CharCodec providers will support more than one encoding.

If sun.io.StandardCodec is a provider of the CharCodec service then its jar file would contain the file META-INF/services/java.io.spi.CharCodec. This file would contain the single line:

  sun.io.StandardCodec    # Standard codecs for the platform

To locate an codec for a given encoding name, the internal I/O code would do something like this:

  CharEncoder getEncoder(String encodingName) {
      for( CharCodec cc : ServiceFinder.find(CharCodec.class) ) {
          CharEncoder ce = cc.getEncoder(encodingName);
          if (ce != null)
              return ce;
      }
      return null;
  }

The provider-lookup mechanism always executes in the security context of the caller. Trusted system code should typically invoke the methods in this class from within a privileged security context.

Authors
Mark Reinhold, Jakub Podlesak, Marek Potociar

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public static class
ServiceFinder.DefaultServiceIteratorProvider

The default service iterator provider that looks up provider classes in META-INF/services files.

private static class
private static class
public abstract static class
ServiceFinder.ServiceIteratorProvider

Supports iteration of provider instances or classes.

Field Summary

Modifier and TypeField and Description
private final ClassLoader
private final boolean
private static final Logger
private static final String
private final Class<T>
private final String

Constructor Summary

AccessConstructor and Description
private
ServiceFinder(Class<T> service, ClassLoader loader, boolean ignoreOnClassNotFound)

private
ServiceFinder(Class<T> service, String serviceName, ClassLoader loader, boolean ignoreOnClassNotFound)

Method Summary

Modifier and TypeMethod and Description
private static ClassLoader
private static void
fail(String serviceName, String msg, Throwable cause)

private static void
fail(String serviceName, String msg)

private static void
fail(String serviceName, URL u, int line, String msg)

public static <
the type of the service instance.
T
>
ServiceFinder<T>

Returns:

the service finder
find
(Class<T>
The service's abstract service class
service
,
ClassLoader
The class loader to be used to load provider-configuration files and instantiate provider classes, or null if the system class loader (or, failing that the bootstrap class loader) is to be used
loader
)

Locates and incrementally instantiates the available providers of a given service using the given class loader.

public static <
the type of the service instance.
T
>
ServiceFinder<T>

Returns:

the service finder
find
(Class<T>
The service's abstract service class
service
,
ClassLoader
The class loader to be used to load provider-configuration files and instantiate provider classes, or null if the system class loader (or, failing that the bootstrap class loader) is to be used
loader
,
boolean
If a provider cannot be loaded by the class loader then move on to the next available provider.
ignoreOnClassNotFound
)

Locates and incrementally instantiates the available providers of a given service using the given class loader.

public static <
the type of the service instance.
T
>
ServiceFinder<T>

Returns:

the service finder
find
(Class<T>
The service's abstract service class
service
)

Locates and incrementally instantiates the available providers of a given service using the context class loader.

public static <
the type of the service instance.
T
>
ServiceFinder<T>

Returns:

the service finder
find
(Class<T>
The service's abstract service class
service
,
boolean
If a provider cannot be loaded by the class loader then move on to the next available provider.
ignoreOnClassNotFound
)

Locates and incrementally instantiates the available providers of a given service using the context class loader.

public static ServiceFinder<?>

Returns:

the service finder
find
(String
the service name correspond to a file in META-INF/services that contains a list of fully qualified class names
serviceName
)

Locates and incrementally instantiates the available classes of a given service file using the context class loader.

private static Enumeration<URL>
private static Enumeration<URL>
public Iterator<T>

Returns:

An Iterator that yields provider objects for the given service, in some arbitrary order. The iterator will throw a ServiceConfigurationError if a provider-configuration file violates the specified format or if a provider class cannot be found and instantiated.
iterator
()

Implements java.lang.Iterable.iterator.

Returns discovered objects incrementally.

private static Iterator<String>

Returns:

A (possibly empty) Iterator that will yield the provider-class names in the given configuration file that are not yet members of the returned set
parse
(String
The service class for which providers are being sought; used to construct error detail strings
serviceName
,
URL
The URL naming the configuration file to be parsed
u
,
Set<String>
A Set containing the names of provider classes that have already been returned. This set will be updated to contain the names that will be yielded from the returned Iterator.
returned
)

Parse the content of the given URL as a provider-configuration file.

private static int
parseLine(String serviceName, URL u, BufferedReader r, int lc, List<String> names, Set<String> returned)

Parse a single line from the given configuration file, adding the name on the line to both the names list and the returned set iff the name is not already a member of the returned set.

public static void
setIteratorProvider(ServiceFinder.ServiceIteratorProvider
the service iterator provider.
sip
)

Register the service iterator provider to iterate on provider instances or classes.

public T[]

Returns:

can be empty but never null.
toArray
()

Returns discovered objects all at once.

public Class<T>[]

Returns:

can be empty but never null.
toClassArray
()

Returns discovered classes all at once.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classLoaderback to summary
private final ClassLoader classLoader
ignoreOnClassNotFoundback to summary
private final boolean ignoreOnClassNotFound
LOGGERback to summary
private static final Logger LOGGER
PREFIXback to summary
private static final String PREFIX
serviceClassback to summary
private final Class<T> serviceClass
serviceNameback to summary
private final String serviceName

Constructor Detail

ServiceFinderback to summary
private ServiceFinder(Class<T> service, ClassLoader loader, boolean ignoreOnClassNotFound)
ServiceFinderback to summary
private ServiceFinder(Class<T> service, String serviceName, ClassLoader loader, boolean ignoreOnClassNotFound)

Method Detail

_getContextClassLoaderback to summary
private static ClassLoader _getContextClassLoader()
failback to summary
private static void fail(String serviceName, String msg, Throwable cause) throws ServiceConfigurationError
failback to summary
private static void fail(String serviceName, String msg) throws ServiceConfigurationError
failback to summary
private static void fail(String serviceName, URL u, int line, String msg) throws ServiceConfigurationError
findback to summary
public static <T> ServiceFinder<T> find(Class<T> service, ClassLoader loader) throws ServiceConfigurationError

Locates and incrementally instantiates the available providers of a given service using the given class loader.

This method transforms the name of the given service class into a provider-configuration filename as described above and then uses the getResources method of the given class loader to find all available files with that name. These files are then read and parsed to produce a list of provider-class names. The iterator that is returned uses the given class loader to lookup and then instantiate each element of the list.

Because it is possible for extensions to be installed into a running Java virtual machine, this method may return different results each time it is invoked.

Parameters
<T>
the type of the service instance.
service:Class<T>

The service's abstract service class

loader:ClassLoader

The class loader to be used to load provider-configuration files and instantiate provider classes, or null if the system class loader (or, failing that the bootstrap class loader) is to be used

Returns:ServiceFinder<T>

the service finder

Exceptions
ServiceConfigurationError:
If a provider-configuration file violates the specified format or names a provider class that cannot be found and instantiated
See Also
find(Class)
findback to summary
public static <T> ServiceFinder<T> find(Class<T> service, ClassLoader loader, boolean ignoreOnClassNotFound) throws ServiceConfigurationError

Locates and incrementally instantiates the available providers of a given service using the given class loader.

This method transforms the name of the given service class into a provider-configuration filename as described above and then uses the getResources method of the given class loader to find all available files with that name. These files are then read and parsed to produce a list of provider-class names. The iterator that is returned uses the given class loader to lookup and then instantiate each element of the list.

Because it is possible for extensions to be installed into a running Java virtual machine, this method may return different results each time it is invoked.

Parameters
<T>
the type of the service instance.
service:Class<T>

The service's abstract service class

loader:ClassLoader

The class loader to be used to load provider-configuration files and instantiate provider classes, or null if the system class loader (or, failing that the bootstrap class loader) is to be used

ignoreOnClassNotFound:boolean

If a provider cannot be loaded by the class loader then move on to the next available provider.

Returns:ServiceFinder<T>

the service finder

Exceptions
ServiceConfigurationError:
If a provider-configuration file violates the specified format or names a provider class that cannot be found and instantiated
See Also
find(Class)
findback to summary
public static <T> ServiceFinder<T> find(Class<T> service) throws ServiceConfigurationError

Locates and incrementally instantiates the available providers of a given service using the context class loader. This convenience method is equivalent to

  ClassLoader cl = Thread.currentThread().getContextClassLoader();
  return Service.providers(service, cl, false);
Parameters
<T>
the type of the service instance.
service:Class<T>

The service's abstract service class

Returns:ServiceFinder<T>

the service finder

Exceptions
ServiceConfigurationError:
If a provider-configuration file violates the specified format or names a provider class that cannot be found and instantiated
See Also
find(Class, ClassLoader)
findback to summary
public static <T> ServiceFinder<T> find(Class<T> service, boolean ignoreOnClassNotFound) throws ServiceConfigurationError

Locates and incrementally instantiates the available providers of a given service using the context class loader. This convenience method is equivalent to

  ClassLoader cl = Thread.currentThread().getContextClassLoader();
  boolean ingore = ...
  return Service.providers(service, cl, ignore);
Parameters
<T>
the type of the service instance.
service:Class<T>

The service's abstract service class

ignoreOnClassNotFound:boolean

If a provider cannot be loaded by the class loader then move on to the next available provider.

Returns:ServiceFinder<T>

the service finder

Exceptions
ServiceConfigurationError:
If a provider-configuration file violates the specified format or names a provider class that cannot be found and instantiated
See Also
find(Class, ClassLoader)
findback to summary
public static ServiceFinder<?> find(String serviceName) throws ServiceConfigurationError

Locates and incrementally instantiates the available classes of a given service file using the context class loader.

Parameters
serviceName:String

the service name correspond to a file in META-INF/services that contains a list of fully qualified class names

Returns:ServiceFinder<?>

the service finder

Exceptions
ServiceConfigurationError:
If a service file violates the specified format or names a provider class that cannot be found and instantiated
getResourcesback to summary
private static Enumeration<URL> getResources(ClassLoader loader, String name) throws IOException
getResourcesback to summary
private static Enumeration<URL> getResources(String name) throws IOException
iteratorback to summary
public Iterator<T> iterator()

Implements java.lang.Iterable.iterator.

Returns discovered objects incrementally.

Returns:Iterator<T>

An Iterator that yields provider objects for the given service, in some arbitrary order. The iterator will throw a ServiceConfigurationError if a provider-configuration file violates the specified format or if a provider class cannot be found and instantiated.

Annotations
@Override
parseback to summary
private static Iterator<String> parse(String serviceName, URL u, Set<String> returned) throws ServiceConfigurationError

Parse the content of the given URL as a provider-configuration file.

Parameters
serviceName:String

The service class for which providers are being sought; used to construct error detail strings

u:URL

The URL naming the configuration file to be parsed

returned:Set<String>

A Set containing the names of provider classes that have already been returned. This set will be updated to contain the names that will be yielded from the returned Iterator.

Returns:Iterator<String>

A (possibly empty) Iterator that will yield the provider-class names in the given configuration file that are not yet members of the returned set

Annotations
@SuppressWarnings:StatementWithEmptyBody
Exceptions
ServiceConfigurationError:
If an I/O error occurs while reading from the given URL, or if a configuration-file format error is detected
parseLineback to summary
private static int parseLine(String serviceName, URL u, BufferedReader r, int lc, List<String> names, Set<String> returned) throws IOException, ServiceConfigurationError

Parse a single line from the given configuration file, adding the name on the line to both the names list and the returned set iff the name is not already a member of the returned set.

setIteratorProviderback to summary
public static void setIteratorProvider(ServiceFinder.ServiceIteratorProvider sip) throws SecurityException

Register the service iterator provider to iterate on provider instances or classes.

The default implementation registered, DefaultServiceIteratorProvider, looks up provider classes in META-INF/service files.

This method must be called prior to any attempts to obtain provider instances or classes.

Parameters
sip:ServiceFinder.ServiceIteratorProvider

the service iterator provider.

Exceptions
SecurityException:
if the provider cannot be registered.
toArrayback to summary
public T[] toArray() throws ServiceConfigurationError

Returns discovered objects all at once.

Returns:T[]

can be empty but never null.

Annotations
@SuppressWarnings:unchecked
Exceptions
ServiceConfigurationError:
If a provider-configuration file violates the specified format or names a provider class that cannot be found and instantiated
toClassArrayback to summary
public Class<T>[] toClassArray() throws ServiceConfigurationError

Returns discovered classes all at once.

Returns:Class<T>[]

can be empty but never null.

Annotations
@SuppressWarnings:unchecked
Exceptions
ServiceConfigurationError:
If a provider-configuration file violates the specified format or names a provider class that cannot be found
org.glassfish.tyrus.core back to summary

private Class ServiceFinder.AbstractLazyIterator<T>

extends Object
Class Inheritance
Known Direct Subclasses
org.glassfish.tyrus.core.ServiceFinder.LazyClassIterator, org.glassfish.tyrus.core.ServiceFinder.LazyObjectIterator

Field Summary

Modifier and TypeField and Description
pack-priv Enumeration<URL>
pack-priv final boolean
pack-priv final ClassLoader
pack-priv String
pack-priv Iterator<String>
pack-priv Set<String>
pack-priv final Class<T>
pack-priv final String

Constructor Summary

AccessConstructor and Description
private
AbstractLazyIterator(Class<T> service, String serviceName, ClassLoader loader, boolean ignoreOnClassNotFound)

Method Summary

Modifier and TypeMethod and Description
private void
public boolean
public void
protected final void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

configsback to summary
pack-priv Enumeration<URL> configs
ignoreOnClassNotFoundback to summary
pack-priv final boolean ignoreOnClassNotFound
loaderback to summary
pack-priv final ClassLoader loader
nextNameback to summary
pack-priv String nextName
pendingback to summary
pack-priv Iterator<String> pending
returnedback to summary
pack-priv Set<String> returned
serviceback to summary
pack-priv final Class<T> service
serviceNameback to summary
pack-priv final String serviceName

Constructor Detail

AbstractLazyIteratorback to summary
private AbstractLazyIterator(Class<T> service, String serviceName, ClassLoader loader, boolean ignoreOnClassNotFound)

Method Detail

handleClassNotFoundExceptionback to summary
private void handleClassNotFoundException()
hasNextback to summary
public boolean hasNext() throws ServiceConfigurationError
removeback to summary
public void remove()
setConfigsback to summary
protected final void setConfigs()
org.glassfish.tyrus.core back to summary

public final Class ServiceFinder.DefaultServiceIteratorProvider

extends ServiceIteratorProvider
Class Inheritance

The default service iterator provider that looks up provider classes in META-INF/services files.

This class may utilized if a ServiceIteratorProvider needs to reuse the default implementation.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public <T> Iterator<Class<T>>
createClassIterator(Class<T>
the service class.
service
,
String
the service name.
serviceName
,
ClassLoader
the class loader to utilize when loading provider classes.
loader
,
boolean
if true ignore the provider class if cannot be found, otherwise throw a ClassNotFoundException.
ignoreOnClassNotFound
)

Implements abstract org.glassfish.tyrus.core.ServiceFinder.ServiceIteratorProvider.createClassIterator.

Iterate over provider classes of a service.

public <T> Iterator<T>
createIterator(Class<T>
the service class.
service
,
String
the service name.
serviceName
,
ClassLoader
the class loader to utilize when loading provider classes.
loader
,
boolean
if true ignore an instance if the corresponding provider class if cannot be found, otherwise throw a ClassNotFoundException.
ignoreOnClassNotFound
)

Implements abstract org.glassfish.tyrus.core.ServiceFinder.ServiceIteratorProvider.createIterator.

Iterate over provider instances of a service.

Constructor Detail

DefaultServiceIteratorProviderback to summary
public DefaultServiceIteratorProvider()

Method Detail

createClassIteratorback to summary
public <T> Iterator<Class<T>> createClassIterator(Class<T> service, String serviceName, ClassLoader loader, boolean ignoreOnClassNotFound)

Implements abstract org.glassfish.tyrus.core.ServiceFinder.ServiceIteratorProvider.createClassIterator.

Doc from org.glassfish.tyrus.core.ServiceFinder.ServiceIteratorProvider.createClassIterator.

Iterate over provider classes of a service.

Parameters
<T>
the type of the service.
service:Class<T>

the service class.

serviceName:String

the service name.

loader:ClassLoader

the class loader to utilize when loading provider classes.

ignoreOnClassNotFound:boolean

if true ignore the provider class if cannot be found, otherwise throw a ClassNotFoundException.

Returns:Iterator<Class<T>>

the provider class iterator.

Annotations
@Override
createIteratorback to summary
public <T> Iterator<T> createIterator(Class<T> service, String serviceName, ClassLoader loader, boolean ignoreOnClassNotFound)

Implements abstract org.glassfish.tyrus.core.ServiceFinder.ServiceIteratorProvider.createIterator.

Doc from org.glassfish.tyrus.core.ServiceFinder.ServiceIteratorProvider.createIterator.

Iterate over provider instances of a service.

Parameters
<T>
the type of the service.
service:Class<T>

the service class.

serviceName:String

the service name.

loader:ClassLoader

the class loader to utilize when loading provider classes.

ignoreOnClassNotFound:boolean

if true ignore an instance if the corresponding provider class if cannot be found, otherwise throw a ClassNotFoundException.

Returns:Iterator<T>

the provider instance iterator.

Annotations
@Override
org.glassfish.tyrus.core back to summary

private final Class ServiceFinder.LazyClassIterator<T>

extends ServiceFinder.AbstractLazyIterator<T>
implements Iterator<Class<T>>
Class Inheritance
All Implemented Interfaces
java.util.Iterator

Field Summary

Inherited from org.glassfish.tyrus.core.ServiceFinder.AbstractLazyIterator:
configsignoreOnClassNotFoundloadernextNamependingreturnedserviceserviceName

Constructor Summary

AccessConstructor and Description
private
LazyClassIterator(Class<T> service, String serviceName, ClassLoader loader, boolean ignoreOnClassNotFound)

Method Summary

Modifier and TypeMethod and Description
public Class<T>
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.

Inherited from org.glassfish.tyrus.core.ServiceFinder.AbstractLazyIterator:
hasNextremovesetConfigs

Constructor Detail

LazyClassIteratorback to summary
private LazyClassIterator(Class<T> service, String serviceName, ClassLoader loader, boolean ignoreOnClassNotFound)

Method Detail

nextback to summary
public Class<T> next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:Class<T>

the next element in the iteration

Annotations
@Override
org.glassfish.tyrus.core back to summary

private final Class ServiceFinder.LazyObjectIterator<T>

extends ServiceFinder.AbstractLazyIterator<T>
implements Iterator<T>
Class Inheritance
All Implemented Interfaces
java.util.Iterator

Field Summary

Modifier and TypeField and Description
private T
t

Inherited from org.glassfish.tyrus.core.ServiceFinder.AbstractLazyIterator:
configsignoreOnClassNotFoundloadernextNamependingreturnedserviceserviceName

Constructor Summary

AccessConstructor and Description
private
LazyObjectIterator(Class<T> service, String serviceName, ClassLoader loader, boolean ignoreOnClassNotFound)

Method Summary

Modifier and TypeMethod and Description
private void
public boolean
hasNext()

Overrides org.glassfish.tyrus.core.ServiceFinder.AbstractLazyIterator.hasNext.

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.

public T
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.

Inherited from org.glassfish.tyrus.core.ServiceFinder.AbstractLazyIterator:
removesetConfigs

Field Detail

tback to summary
private T t

Constructor Detail

LazyObjectIteratorback to summary
private LazyObjectIterator(Class<T> service, String serviceName, ClassLoader loader, boolean ignoreOnClassNotFound)

Method Detail

handleClassNotFoundExceptionback to summary
private void handleClassNotFoundException() throws ServiceConfigurationError

Hides org.glassfish.tyrus.core.ServiceFinder.AbstractLazyIterator.handleClassNotFoundException.

hasNextback to summary
public boolean hasNext() throws ServiceConfigurationError

Overrides org.glassfish.tyrus.core.ServiceFinder.AbstractLazyIterator.hasNext.

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public T next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:T

the next element in the iteration

Annotations
@Override
org.glassfish.tyrus.core back to summary

public abstract Class ServiceFinder.ServiceIteratorProvider

extends Object
Class Inheritance
  • java.lang.Object
  • org.glassfish.tyrus.core.ServiceFinder.ServiceIteratorProvider
Known Direct Subclasses
org.glassfish.tyrus.core.ServiceFinder.DefaultServiceIteratorProvider, org.glassfish.tyrus.core.OsgiRegistry.OsgiServiceFinder

Supports iteration of provider instances or classes.

The default implementation looks up provider classes from META-INF/services files, see DefaultServiceIteratorProvider. This implementation may be overridden by invoking ServiceFinder#setIteratorProvider(ServiceIteratorProvider)

Field Summary

Modifier and TypeField and Description
private static volatile ServiceFinder.ServiceIteratorProvider
private static final Object

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract <
the type of the service.
T
>
Iterator<Class<T>>

Returns:

the provider class iterator.
createClassIterator
(Class<T>
the service class.
service
,
String
the service name.
serviceName
,
ClassLoader
the class loader to utilize when loading provider classes.
loader
,
boolean
if true ignore the provider class if cannot be found, otherwise throw a ClassNotFoundException.
ignoreOnClassNotFound
)

Iterate over provider classes of a service.

public abstract <
the type of the service.
T
>
Iterator<T>

Returns:

the provider instance iterator.
createIterator
(Class<T>
the service class.
service
,
String
the service name.
serviceName
,
ClassLoader
the class loader to utilize when loading provider classes.
loader
,
boolean
if true ignore an instance if the corresponding provider class if cannot be found, otherwise throw a ClassNotFoundException.
ignoreOnClassNotFound
)

Iterate over provider instances of a service.

private static ServiceFinder.ServiceIteratorProvider
private static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

sipback to summary
private static volatile ServiceFinder.ServiceIteratorProvider sip
sipLockback to summary
private static final Object sipLock

Constructor Detail

ServiceIteratorProviderback to summary
public ServiceIteratorProvider()

Method Detail

createClassIteratorback to summary
public abstract <T> Iterator<Class<T>> createClassIterator(Class<T> service, String serviceName, ClassLoader loader, boolean ignoreOnClassNotFound)

Iterate over provider classes of a service.

Parameters
<T>
the type of the service.
service:Class<T>

the service class.

serviceName:String

the service name.

loader:ClassLoader

the class loader to utilize when loading provider classes.

ignoreOnClassNotFound:boolean

if true ignore the provider class if cannot be found, otherwise throw a ClassNotFoundException.

Returns:Iterator<Class<T>>

the provider class iterator.

createIteratorback to summary
public abstract <T> Iterator<T> createIterator(Class<T> service, String serviceName, ClassLoader loader, boolean ignoreOnClassNotFound)

Iterate over provider instances of a service.

Parameters
<T>
the type of the service.
service:Class<T>

the service class.

serviceName:String

the service name.

loader:ClassLoader

the class loader to utilize when loading provider classes.

ignoreOnClassNotFound:boolean

if true ignore an instance if the corresponding provider class if cannot be found, otherwise throw a ClassNotFoundException.

Returns:Iterator<T>

the provider instance iterator.

getInstanceback to summary
private static ServiceFinder.ServiceIteratorProvider getInstance()
setInstanceback to summary
private static void setInstance(ServiceFinder.ServiceIteratorProvider sip) throws SecurityException