1 /* ***************************************************************************
2 * Copyright (c) 2008 Brabenetz Harald, Austria.
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 *****************************************************************************/
17 package org.settings4j;
18
19 /**
20 * Holder for a single {@link Settings4jInstance}.
21 *
22 * @author Harald.Brabenetz
23 */
24 public interface Settings4jRepository {
25
26 /**
27 * Retrieve the appropriate {@link Settings4j} instance.
28 *
29 * @return the appropriate {@link Settings4jInstance}
30 */
31 Settings4jInstance getSettings();
32
33 /**
34 * Retrieve the appropriate {@link Settings4j} instance or create it with the give factory if doesn'r already exist.
35 *
36 * @param factory The factory to create a {@link Settings4jInstance}.
37 * @return the appropriate {@link Settings4jInstance}
38 */
39 Settings4jInstance getSettings(Settings4jFactory factory);
40
41 /**
42 * Return the Connector Count.<br />
43 * If the connector count is 0. the Settings will be reinitialized with the default-fallback-config in
44 * {@link org.settings4j.settings.SettingsManager#getSettings()}
45 *
46 * @return The Connector Count.
47 */
48 int getConnectorCount();
49
50 /**
51 * <p>
52 * Remove the Settings, Connectors and other Objects from the Repository.
53 * <p>
54 * Make it ready to fill it with a new Configuration.
55 * <p>
56 * Example (maybe in an init()-Method of your Application):
57 *
58 * <pre>
59 * // clear Settings from "settings4j.xml"
60 * SettingsRepository settingsRepository = SettingsManager.getSettingsRepository();
61 * settingsRepository.resetConfiguration();
62 *
63 * // read XML Custome to configure the repository
64 * URL url = ClasspathContentResolver.getResource("customizedSettings4j.xml");
65 * DOMConfigurator domConfigurator = new DOMConfigurator(settingsRepository);
66 * domConfigurator.doConfigure(url);
67 * </pre>
68 */
69 void resetConfiguration();
70 }