de.smartics.properties.impl.config.domain.key.rtaware
Class TenantUserDefinitionKeyHelper

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

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

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

See Also:
Serialized Form

Constructor Summary
TenantUserDefinitionKeyHelper()
          Convenience constructor using the default TLDs and not registering any environments, nodes or groups.
TenantUserDefinitionKeyHelper(TenantUserPropertiesDefinitionContext 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

TenantUserDefinitionKeyHelper

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


TenantUserDefinitionKeyHelper

public TenantUserDefinitionKeyHelper(TenantUserPropertiesDefinitionContext 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. /'user.'user
  2. /'tenant.'tenant
  3. /environment
  4. /environment
  5. /environment/node
  6. /environment/node/group
  7. /environment/node/group/application
  8. /environment/node/group/application/version
  9. /environment/group
  10. /environment/group/application
  11. /environment/group/application/version
  12. /group
  13. /group/application
  14. /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 AbstractPropertiesDefinitionContext.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.