From 8b98b7e9deecc098afde73051c60c5b34051e2d1 Mon Sep 17 00:00:00 2001 From: Saad Sahibjan Date: Mon, 15 Feb 2021 22:08:41 +0530 Subject: [PATCH] Initialize sms-config.xml file during service activation --- .../sms-mgt/io.entgra.sms.mgt.core/pom.xml | 132 ++++++++++++++++++ .../core/internal/SMSMgtServiceComponent.java | 55 ++++++++ 2 files changed, 187 insertions(+) create mode 100644 components/sms-mgt/io.entgra.sms.mgt.core/pom.xml create mode 100644 components/sms-mgt/io.entgra.sms.mgt.core/src/main/java/io/entgra/sms/mgt/core/internal/SMSMgtServiceComponent.java diff --git a/components/sms-mgt/io.entgra.sms.mgt.core/pom.xml b/components/sms-mgt/io.entgra.sms.mgt.core/pom.xml new file mode 100644 index 0000000000..09cc5826cb --- /dev/null +++ b/components/sms-mgt/io.entgra.sms.mgt.core/pom.xml @@ -0,0 +1,132 @@ + + + + + + + org.wso2.carbon.devicemgt + sms-mgt + 4.1.12-SNAPSHOT + ../pom.xml + + + 4.0.0 + io.entgra.sms.mgt.core + bundle + Entgra IoT - SMS Management Core + Entgra IoT - SMS Management Core + http://entgra.io + + + + + org.apache.felix + maven-scr-plugin + + + org.jacoco + jacoco-maven-plugin + + ${basedir}/target/coverage-reports/jacoco-unit.exec + + + + jacoco-initialize + + prepare-agent + + + + jacoco-site + test + + report + + + ${basedir}/target/coverage-reports/jacoco-unit.exec + ${basedir}/target/coverage-reports/site + + + + + + org.apache.felix + maven-bundle-plugin + true + + + ${project.artifactId} + ${project.artifactId} + ${carbon.device.mgt.version} + SMS Management Core Bundle + io.entgra.sms.mgt.core.internal + + io.entgra.sms.mgt.common.*, + javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, + javax.xml.bind.annotation, + javax.xml.bind, + org.apache.commons.lang, + org.wso2.carbon, + org.wso2.carbon.device.mgt.common.*, + org.wso2.carbon.device.mgt.core.* + + + !io.entgra.sms.mgt.core.internal, + io.entgra.sms.mgt.core.* + + * + + + + + + + + + org.wso2.carbon + org.wso2.carbon.logging + provided + + + org.wso2.carbon + org.wso2.carbon.core + provided + + + org.wso2.carbon.devicemgt + io.entgra.sms.mgt.common + provided + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.core + provided + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.common + provided + + + + + + diff --git a/components/sms-mgt/io.entgra.sms.mgt.core/src/main/java/io/entgra/sms/mgt/core/internal/SMSMgtServiceComponent.java b/components/sms-mgt/io.entgra.sms.mgt.core/src/main/java/io/entgra/sms/mgt/core/internal/SMSMgtServiceComponent.java new file mode 100644 index 0000000000..849a76d59c --- /dev/null +++ b/components/sms-mgt/io.entgra.sms.mgt.core/src/main/java/io/entgra/sms/mgt/core/internal/SMSMgtServiceComponent.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2021, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you 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. + */ + +package io.entgra.sms.mgt.core.internal; + +import io.entgra.sms.mgt.core.config.SMSConfigurationManager; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.osgi.service.component.ComponentContext; + +/** + * @scr.component + * name="io.entgra.sms.mgt.core.internal.SMSMgtServiceComponent" immediate="true" + */ +public class SMSMgtServiceComponent { + + private static final Log log = LogFactory.getLog(SMSMgtServiceComponent.class); + + protected void activate(ComponentContext ctx) { + + if (log.isDebugEnabled()) { + log.debug("Activating SMS Management Service Component"); + } + try { + SMSConfigurationManager.getInstance().initConfig(); + + if (log.isDebugEnabled()) { + log.debug("SMS Management Service Component has been successfully activated"); + } + } catch (Throwable e) { + log.error("Error occurred while activating SMS Management Service Component", e); + } + } + + protected void deactivate(ComponentContext ctx) { + if (log.isDebugEnabled()) { + log.debug("De-activating SMS Management Service Component"); + } + } +}