de.smartics.properties.api.config.domain.key
Class ApplicationIdLoader

Package class diagram package ApplicationIdLoader
java.lang.Object
  extended by de.smartics.properties.api.config.domain.key.ApplicationIdLoader

@ThreadSafe
public final class ApplicationIdLoader
     
     
extends Object

Loads the application identifier from the Manifest file.


Constructor Summary
ApplicationIdLoader()
          Convenience constructor preferring manifest information from EARs and no caching.
ApplicationIdLoader(boolean preferEarManifest)
          Convenience constructor preferring no caching.
ApplicationIdLoader(boolean preferEarManifest, boolean useCache)
          Default constructor.
 
Method Summary
static ApplicationIdLoader createCachedJarLoader()
          Returns a caching loader that reads the Manifest file from the JAR that actually contains the resource.
 ApplicationId load()
          Loads the application identifier from the manifest file pointed at by the context class loader.
 ApplicationId load(Class<?> locator)
          Loads the application identifier from the manifest file pointed at from the given class.
 ApplicationId load(ClassLoader classLoader)
          Loads the application identifier from the manifest file pointed at from the given class loader.
 ApplicationId load(URL rootUrl)
          Loads the manifest information as application ID from the given root URL.
 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

ApplicationIdLoader

public ApplicationIdLoader()
Convenience constructor preferring manifest information from EARs and no caching.


ApplicationIdLoader

public ApplicationIdLoader(boolean preferEarManifest)
Convenience constructor preferring no caching.

Parameters:
preferEarManifest - the flag to signal that the manifest of a EAR file (with the extension (with the extension ear) is preferred if present.

ApplicationIdLoader

public ApplicationIdLoader(boolean preferEarManifest,
                           boolean useCache)
Default constructor.

Parameters:
preferEarManifest - the flag to signal that the manifest of a EAR file (with the extension (with the extension ear) is preferred if present.
useCache - set to true if all loaded application IDs should be cached, false otherwise.
Method Detail

createCachedJarLoader

public static ApplicationIdLoader createCachedJarLoader()
Returns a caching loader that reads the Manifest file from the JAR that actually contains the resource.

Returns:
the loader instance.
See Also:
ApplicationIdLoader(boolean, boolean)

load

public ApplicationId load()
                   throws IllegalStateException
Loads the application identifier from the manifest file pointed at by the context class loader.

Returns:
the application identifier.
Throws:
IllegalStateException - if the application identifier cannot be read from the manifest.

load

public ApplicationId load(Class<?> locator)
                   throws IllegalStateException
Loads the application identifier from the manifest file pointed at from the given class.

Parameters:
locator - the class to locate the manifest file to load. It is the manifest file of the archive this class is part of.
Returns:
the application identifier.
Throws:
IllegalStateException - if the application identifier cannot be read from the manifest.

load

public ApplicationId load(URL rootUrl)
Loads the manifest information as application ID from the given root URL.

Parameters:
rootUrl - the URL to a class path root. The JarFile.MANIFEST_NAME will be appended to locate the manifest file.
Returns:
the application ID as read from the manifest file found in the rootUrl.

load

public ApplicationId load(ClassLoader classLoader)
                   throws IllegalStateException
Loads the application identifier from the manifest file pointed at from the given class loader.

Parameters:
classLoader - the class loader to load the manifest file.
Returns:
the application identifier.
Throws:
IllegalStateException - if the application identifier cannot be read from the manifest.

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.