org.nnsoft.commons.bspi
Class ServiceLoader<S>

java.lang.Object
  extended by org.nnsoft.commons.bspi.ServiceLoader<S>
Type Parameters:
S - The type of the service to be loaded by this loader.
All Implemented Interfaces:
Iterable<S>

public final class ServiceLoader<S>
extends Object
implements Iterable<S>

A simple service-provider loading facility.


Method Summary
 Iterator<S> iterator()
          
static
<S> ServiceLoader<S>
load(Class<S> service)
          Creates a new service loader for the given service type, using the current thread's context class loader.
static
<S> ServiceLoader<S>
load(Class<S> service, ClassLoader classLoader)
          Creates a new service loader for the given service type and class loader.
static
<S> ServiceLoader<S>
loadInstalled(Class<S> service)
          Creates a new service loader for the given service type, using the extension class loader.
 void reload()
          Clear this loader's provider cache so that all providers will be reloaded.
 String toString()
          
 Iterator<Class<? extends S>> typesIterator()
          Returns an iterator over a set of elements of type Class<? extends S>.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

load

public static <S> ServiceLoader<S> load(Class<S> service)
Creates a new service loader for the given service type, using the current thread's context class loader.

Type Parameters:
S - The type of the service to be loaded by this loader.
Parameters:
service - The class or interface representing the service being loaded.
Returns:
A new service loader.

load

public static <S> ServiceLoader<S> load(Class<S> service,
                                        ClassLoader classLoader)
Creates a new service loader for the given service type and class loader.

Type Parameters:
S - The type of the service to be loaded by this loader.
Parameters:
service - The class or interface representing the service being loaded.
classLoader - The class loader used to locate, load, and instantiate providers.
Returns:
A new service loader.

loadInstalled

public static <S> ServiceLoader<S> loadInstalled(Class<S> service)
Creates a new service loader for the given service type, using the extension class loader.

Type Parameters:
S - The type of the service to be loaded by this loader.
Parameters:
service - The class or interface representing the service being loaded.
Returns:
A new service loader.

reload

public void reload()
Clear this loader's provider cache so that all providers will be reloaded.


iterator

public Iterator<S> iterator()

Specified by:
iterator in interface Iterable<S>

typesIterator

public Iterator<Class<? extends S>> typesIterator()
Returns an iterator over a set of elements of type Class<? extends S>.

Returns:
an iterator over a set of elements of type Class<? extends S>.
Since:
1.0.1

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2010-2011 99 Software Foundation. All Rights Reserved.