Example usage for org.apache.lucene.util SPIClassIterator get

List of usage examples for org.apache.lucene.util SPIClassIterator get

Introduction

In this page you can find the example usage for org.apache.lucene.util SPIClassIterator get.

Prototype

public static <S> SPIClassIterator<S> get(Class<S> clazz, ClassLoader loader) 

Source Link

Document

Creates a new SPI iterator to lookup services of type clazz using the given classloader.

Usage

From source file:org.elasticsearch.xpack.core.security.SecurityExtension.java

License:Open Source License

/**
 * Loads the XPackSecurityExtensions from the given class loader
 *//*from  w  ww.  j a  v a2 s . c o m*/
static List<SecurityExtension> loadExtensions(ClassLoader loader) {
    SPIClassIterator<SecurityExtension> iterator = SPIClassIterator.get(SecurityExtension.class, loader);
    List<SecurityExtension> extensions = new ArrayList<>();
    while (iterator.hasNext()) {
        final Class<? extends SecurityExtension> c = iterator.next();
        try {
            extensions.add(c.getConstructor().newInstance());
        } catch (Exception e) {
            throw new ServiceConfigurationError("failed to load security extension [" + c.getName() + "]", e);
        }
    }
    return extensions;
}