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

Package class diagram package ConfigurationKeyHelper
java.lang.Object
  extended by de.smartics.properties.api.config.domain.key.ConfigurationKeyHelper
All Implemented Interfaces:
Serializable

public final class ConfigurationKeyHelper
     
     
extends Object
implements Serializable

Helper to construct configuration keys by analyzing the runtime environment.

See Also:
Serialized Form

Field Summary
static String SYSTEM_PROPERTY_ENVIRONMENT_NAME
          The name of the system property that stores the name of the environment.
static String SYSTEM_PROPERTY_ENVIRONMENT_NODE
          The name of the system property that stores the node name of the environment.
 
Constructor Summary
ConfigurationKeyHelper()
          Convenience constructor preferring manifest information from EARs.
ConfigurationKeyHelper(boolean preferEarManifest)
          Default constructor.
 
Method Summary
 ConfigurationKey load(Class<?> locator)
          Loads the application identifier from the manifest file pointed at by the given locator class.
 ConfigurationKey load(EnvironmentId environmentId, Class<?> locator)
          Loads the application identifier from the manifest file pointed at by the given locator class.
 ConfigurationKey load(String environmentName, Class<?> locator)
          Loads the application identifier from the manifest file pointed at by the given locator class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SYSTEM_PROPERTY_ENVIRONMENT_NAME

public static final String SYSTEM_PROPERTY_ENVIRONMENT_NAME
The name of the system property that stores the name of the environment.

The value of this constant is "properties.environment.name".

Constant Field Value:
"properties.environment.name"

SYSTEM_PROPERTY_ENVIRONMENT_NODE

public static final String SYSTEM_PROPERTY_ENVIRONMENT_NODE
The name of the system property that stores the node name of the environment.

The value of this constant is "properties.environment.node".

Constant Field Value:
"properties.environment.node"
Constructor Detail

ConfigurationKeyHelper

public ConfigurationKeyHelper()
Convenience constructor preferring manifest information from EARs.


ConfigurationKeyHelper

public ConfigurationKeyHelper(boolean preferEarManifest)
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.
Method Detail

load

public ConfigurationKey load(Class<?> locator)
                      throws IllegalStateException
Loads the application identifier from the manifest file pointed at by the given locator 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.
See Also:
load(EnvironmentId, Class)

load

public ConfigurationKey load(String environmentName,
                             Class<?> locator)
                      throws IllegalStateException
Loads the application identifier from the manifest file pointed at by the given locator class.

Parameters:
environmentName - the name of the environment of use. May be null if the value of the system property SYSTEM_PROPERTY_ENVIRONMENT_NAME should be used (along with the node name defined by SYSTEM_PROPERTY_ENVIRONMENT_NODE). If not specified, the name of the host of this runtime is determined.
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.
See Also:
load(EnvironmentId, Class)

load

public ConfigurationKey load(EnvironmentId environmentId,
                             Class<?> locator)
                      throws IllegalStateException
Loads the application identifier from the manifest file pointed at by the given locator class.

Parameters:
environmentId - the environment part of the configuration key to construct.
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.
See Also:
load(Class), load(String, Class)


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