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.resource;
17  
18  import java.util.LinkedHashMap;
19  import java.util.Map;
20  
21  import javax.annotation.concurrent.ThreadSafe;
22  
23  import de.smartics.properties.api.config.ds.DataSourceConfiguration;
24  import de.smartics.properties.impl.config.ds.AutodetectDataSourceConfigurationPropertiesFactory;
25  import de.smartics.properties.resource.domain.ArtifactId;
26  import de.smartics.properties.resource.domain.ClassPathEnvironment;
27  
28  /**
29   * Factory to create instances of
30   * {@link de.smartics.properties.api.config.domain.ConfigurationPropertiesManagement}
31   * being based on a delegate passed to it.
32   */
33  @ThreadSafe
34  public class AutodetectDataSourceResourceConfigurationPropertiesFactory extends
35      AutodetectDataSourceConfigurationPropertiesFactory
36  {
37    // ********************************* Fields *********************************
38  
39    // --- constants ------------------------------------------------------------
40  
41    /**
42     * The class version identifier.
43     */
44    private static final long serialVersionUID = 1L;
45  
46    // --- members --------------------------------------------------------------
47  
48    /**
49     * The list of artifact that reference all resources to access to read
50     * property declarations and definitions.
51     *
52     * @serial
53     */
54    private final Map<ArtifactId, ClassPathEnvironment> artifactIds =
55        new LinkedHashMap<ArtifactId, ClassPathEnvironment>();
56  
57    // ****************************** Initializer *******************************
58  
59    // ****************************** Constructors ******************************
60  
61    /**
62     * Default constructor.
63     */
64    public AutodetectDataSourceResourceConfigurationPropertiesFactory()
65    {
66      getFactoryConfiguration().setAddDefaultRootLocations(false);
67    }
68  
69    /**
70     * Constructor that enables the configuration to be set.
71     *
72     * @param configuration the configuration to use for this factory.
73     */
74    public AutodetectDataSourceResourceConfigurationPropertiesFactory(
75        final DataSourceConfiguration configuration)
76    {
77      super(configuration);
78    }
79  
80    // ****************************** Inner Classes *****************************
81  
82    // ********************************* Methods ********************************
83  
84    // --- init -----------------------------------------------------------------
85  
86    // --- get&set --------------------------------------------------------------
87  
88    // --- business -------------------------------------------------------------
89  
90    // --- object basics --------------------------------------------------------
91  
92    /**
93     * Returns the string representation of the object.
94     *
95     * @return the string representation of the object.
96     */
97    @Override
98    public String toString()
99    {
100     final StringBuilder buffer = new StringBuilder();
101 
102     buffer.append(super.toString());
103     synchronized (artifactIds)
104     {
105       for (final ArtifactId artifactId : artifactIds.keySet())
106       {
107         buffer.append(artifactId).append(' ');
108       }
109     }
110 
111     return buffer.toString();
112   }
113 }