All Downloads are FREE. Search and download functionalities are using the official Maven repository.

group.rxcloud.capa.spi.config.CapaSpiProperties Maven / Gradle / Ivy

There is a newer version: 1.11.13.2.RELEASE
Show newest version
package group.rxcloud.capa.spi.config;

import group.rxcloud.capa.infrastructure.config.CapaProperties;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Properties;

/**
 * The Capa SPI environment.
 */
public abstract class CapaSpiProperties {

    /**
     * Gets default options loader.
     *
     * @return the default options loader
     */
    public static CapaSpiOptionsLoader getSpiOptionsLoader() {
        // load spi capa http impl
        try {
            Properties properties = CapaProperties.COMPONENT_PROPERTIES_SUPPLIER.get();
            String classPath = properties.getProperty(CapaSpiOptionsLoader.class.getName());
            Class aClass = (Class) Class.forName(classPath);
            Constructor constructor = aClass.getConstructor();
            Object newInstance = constructor.newInstance();
            return (CapaSpiOptionsLoader) newInstance;
        } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) {
            throw new IllegalArgumentException("No CapaSpiOptionsLoader implement supported.");
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy