org.ops4j.spi
Class SafeServiceLoader

java.lang.Object
  extended by org.ops4j.spi.SafeServiceLoader

public class SafeServiceLoader
extends Object

Loads service provider instances from META-INF/services using a given class loader, avoiding the system class loader used by java.util.ServiceLoader.

Author:
Harald Wellmann

Constructor Summary
SafeServiceLoader(ClassLoader classLoader)
          Constructs a service loader using the given class loader.
 
Method Summary
<T> List<T>
load(String serviceType)
          Returns a list of service instances for the given a service type, finding all META-INF/services resources for the given type and loading and instantiating all classes listed in these resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SafeServiceLoader

public SafeServiceLoader(ClassLoader classLoader)
Constructs a service loader using the given class loader.

Parameters:
classLoader -
Method Detail

load

public <T> List<T> load(String serviceType)
Returns a list of service instances for the given a service type, finding all META-INF/services resources for the given type and loading and instantiating all classes listed in these resources.

A class that cannot be loaded by the class loader passed to the constructor of this class is silently ignored.

Parameters:
serviceType - fully qualified service class name
Returns:
list of services matching the given service type
Throws:
NoServiceProviderException - if a resource cannot be read or if a loaded class cannot be instantiated


Copyright © 2006-2012 OPS4J - Open Participation Software for Java. All Rights Reserved.