de.smartics.properties.impl.config.domain.key.envapp
Class EnvAppDefinitionKeyHelper

Package class diagram package EnvAppDefinitionKeyHelper
java.lang.Object
  extended by de.smartics.properties.impl.config.domain.key.envapp.EnvAppDefinitionKeyHelper
All Implemented Interfaces:
DefinitionKeyHelper, Serializable

@ThreadSafe
public final class EnvAppDefinitionKeyHelper
     
     
extends Object
implements Serializable, DefinitionKeyHelper

Derives a ConfigurationKey from a path found in a definition file.

See Also:
Serialized Form

Constructor Summary
EnvAppDefinitionKeyHelper()
          Convenience constructor using the default TLDs and not registering any environments, nodes or groups.
EnvAppDefinitionKeyHelper(EnvAppPropertiesDefinitionContext context)
          Default constructor.
 
Method Summary
 ConfigurationKey<?> parse(String pathWithFile)
          Parses the given path to create a configuration key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnvAppDefinitionKeyHelper

public EnvAppDefinitionKeyHelper()
Convenience constructor using the default TLDs and not registering any environments, nodes or groups.


EnvAppDefinitionKeyHelper

public EnvAppDefinitionKeyHelper(EnvAppPropertiesDefinitionContext context)
                          throws NullPointerException
Default constructor.

Parameters:
context - the context to evaluate the configuration keys from properties file paths.
Throws:
NullPointerException - if context is null.
Method Detail

parse

public ConfigurationKey<?> parse(String pathWithFile)
                          throws IllegalArgumentException
Parses the given path to create a configuration key.

The expected syntax is as follows:

  1. /environment
  2. /environment/node
  3. /environment/node/group
  4. /environment/node/group/application
  5. /environment/node/group/application/version
  6. /environment/group
  7. /environment/group/application
  8. /environment/group/application/version
  9. /group
  10. /group/application
  11. /group/application/version

A file ending with properties following the path will be chopped.

The parser has to determine whether a part of the path is a environment, a node or a group. Since a node is always prefixed by an environment only the following two cases have to be dealt with:

  1. environment vs. group
  2. node vs. group

groups start with

  1. A TLD as registered by default by TenantUserPropertiesDefinitionContext#DEFAULT_TLDS or explicitly registered with TenantUserPropertiesDefinitionContext
  2. Two letters followed by a dot (.)
  3. Any sequence of characters that is explicitly registered as a group in the definition.xml file

environments and nodes do not start as groups except they are explicitly registered in the definition.xml file.

Specified by:
parse in interface DefinitionKeyHelper
Parameters:
pathWithFile - the path to parse.
Returns:
the configuration key.
Throws:
IllegalArgumentException - if the given path is not valid according to the rules given above.


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