/** * Find implementation of SPI. * * @param <T> Service Provider Interface type * * @param spiClass Service Provider Interface Class. * * @param properties Used to determine name of SPI implementation, * and passed to implementation.init() method if * implementation implements Service interface. * * @return Instance of a class implementing the SPI. * * @exception DiscoveryException Thrown if the name of a class implementing * the SPI cannot be found, if the class cannot be loaded and * instantiated, or if the resulting class does not implement * (or extend) the SPI. */ public static <T> T find(Class<T> spiClass, Properties properties) throws DiscoveryException { return find(null, new SPInterface<T>(spiClass), new PropertiesHolder(properties), (DefaultClassHolder<T>) null); }
/** * Returns the {@code Properties} instance, loaded if necessary from {@code propertiesFileName}. * * @param spi Optional SPI (may be null). * If provided, an attempt is made to load the * property file as-per Class.getResource(). * * @param loaders Used only if properties need to be loaded. * * @return The {@code Properties}, loaded if necessary. */ public Properties getProperties(SPInterface<?> spi, ClassLoaders loaders) { if (properties == null) { properties = ResourceUtils.loadProperties(spi.getSPClass(), getPropertiesFileName(), loaders); } return properties; }
: properties.getProperties(spi, loaders);
private static synchronized WSAG4JConfigurationEnvironment getEnvironment() { SimpleLog.setLevel( SimpleLog.LOG_LEVEL_INFO ); if ( instance == null ) { SPInterface mssConfigSP = getWSAG4JSPI(); PropertiesHolder pHolder = new PropertiesHolder( WSAG4JEnvironment.DEFAULT_CONFIGURATION_FILE ); DefaultClassHolder cHolder = new DefaultClassHolder( WSAG4JEnvironment.class.getName() ); instance = (WSAG4JConfigurationEnvironment) DiscoverSingleton.find( null, mssConfigSP, pHolder, cHolder ); } return instance; }
/** * Find class implementing SPI. * * @param <T> The SPI type * @param <S> Any class extending T * @param spiClass Service Provider Interface Class. * @param properties Used to determine name of SPI implementation. * @return Class implementing the SPI. * @exception DiscoveryException Thrown if the name of a class implementing * the SPI cannot be found, if the class cannot be loaded, or if * the resulting class does not implement (or extend) the SPI. */ public <T, S extends T> Class<S> find(Class<T> spiClass, Properties properties) throws DiscoveryException { return find(getClassLoaders(spiClass), new SPInterface<T>(spiClass), new PropertiesHolder(properties), (DefaultClassHolder<T>) null); }
/** * Find implementation of SPI. * * @param <T> Service Provider Interface type * * @param spiClass Service Provider Interface Class. * * @param properties Used to determine name of SPI implementation, * and passed to implementation.init() method if * implementation implements Service interface. * * @param defaultImpl Default implementation. * * @return Instance of a class implementing the SPI. * * @exception DiscoveryException Thrown if the name of a class implementing * the SPI cannot be found, if the class cannot be loaded and * instantiated, or if the resulting class does not implement * (or extend) the SPI. */ public static <T> T find(Class<T> spiClass, Properties properties, String defaultImpl) throws DiscoveryException { return find(null, new SPInterface<T>(spiClass), new PropertiesHolder(properties), new DefaultClassHolder<T>(defaultImpl)); }
/** * Create new instance of class implementing SPI. * * @param <T> The SPI type * @param spiClass Service Provider Interface Class. * @param properties Used to determine name of SPI implementation, * and passed to implementation.init() method if * implementation implements Service interface. * @return Instance of a class implementing the SPI. * @exception DiscoveryException Thrown if the name of a class implementing * the SPI cannot be found, if the class cannot be loaded and * instantiated, or if the resulting class does not implement * (or extend) the SPI. * @throws InstantiationException see {@link Class#newInstance()} * @throws IllegalAccessException see {@link Class#newInstance()} * @throws NoSuchMethodException see {@link Class#newInstance()} * @throws InvocationTargetException see {@link Class#newInstance()} */ public <T> T newInstance(Class<T> spiClass, Properties properties) throws DiscoveryException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { return newInstance(getClassLoaders(spiClass), new SPInterface<T>(spiClass), new PropertiesHolder(properties), (DefaultClassHolder<T>) null); }
/** * Find implementation of SPI. * * @param <T> Service Provider Interface type * * @param spiClass Service Provider Interface Class. * * @param propertiesFileName Used to determine name of SPI implementation, * and passed to implementation.init() method if * implementation implements Service interface. * * @param defaultImpl Default implementation. * * @return Instance of a class implementing the SPI. * * @exception DiscoveryException Thrown if the name of a class implementing * the SPI cannot be found, if the class cannot be loaded and * instantiated, or if the resulting class does not implement * (or extend) the SPI. */ public static <T> T find(Class<T> spiClass, String propertiesFileName, String defaultImpl) throws DiscoveryException { return find(null, new SPInterface<T>(spiClass), new PropertiesHolder(propertiesFileName), new DefaultClassHolder<T>(defaultImpl)); }
/** * Find class implementing SPI. * * @param <T> The SPI type * @param <S> Any class extending T * @param spiClass Service Provider Interface Class. * @param properties Used to determine name of SPI implementation,. * @param defaultImpl Default implementation class. * @return Class implementing the SPI. * @exception DiscoveryException Thrown if the name of a class implementing * the SPI cannot be found, if the class cannot be loaded, or if * the resulting class does not implement (or extend) the SPI. */ public <T, S extends T> Class<S> find(Class<T> spiClass, Properties properties, String defaultImpl) throws DiscoveryException { return find(getClassLoaders(spiClass), new SPInterface<T>(spiClass), new PropertiesHolder(properties), new DefaultClassHolder<T>(defaultImpl)); }
/** * Find class implementing SPI. * * @param <T> The SPI type * @param <S> Any class extending T * @param spiClass Service Provider Interface Class. * @param propertiesFileName Used to determine name of SPI implementation,. * @param defaultImpl Default implementation class. * @return Class implementing the SPI. * @exception DiscoveryException Thrown if the name of a class implementing * the SPI cannot be found, if the class cannot be loaded, or if * the resulting class does not implement (or extend) the SPI. */ public <T, S extends T> Class<S> find(Class<T> spiClass, String propertiesFileName, String defaultImpl) throws DiscoveryException { return find(getClassLoaders(spiClass), new SPInterface<T>(spiClass), new PropertiesHolder(propertiesFileName), new DefaultClassHolder<T>(defaultImpl)); }
/** * Create new instance of class implementing SPI. * * @param <T> The SPI type * @param spiClass Service Provider Interface Class. * @param properties Used to determine name of SPI implementation, * and passed to implementation.init() method if * implementation implements Service interface. * @param defaultImpl Default implementation. * @return Instance of a class implementing the SPI. * @exception DiscoveryException Thrown if the name of a class implementing * the SPI cannot be found, if the class cannot be loaded and * instantiated, or if the resulting class does not implement * (or extend) the SPI. * @throws InstantiationException see {@link Class#newInstance()} * @throws IllegalAccessException see {@link Class#newInstance()} * @throws NoSuchMethodException see {@link Class#newInstance()} * @throws InvocationTargetException see {@link Class#newInstance()} */ public <T> T newInstance(Class<T> spiClass, Properties properties, String defaultImpl) throws DiscoveryException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { return newInstance(getClassLoaders(spiClass), new SPInterface<T>(spiClass), new PropertiesHolder(properties), new DefaultClassHolder<T>(defaultImpl)); }
/** * Create new instance of class implementing SPI. * * @param <T> The SPI type * @param spiClass Service Provider Interface Class. * @param propertiesFileName Used to determine name of SPI implementation, * and passed to implementation.init() method if * implementation implements Service interface. * @param defaultImpl Default implementation. * @return Instance of a class implementing the SPI. * @exception DiscoveryException Thrown if the name of a class implementing * the SPI cannot be found, if the class cannot be loaded and * instantiated, or if the resulting class does not implement * (or extend) the SPI. * @throws InstantiationException see {@link Class#newInstance()} * @throws IllegalAccessException see {@link Class#newInstance()} * @throws NoSuchMethodException see {@link Class#newInstance()} * @throws InvocationTargetException see {@link Class#newInstance()} */ public <T> T newInstance(Class<T> spiClass, String propertiesFileName, String defaultImpl) throws DiscoveryException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { return newInstance(getClassLoaders(spiClass), new SPInterface<T>(spiClass), new PropertiesHolder(propertiesFileName), new DefaultClassHolder<T>(defaultImpl)); }