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.api.config.domain; 17 18 import java.util.Collection; 19 20 import de.smartics.properties.api.config.domain.key.ConfigurationKey; 21 import de.smartics.properties.api.core.domain.PropertyDescriptorRegistry; 22 import de.smartics.util.lang.NullArgumentException; 23 24 /** 25 * Management interface to change configuration properties. 26 * <p> 27 * Implementations are not required to be thread-safe, but usually should be. 28 * </p> 29 */ 30 public interface ConfigurationRepositoryManagement extends 31 ConfigurationRepository 32 { 33 // ********************************* Fields ********************************* 34 35 // --- constants ------------------------------------------------------------ 36 37 // ****************************** Initializer ******************************* 38 39 // ****************************** Inner Classes ***************************** 40 41 // ********************************* Methods ******************************** 42 43 // --- get&set -------------------------------------------------------------- 44 45 // --- business ------------------------------------------------------------- 46 47 /** 48 * Registers the given configuration properties for the given configuration 49 * {@code key}. 50 * 51 * @param key the key that specifies an application in its environment. 52 * @param configurationProperties the configuration properties to register by 53 * the given {@code key}. 54 * @throws NullArgumentException if {@code key} or 55 * {@code configurationProperties} is <code>null</code>. 56 * @throws DuplicateConfigurationException if a configuration with the given 57 * key is already registered. 58 */ 59 void registerProperties(ConfigurationKey key, 60 ConfigurationPropertiesManagement configurationProperties) 61 throws NullArgumentException, DuplicateConfigurationException; 62 63 /** 64 * Removes the configuration properties for the given configuration key. 65 * 66 * @param key the key that specifies an application in its environment. 67 * @return the configuration properties that has been removed. May be 68 * <code>null</code>. 69 * @throws NullArgumentException if {@code key} is <code>null</code>. 70 */ 71 ConfigurationPropertiesManagement deregisterProperties(ConfigurationKey key) 72 throws NullArgumentException; 73 74 /** 75 * Returns the list of keys with configuration properties. 76 * 77 * @return the list of keys with configuration properties. 78 */ 79 Collection<ConfigurationKey> getKeys(); 80 81 /** 82 * Fetches the properties management for the given configuration key. The 83 * default values for partial key are also attached. 84 * 85 * @param key the key that specifies an application in its environment. 86 * @return the requested configuration properties. Never <code>null</code>. 87 * @throws NullArgumentException if {@code key} is <code>null</code>. 88 * @throws MissingConfigurationException if there is no configuration for the 89 * given key. 90 * @see #getProperties(ConfigurationKey) 91 */ 92 ConfigurationPropertiesManagement getPropertiesManagementWithDefaults( 93 ConfigurationKey key) throws NullArgumentException, 94 MissingConfigurationException; 95 96 /** 97 * Fetches the properties management for the given configuration key. 98 * 99 * @param key the key that specifies an application in its environment. 100 * @return the requested configuration properties. Never <code>null</code>. 101 * @throws NullArgumentException if {@code key} is <code>null</code>. 102 * @throws MissingConfigurationException if there is no configuration for the 103 * given key. 104 * @see #getProperties(ConfigurationKey) 105 */ 106 ConfigurationPropertiesManagement getPropertiesManagement(ConfigurationKey key) 107 throws NullArgumentException, MissingConfigurationException; 108 109 /** 110 * Checks if a properties management for the given configuration key is 111 * present. 112 * 113 * @param key the key that specifies an application in its environment. 114 * @return <code>true</code> if the configuration is present, 115 * <code>false</code> if not. 116 * @throws NullArgumentException if {@code key} is <code>null</code>. 117 */ 118 boolean hasPropertiesManagement(ConfigurationKey key) 119 throws NullArgumentException; 120 121 /** 122 * Returns the registry to resolve property descriptors. 123 * 124 * @return the registry to resolve property descriptors. 125 */ 126 PropertyDescriptorRegistry getRegistry(); 127 128 // --- object basics -------------------------------------------------------- 129 130 }