1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
/*-
* ============LICENSE_START=======================================================
* openECOMP : APP-C
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
*/
package org.openecomp.appc.configuration;
import java.util.Properties;
import org.slf4j.Logger;
/**
* This interface defines the common configuration support that is available to the application.
* <p>
* Where properties are common to all CDP components (server, coordinator, and EPM), the property symbolic values are
* defined as part of this interface. Where they are unique to each component, they must be defined within that
* component.
* </p>
*/
public interface Configuration {
String PROPERTY_BOOTSTRAP_FILE_NAME = "org.openecomp.appc.bootstrap.file";
String DEFAULT_BOOTSTRAP_FILE_NAME = "appc.properties";
String PROPERTY_BOOTSTRAP_FILE_PATH = "org.openecomp.appc.bootstrap.path";
String DEFAULT_BOOTSTRAP_FILE_PATH = "${user.home},etc,../etc";
String PROPERTY_RESOURCE_BUNDLES = "org.openecomp.appc.resources";
String DEFAULT_RESOURCE_BUNDLES = "org/openecomp/appc/i18n/MessageResources";
/**
* This method is called to obtain a property expressed as a boolean value (true or false). The standard rules for
* {@link Boolean#valueOf(String)} are used.
*
* @param key
* The property key
* @return The value of the property expressed as a boolean, or false if it does not exist.
*/
boolean getBooleanProperty(String key);
/**
* This method is called to obtain a property expressed as a boolean value (true or false). The standard rules for
* {@link Boolean#valueOf(String)} are used.
*
* @param key
* The property key
* @param defaultValue
* The default value to be returned if the property does not exist
* @return The value of the property expressed as a boolean, or false if it does not exist.
*/
boolean getBooleanProperty(String key, boolean defaultValue);
/**
* Returns the indicated property value expressed as a floating point double-precision value (double). The standard
* rules for {@link Double#valueOf(String)} are used.
*
* @param key
* The property to retrieve
* @return The value of the property, or 0.0 if not found or invalid
*/
double getDoubleProperty(String key);
/**
* Returns the indicated property value expressed as a floating point double-precision value (double). The standard
* rules for {@link Double#valueOf(String)} are used.
*
* @param key
* The property to retrieve
* @param defaultValue
* The default value to be returned if the property does not exist
* @return The value of the property, or 0.0 if not found or invalid
*/
double getDoubleProperty(String key, double defaultValue);
/**
* Returns the property indicated expressed as an integer. The standard rules for
* {@link Integer#parseInt(String, int)} using a radix of 10 are used.
*
* @param key
* The property name to retrieve.
* @return The value of the property, or 0 if it does not exist or is invalid.
*/
int getIntegerProperty(String key);
/**
* Returns the property indicated expressed as an integer. The standard rules for
* {@link Integer#parseInt(String, int)} using a radix of 10 are used.
*
* @param key
* The property name to retrieve.
* @param defaultValue
* The default value to be returned if the property does not exist
* @return The value of the property, or 0 if it does not exist or is invalid.
*/
int getIntegerProperty(String key, int defaultValue);
/**
* Returns the specified property as a long integer value, if it exists, or zero if it does not.
*
* @param key
* The key of the property desired.
* @return The value of the property expressed as an integer long value, or zero if the property does not exist or
* is not a valid integer long.
*/
long getLongProperty(String key);
/**
* Returns the specified property as a long integer value, if it exists, or the default value if it does not exist
* or is invalid.
*
* @param key
* The key of the property desired.
* @param defaultValue
* the value to be returned if the property is not valid or does not exist.
* @return The value of the property expressed as an integer long value, or the default value if the property does
* not exist or is not a valid integer long.
*/
long getLongProperty(String key, long defaultValue);
/**
* This method can be called to retrieve a properties object that is immutable. Any attempt to modify the properties
* object returned will result in an exception. This allows a caller to view the current configuration as a set of
* properties.
*
* @return An unmodifiable properties object.
*/
Properties getProperties();
/**
* This method is called to obtain a property as a string value
*
* @param key
* The key of the property
* @return The string value, or null if it does not exist.
*/
String getProperty(String key);
/**
* This method is called to obtain a property as a string value
*
* @param key
* The key of the property
* @param defaultValue
* The default value to be returned if the property does not exist
* @return The string value, or null if it does not exist.
*/
String getProperty(String key, String defaultValue);
/**
* Returns true if the named property is defined, false otherwise.
*
* @param key
* The key of the property we are interested in
* @return True if the property exists.
*/
boolean isPropertyDefined(String key);
/**
* Returns an indication of the validity of the boolean property. A boolean property is considered to be valid only
* if it has the value "true" or "false" (ignoring case).
*
* @param key
* The property to be checked
* @return True if the value is a boolean constant, or false if it does not exist or is not a correct string
*/
boolean isValidBoolean(String key);
/**
* Returns an indication if the indicated property represents a valid double-precision floating point number.
*
* @param key
* The property to be examined
* @return True if the property is a valid representation of a double, or false if it does not exist or contains
* illegal characters.
*/
boolean isValidDouble(String key);
/**
* Returns an indication if the property is a valid integer value or not.
*
* @param key
* The key of the property to check
* @return True if the value is a valid integer string, or false if it does not exist or contains illegal
* characters.
*/
boolean isValidInteger(String key);
/**
* Determines is the specified property exists and is a valid representation of an integer long value.
*
* @param key
* The property to be checked
* @return True if the property is a valid representation of an integer long value, and false if it either does not
* exist or is not valid.
*/
boolean isValidLong(String key);
/**
* This method allows the caller to set all properties from a provided properties object into the configuration
* property set.
* <p>
* The primary difference between this method and the factory method
* {@link ConfigurationFactory#getConfiguration(Properties)} is that this method does not clear and reload the
* configuration. Rather, this method merges the provided properties object contents into the existing properties,
* replacing any same-named keys with the values from this object.
* </p>
*
* @param properties
* The properties object to copy all properties from
*/
void setProperties(Properties properties);
/**
* This method allows a caller to insert a new property definition into the configuration object. This allows the
* application to adjust or add to the current configuration. If the property already exists, it is replaced with
* the new value.
*
* @param key
* The key of the property to be defined
* @param value
* The value of the property to be defined
*/
void setProperty(String key, String value);
}
|