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

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

Introduction

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

Prototype

@Override
    public Class<? extends S> next() 

Source Link

Usage

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

License:Open Source License

/**
 * Loads the XPackSecurityExtensions from the given class loader
 *//* w  w  w  . jav a2s .  c  om*/
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;
}