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.resource.maven.repository;
17  
18  import de.smartics.properties.api.config.app.ConfigurationPropertiesFactory;
19  import de.smartics.properties.api.config.app.ConfigurationPropertiesFactoryFactory;
20  import de.smartics.properties.api.config.domain.ConfigurationPropertiesManagement;
21  import de.smartics.properties.api.config.domain.key.ConfigurationKey;
22  import de.smartics.properties.impl.config.properties.PropertiesConfigurationPropertiesFactory;
23  import de.smartics.properties.spi.config.domain.key.ConfigurationKeyContextManager;
24  
25  /**
26   * The resource repository properties.
27   */
28  final class ResourceRepositoryPropertiesSingleton
29  {
30    // ********************************* Fields *********************************
31  
32    // --- constants ------------------------------------------------------------
33  
34    /**
35     * The resource repository properties.
36     */
37    private static ResourceRepositoryProperties INSTANCE;
38  
39    // --- members --------------------------------------------------------------
40  
41    // ****************************** Initializer *******************************
42  
43    private static void initialize()
44    {
45      final ConfigurationPropertiesFactory factory =
46          ConfigurationPropertiesFactoryFactory
47              .createFactory(PropertiesConfigurationPropertiesFactory.class);
48  
49      final ConfigurationKey<?> key =
50          ConfigurationKeyContextManager.INSTANCE.context()
51              .configurationKeyFactory().createDefaultKey();
52      final ConfigurationPropertiesManagement propertiesConfiguration =
53          factory.createManagement(key);
54      INSTANCE =
55          propertiesConfiguration
56              .getProperties(ResourceRepositoryProperties.class);
57    }
58  
59    // ****************************** Constructors ******************************
60  
61    private ResourceRepositoryPropertiesSingleton()
62    {
63    }
64  
65    // ****************************** Inner Classes *****************************
66  
67    // ********************************* Methods ********************************
68  
69    // --- init -----------------------------------------------------------------
70  
71    // --- get&set --------------------------------------------------------------
72  
73    // --- business -------------------------------------------------------------
74  
75    public static ResourceRepositoryProperties instance()
76    {
77      if (INSTANCE == null)
78      {
79        initialize();
80      }
81      return INSTANCE;
82    }
83  
84    // --- object basics --------------------------------------------------------
85  
86  }