summaryrefslogtreecommitdiffstats
path: root/common-app-api/src/main/java/org/openecomp/sdc/common/impl/FSConfigurationSource.java
diff options
context:
space:
mode:
Diffstat (limited to 'common-app-api/src/main/java/org/openecomp/sdc/common/impl/FSConfigurationSource.java')
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/impl/FSConfigurationSource.java75
1 files changed, 38 insertions, 37 deletions
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/FSConfigurationSource.java b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/FSConfigurationSource.java
index 3aa220c5bc..8cab431594 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/FSConfigurationSource.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/FSConfigurationSource.java
@@ -7,9 +7,9 @@
* 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.
@@ -31,8 +31,9 @@ import org.openecomp.sdc.common.util.YamlToObjectConverter;
/**
* Read configuration from file system
- *
+ *
* @author esofer
+ *
*/
public class FSConfigurationSource implements ConfigurationSource {
@@ -41,50 +42,50 @@ public class FSConfigurationSource implements ConfigurationSource {
private final ConfigFileChangeListener changeListener;
private final String appConfigDir;
- public FSConfigurationSource(ConfigFileChangeListener changeListener, String appConfigDir) {
- super();
- this.changeListener = changeListener;
- this.appConfigDir = appConfigDir;
- }
+ public FSConfigurationSource(ConfigFileChangeListener changeListener, String appConfigDir) {
+ super();
+ this.changeListener = changeListener;
+ this.appConfigDir = appConfigDir;
+ }
- /*
- * get and watch configuration changes. The file name we looking for is the lower case of the class name separated by "-".
- *
- * (non-Javadoc)
- *
- * @see org.openecomp.sdc.common.api.ConfigurationSource#getAndWatchConfiguration (java.lang.Class, org.openecomp.sdc.common.api.ConfigurationListener)
- */
- public <T> T getAndWatchConfiguration(Class<T> className, ConfigurationListener configurationListener) {
+ /*
+ * get and watch configuration changes. The file name we looking for is the lower case of the class name separated by "-".
+ *
+ * (non-Javadoc)
+ *
+ * @see org.openecomp.sdc.common.api.ConfigurationSource#getAndWatchConfiguration (java.lang.Class, org.openecomp.sdc.common.api.ConfigurationListener)
+ */
+ public <T> T getAndWatchConfiguration(Class<T> className, ConfigurationListener configurationListener) {
- String configFileName = calculateFileName(className);
+ String configFileName = calculateFileName(className);
- T object = yamlToObjectConverter.convert(this.appConfigDir, className, configFileName);
+ T object = yamlToObjectConverter.convert(this.appConfigDir, className, configFileName);
- if (configurationListener != null && changeListener != null) {
- if (object != null) {
- changeListener.register(configFileName, configurationListener);
- }
- }
+ if (configurationListener != null && changeListener != null) {
+ if (object != null) {
+ changeListener.register(configFileName, configurationListener);
+ }
+ }
- return object;
- }
+ return object;
+ }
- public <T> void addWatchConfiguration(Class<T> className, ConfigurationListener configurationListener) {
+ public <T> void addWatchConfiguration(Class<T> className, ConfigurationListener configurationListener) {
- String configFileName = calculateFileName(className);
+ String configFileName = calculateFileName(className);
- if (configurationListener != null) {
- changeListener.register(configFileName, configurationListener);
- }
+ if (configurationListener != null) {
+ changeListener.register(configFileName, configurationListener);
+ }
- }
+ }
- /**
- * convert camel case string to list of words separated by "-" where each word is in lower case format. For example, MyClass will be calculated to be my-class.yaml .
- *
- * @param className
- * @return file name based on the class name
- */
+ /**
+ * convert camel case string to list of words separated by "-" where each word is in lower case format. For example, MyClass will be calculated to be my-class.yaml .
+ *
+ * @param className
+ * @return file name based on the class name
+ */
static <T> String calculateFileName(Class<T> className) {
String[] words = className.getSimpleName().split("(?=\\p{Upper})");