1 /* 2 * #%L 3 * settings4j 4 * =============================================================== 5 * Copyright (C) 2008 - 2015 Brabenetz Harald, Austria 6 * =============================================================== 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 * #L% 19 */ 20 package org.settings4j; 21 22 /** 23 * Holder for a single {@link Settings4jInstance}. 24 * 25 * @author Harald.Brabenetz 26 */ 27 public interface Settings4jRepository { 28 29 /** 30 * Retrieve the appropriate {@link Settings4j} instance. 31 * 32 * @return the appropriate {@link Settings4jInstance} 33 */ 34 Settings4jInstance getSettings(); 35 36 /** 37 * Retrieve the appropriate {@link Settings4j} instance or create it with the give factory if doesn'r already exist. 38 * 39 * @param factory The factory to create a {@link Settings4jInstance}. 40 * @return the appropriate {@link Settings4jInstance} 41 */ 42 Settings4jInstance getSettings(Settings4jFactory factory); 43 44 /** 45 * Return the Connector Count.<br> 46 * If the connector count is 0. the Settings will be reinitialized with the default-fallback-config in 47 * {@link org.settings4j.settings.SettingsManager#getSettings()} 48 * 49 * @return The Connector Count. 50 */ 51 int getConnectorCount(); 52 53 /** 54 * Remove the Settings, Connectors and other Objects from the Repository. 55 * <p> 56 * Make it ready to fill it with a new Configuration. 57 * </p> 58 * <p> 59 * Example (maybe in an init()-Method of your Application): 60 * </p> 61 * 62 * <pre> 63 * // clear Settings from "settings4j.xml" 64 * SettingsRepository settingsRepository = SettingsManager.getSettingsRepository(); 65 * settingsRepository.resetConfiguration(); 66 * 67 * // read XML Custome to configure the repository 68 * URL url = ClasspathContentResolver.getResource("customizedSettings4j.xml"); 69 * DOMConfigurator domConfigurator = new DOMConfigurator(settingsRepository); 70 * domConfigurator.doConfigure(url); 71 * </pre> 72 */ 73 void resetConfiguration(); 74 }