2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.common.impl;
23 import org.apache.commons.jci.monitor.FilesystemAlterationMonitor;
24 import org.openecomp.sdc.common.api.ConfigurationSource;
35 public class ExternalConfiguration {
37 private static String appName;
38 private static String appVersion;
39 private static String configDir;
40 private static ConfigurationSource configurationSource;
42 private static FilesystemAlterationMonitor fam = null;
44 private static ConfigFileChangeListener changeListener = new ConfigFileChangeListener();
46 private static boolean enableReconfigure = true;
48 public static String getAppName() {
52 public static void setAppName(String appName) {
53 ExternalConfiguration.appName = appName;
56 public static String getAppVersion() {
60 public static void setAppVersion(String appVersion) {
61 ExternalConfiguration.appVersion = appVersion;
64 public static String getConfigDir() {
68 public static void setConfigDir(String configDir) {
69 ExternalConfiguration.configDir = configDir;
72 public static ConfigurationSource getConfigurationSource() {
73 return configurationSource;
76 public static void setConfigurationSource(ConfigurationSource configurationSource) {
77 ExternalConfiguration.configurationSource = configurationSource;
80 public static ConfigFileChangeListener getChangeListener() {
81 return changeListener;
84 public static void listenForChanges() {
86 String watchingDir = configDir + File.separator + appName;
87 if (enableReconfigure) {
89 fam = new FilesystemAlterationMonitor();
90 fam.setInterval(1000);
91 fam.addListener(new File(watchingDir), changeListener);
97 public static void stopListenForFileChanges() {
98 if (enableReconfigure) {