Lombok - v0.11.2

lombok.core
Class SpiLoadUtil

java.lang.Object
  extended by lombok.core.SpiLoadUtil

public class SpiLoadUtil
extends Object

The java core libraries have a SPI discovery system, but it works only in Java 1.6 and up. For at least Eclipse, lombok actually works in java 1.5, so we've rolled our own SPI discovery system. It is not API compatible with ServiceLoader.

See Also:
ServiceLoader

Method Summary
static Class<? extends Annotation> findAnnotationClass(Class<?> c, Class<?> base)
          This method will find the @{code T} in public class Foo extends BaseType<T>.
static
<C> Iterable<C>
findServices(Class<C> target)
          Returns an iterator of instances that, at least according to the spi discovery file, are implementations of the stated class.
static
<C> Iterable<C>
findServices(Class<C> target, ClassLoader loader)
          Returns an iterator of class objects that, at least according to the spi discovery file, are implementations of the stated class.
static
<T> List<T>
readAllFromIterator(Iterable<T> findServices)
          Method that conveniently turn the Iterables returned by the other methods in this class to a List.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

readAllFromIterator

public static <T> List<T> readAllFromIterator(Iterable<T> findServices)
Method that conveniently turn the Iterables returned by the other methods in this class to a List.

See Also:
findServices(Class), findServices(Class, ClassLoader)

findServices

public static <C> Iterable<C> findServices(Class<C> target)
                                throws IOException
Returns an iterator of instances that, at least according to the spi discovery file, are implementations of the stated class. Like ServiceLoader, each listed class is turned into an instance by calling the public no-args constructor. Convenience method that calls the more elaborate findServices(Class, ClassLoader) method with this Thread's context class loader as ClassLoader.

Parameters:
target - class to find implementations for.
Throws:
IOException

findServices

public static <C> Iterable<C> findServices(Class<C> target,
                                           ClassLoader loader)
                                throws IOException
Returns an iterator of class objects that, at least according to the spi discovery file, are implementations of the stated class. Like ServiceLoader, each listed class is turned into an instance by calling the public no-args constructor.

Parameters:
target - class to find implementations for.
loader - The classloader object to use to both the spi discovery files, as well as the loader to use to make the returned instances.
Throws:
IOException

findAnnotationClass

public static Class<? extends Annotation> findAnnotationClass(Class<?> c,
                                                              Class<?> base)
This method will find the @{code T} in public class Foo extends BaseType<T>. It returns an annotation type because it is used exclusively to figure out which annotations are being handled by lombok.eclipse.EclipseAnnotationHandler and lombok.javac.JavacAnnotationHandler.


Lombok - v0.11.2

Copyright © 2011 The Project Lombok Authors, licensed under the MIT licence.