View Javadoc

1   /*
2    * Copyright 2012-2013 smartics, Kronseder & Reiner GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package de.smartics.properties.impl.config.domain.key.envapp;
17  
18  import de.smartics.properties.api.config.domain.key.ConfigurationKeyFactory;
19  import de.smartics.properties.api.config.domain.key.ConfigurationKeyHelper;
20  import de.smartics.properties.api.config.domain.key.KeyListBuilder;
21  import de.smartics.properties.spi.config.definition.DefinitionConfigParser;
22  import de.smartics.properties.spi.config.definition.DefinitionKeyHelper;
23  import de.smartics.properties.spi.config.definition.PropertiesDefinitionContext;
24  import de.smartics.properties.spi.config.domain.key.ConfigurationKeyContext;
25  
26  /**
27   * Implementation that supports environment and application IDs.
28   */
29  public final class EnvAppConfigurationKeyContext implements
30      ConfigurationKeyContext
31  {
32    // ********************************* Fields *********************************
33  
34    // --- constants ------------------------------------------------------------
35  
36    // --- members --------------------------------------------------------------
37  
38    /**
39     * Provides access to the configuration key factory.
40     */
41    private final EnvAppConfigurationKeyFactory factory =
42        new EnvAppConfigurationKeyFactory();
43  
44    /**
45     * Provides exploding a configuration key to its defaulting configuration
46     * keys.
47     */
48    private final EnvAppKeyListBuilder builder = new EnvAppKeyListBuilder();
49  
50    /**
51     * Provides parsing the <code>definition.xml</code> file for properties.
52     */
53    private final EnvAppDefinitionConfigParser parser =
54        new EnvAppDefinitionConfigParser();
55  
56    /**
57     * The default, contextless helper to deal with definition keys.
58     */
59    private final EnvAppDefinitionKeyHelper defaultHelper =
60        new EnvAppDefinitionKeyHelper();
61  
62    // ****************************** Initializer *******************************
63  
64    // ****************************** Constructors ******************************
65  
66    /**
67     * Default constructor.
68     */
69    public EnvAppConfigurationKeyContext()
70    {
71    }
72  
73    // ****************************** Inner Classes *****************************
74  
75    // ********************************* Methods ********************************
76  
77    // --- init -----------------------------------------------------------------
78  
79    // --- get&set --------------------------------------------------------------
80  
81    // --- business -------------------------------------------------------------
82  
83    @Override
84    public ConfigurationKeyFactory<?> configurationKeyFactory()
85    {
86      return factory;
87    }
88  
89    @Override
90    public KeyListBuilder keyListBuilder()
91    {
92      return builder;
93    }
94  
95    @Override
96    public DefinitionConfigParser<?> definitionConfigParser()
97    {
98      return parser;
99    }
100 
101   @Override
102   public DefinitionKeyHelper definitionKeyHelper()
103   {
104     return defaultHelper;
105   }
106 
107   @Override
108   public DefinitionKeyHelper definitionKeyHelper(
109       final PropertiesDefinitionContext definitionContext)
110   {
111     return new EnvAppDefinitionKeyHelper(
112         (EnvAppPropertiesDefinitionContext) definitionContext);
113   }
114 
115   @Override
116   public ConfigurationKeyHelper configurationKeyHelper(
117       final boolean preferEarManifest)
118   {
119     final EnvAppConfigurationKeyHelper configurationKeyHelper =
120         new EnvAppConfigurationKeyHelper(preferEarManifest);
121     return configurationKeyHelper;
122   }
123 
124   // --- object basics --------------------------------------------------------
125 
126 }