de.smartics.properties.spi.config.support
Class ClassPathLoader<T extends ConfigurationPropertiesManagement>

Package class diagram package ClassPathLoader
java.lang.Object
  extended by de.smartics.properties.spi.config.support.ClassPathLoader<T>
Type Parameters:
T - the concrete type of the returned configuration properties.

@NotThreadSafe
public final class ClassPathLoader<T extends ConfigurationPropertiesManagement>
     
     
extends Object

Loads property descriptors and properties files found on the class path.


Constructor Summary
ClassPathLoader(FactoryCache<T> factoryCache, boolean lenient, boolean skipPropertyLoading, PropertyValueSecurity decrypter)
          Default constructor.
 
Method Summary
 void addDefaultRootUrls()
          Adds all class path root URLs provided by the context class loader of the current thread.
 void addRootProperties(List<PropertyProvider> rootPropertyProviders)
          Adds the given property providers as additional property definitions.
 void addRootUrl(Class<?> exemplar)
          Adds the root URL of the given exemplar to the set of class path root URLs.
 void addRootUrl(ClassLoader classLoader)
          Adds the relevant root URL of the given classLoader to the set of class path root URLs.
 void addRootUrl(URL rootUrl)
          Adds the given URL to the set of class path root URLs.
 void addRootUrls(List<URL> rootLocations)
          Adds the given root URLs to the collection of class path roots managed by this class loader.
 ConfigurationRepositoryManagement load()
          Loads the configuration properties instance from information found on the class path.
 String toString()
          Returns the string representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClassPathLoader

public ClassPathLoader(FactoryCache<T> factoryCache,
                       boolean lenient,
                       boolean skipPropertyLoading,
                       PropertyValueSecurity decrypter)
                throws de.smartics.util.lang.NullArgumentException
Default constructor.

Parameters:
factoryCache - the cache to create and cache new configuration properties instances.
lenient - the flag indicates that configuration problems are not signaled by exceptions.
skipPropertyLoading - the flag indicates that loading properties from the class path is to be skipped.
decrypter - the helper to decrypt secured property values.
Throws:
de.smartics.util.lang.NullArgumentException - if factoryCache or decrypter is null.
Method Detail

addRootUrl

public void addRootUrl(URL rootUrl)
                throws de.smartics.util.lang.NullArgumentException
Adds the given URL to the set of class path root URLs.

Parameters:
rootUrl - the URL to add as a class path root URL.
Throws:
de.smartics.util.lang.NullArgumentException - if rootUrl is null.

addRootUrl

public void addRootUrl(Class<?> exemplar)
                throws de.smartics.util.lang.NullArgumentException
Adds the root URL of the given exemplar to the set of class path root URLs.

Parameters:
exemplar - a sample class to derive the root URL from.
Throws:
de.smartics.util.lang.NullArgumentException - if exemplar is null.

addRootUrl

public void addRootUrl(ClassLoader classLoader)
                throws de.smartics.util.lang.NullArgumentException
Adds the relevant root URL of the given classLoader to the set of class path root URLs.

Only archives that contain the "META-INF/smartics-properties" are relevant and therefore added.

Parameters:
classLoader - the class loader whose class roots are added.
Throws:
de.smartics.util.lang.NullArgumentException - if exemplar is null.

load

public ConfigurationRepositoryManagement load()
                                       throws CompoundConfigurationException
Loads the configuration properties instance from information found on the class path.

Returns:
the loaded configuration properties instance.
Throws:
CompoundConfigurationException - if loading encountered problems.

addDefaultRootUrls

public void addDefaultRootUrls()
Adds all class path root URLs provided by the context class loader of the current thread.


addRootUrls

public void addRootUrls(List<URL> rootLocations)
Adds the given root URLs to the collection of class path roots managed by this class loader. The root locations are used for searching property declarations and property definitions.

Parameters:
rootLocations - the additional root locations to search for property declarations and definitions.

addRootProperties

public void addRootProperties(List<PropertyProvider> rootPropertyProviders)
Adds the given property providers as additional property definitions. Values provided by these instances are taken into account similar to any property definitions found on the class path.

Property values provided by these providers take precedence over any property values found on the class path.

Parameters:
rootPropertyProviders - the additional property definitions to add.

toString

public String toString()
Returns the string representation of the object.

Overrides:
toString in class Object
Returns:
the string representation of the object.


Copyright © 2012-2013 Kronseder & Reiner GmbH - smartics. All Rights Reserved.