com.aragost.javahg.internals
Class ServiceLoader

java.lang.Object
  extended by com.aragost.javahg.internals.ServiceLoader

public final class ServiceLoader
extends Object

The ServiceLoader searches for Service implementations in META-INF/services. This class emulates the behavior of ServiceLoader introduced in Java 1.6.

Author:
Sebastian Sdorra

Constructor Summary
ServiceLoader()
           
 
Method Summary
static
<S> S
loadService(Class<S> serviceClass)
          This method is shorthand for loadService(java.lang.ClassLoader, java.lang.Class) with the context classloader.
static
<S> S
loadService(ClassLoader classLoader, Class<S> serviceClass)
          Returns a implementation of the given service or null if no service could be found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceLoader

public ServiceLoader()
Method Detail

loadService

public static <S> S loadService(Class<S> serviceClass)
                     throws ServiceException
This method is shorthand for loadService(java.lang.ClassLoader, java.lang.Class) with the context classloader.

Parameters:
serviceClass - classloader used to load the resource from META-INF/services
Returns:
service implementation or null
Throws:
ServiceException

loadService

public static <S> S loadService(ClassLoader classLoader,
                                Class<S> serviceClass)
                     throws ServiceException
Returns a implementation of the given service or null if no service could be found.

Parameters:
classLoader - classloader used to load the resource from META-INF/services
serviceClass - service class to load
Returns:
service implementation or null
Throws:
ServiceException


Copyright © 2011-2013 aragost Trifork ag. All Rights Reserved.