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.rtaware;
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, application, tenant, and user IDs.
28   */
29  public final class TenantUserConfigurationKeyContext 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 TenantUserConfigurationKeyFactory factory =
42        new TenantUserConfigurationKeyFactory();
43  
44    /**
45     * Provides exploding a configuration key to its defaulting configuration
46     * keys.
47     */
48    private final TenantUserKeyListBuilder builder =
49        new TenantUserKeyListBuilder();
50  
51    /**
52     * Provides parsing the <code>definition.xml</code> file for properties.
53     */
54    private final TenantUserDefinitionConfigParser parser =
55        new TenantUserDefinitionConfigParser();
56  
57    /**
58     * The default, contextless helper to deal with definition keys.
59     */
60    private final TenantUserDefinitionKeyHelper defaultHelper =
61        new TenantUserDefinitionKeyHelper();
62  
63    // ****************************** Initializer *******************************
64  
65    // ****************************** Constructors ******************************
66  
67    /**
68     * Default constructor.
69     */
70    public TenantUserConfigurationKeyContext()
71    {
72    }
73  
74    // ****************************** Inner Classes *****************************
75  
76    // ********************************* Methods ********************************
77  
78    // --- init -----------------------------------------------------------------
79  
80    // --- get&set --------------------------------------------------------------
81  
82    // --- business -------------------------------------------------------------
83  
84    @Override
85    public ConfigurationKeyFactory<?> configurationKeyFactory()
86    {
87      return factory;
88    }
89  
90    @Override
91    public KeyListBuilder keyListBuilder()
92    {
93      return builder;
94    }
95  
96    @Override
97    public DefinitionConfigParser<?> definitionConfigParser()
98    {
99      return parser;
100   }
101 
102   @Override
103   public DefinitionKeyHelper definitionKeyHelper()
104   {
105     return defaultHelper;
106   }
107 
108   @Override
109   public DefinitionKeyHelper definitionKeyHelper(
110       final PropertiesDefinitionContext definitionContext)
111   {
112     return new TenantUserDefinitionKeyHelper(
113         (TenantUserPropertiesDefinitionContext) definitionContext);
114   }
115 
116   @Override
117   public ConfigurationKeyHelper configurationKeyHelper(
118       final boolean preferEarManifest)
119   {
120     final TenantUserConfigurationKeyHelper configurationKeyHelper =
121         new TenantUserConfigurationKeyHelper(preferEarManifest);
122     return configurationKeyHelper;
123   }
124 
125   // --- object basics --------------------------------------------------------
126 
127 }