* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
* =============================================================================
* 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
* ============LICENSE_END=========================================================
*/
package org.onap.appc.ccadaptor;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;
-
import org.onap.ccsdk.sli.core.sli.ConfigurationException;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
public class CCAActivator implements BundleActivator
{
- private static final String CCA_PROP_FILE_VAR = "SDNC_CCA_PROPERTIES";
- private static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR";
-
@SuppressWarnings("rawtypes")
private ServiceRegistration registration = null;
- //private static final Logger log = LoggerFactory.getLogger(CCAActivator.class);
private static final EELFLogger log = EELFManager.getInstance().getLogger(CCAActivator.class);
- @Override
- public void start(BundleContext ctx) throws Exception
- {
- // Read properties
- Properties props = new Properties();
-
- // Read properties from appc-config-adaptor.properties
- String propFileName = System.getenv(CCA_PROP_FILE_VAR);
- if (propFileName == null)
- {
- String propDir = System.getenv(SDNC_CONFIG_DIR_VAR);
- if (propDir == null)
- throw new ConfigurationException(
- "Cannot find config file - " + CCA_PROP_FILE_VAR + " and " + SDNC_CONFIG_DIR_VAR + " unset");
+ @Override
+ public void start(BundleContext ctx) throws Exception
+ {
+ // Read properties
+ Properties props = new Properties();
- propFileName = propDir + "/appc-config-adaptor.properties";
- log.warn("Environment variable " + CCA_PROP_FILE_VAR + " unset - defaulting to " + propFileName);
- }
+ // Read properties from appc-config-adaptor.properties
+ String propFileName = CcAdaptorConstants.getEnvironmentVariable(CcAdaptorConstants.CCA_PROP_FILE_VAR);
+ if (propFileName == null)
+ {
+ String propDir = CcAdaptorConstants.getEnvironmentVariable(CcAdaptorConstants.APPC_CONFIG_DIR_VAR);
+ if (propDir == null)
+ throw new ConfigurationException(
+ "Cannot find config file - " + CcAdaptorConstants.CCA_PROP_FILE_VAR + " and " +
+ CcAdaptorConstants.APPC_CONFIG_DIR_VAR + " unset");
+
+ propFileName = propDir + "/appc-config-adaptor.properties";
+ log.warn("Environment variable " + CcAdaptorConstants.CCA_PROP_FILE_VAR + " unset - defaulting to "
+ + propFileName);
+ }
- File propFile = new File(propFileName);
- if (!propFile.exists())
- throw new ConfigurationException("Missing configuration properties file: " + propFile);
+ File propFile = new File(propFileName);
+ if (!propFile.exists())
+ throw new ConfigurationException("Missing configuration properties file: " + propFile);
- try(InputStream in = new FileInputStream(propFile)) {
- props.load(in);
- log.info("Loaded properties: ");
- }
- catch (Exception e)
- {
- throw new ConfigurationException("Could not load properties file " + propFileName, e);
- }
+ try (InputStream in = new FileInputStream(propFile))
+ {
+ props.load(in);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("Could not load properties file " + propFileName, e);
+ }
- // Advertise adaptor
- ConfigComponentAdaptor adaptor = new ConfigComponentAdaptor(props);
- if (registration == null)
- {
- log.info("Registering service " + ConfigComponentAdaptor.class.getName());
- registration = ctx.registerService(ConfigComponentAdaptor.class.getName(), adaptor, null);
- }
+ log.info("Loaded properties: ");
+ // Advertise adaptor
+ ConfigComponentAdaptor adaptor = new ConfigComponentAdaptor(props);
+ if (registration == null)
+ {
+ log.info("Registering service " + ConfigComponentAdaptor.class.getName());
+ registration = ctx.registerService(ConfigComponentAdaptor.class.getName(), adaptor, null);
}
- @Override
- public void stop(BundleContext ctx) throws Exception
+ }
+
+ @Override
+ public void stop(BundleContext ctx) throws Exception
+ {
+ if (registration != null)
{
- if (registration != null)
- {
- registration.unregister();
- registration = null;
- }
+ registration.unregister();
+ registration = null;
}
-}
+ }
+}
\ No newline at end of file