From cb2221693e7ad673a9b1e26b62fea89671de0f3e Mon Sep 17 00:00:00 2001 From: Saad Sahibjan Date: Mon, 15 Feb 2021 22:09:30 +0530 Subject: [PATCH] Add sample SMS Sender implementation --- .../sms/mgt/core/impl/SampleSenderImpl.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 components/sms-mgt/io.entgra.sms.mgt.core/src/main/java/io/entgra/sms/mgt/core/impl/SampleSenderImpl.java diff --git a/components/sms-mgt/io.entgra.sms.mgt.core/src/main/java/io/entgra/sms/mgt/core/impl/SampleSenderImpl.java b/components/sms-mgt/io.entgra.sms.mgt.core/src/main/java/io/entgra/sms/mgt/core/impl/SampleSenderImpl.java new file mode 100644 index 00000000000..c223ad92cdc --- /dev/null +++ b/components/sms-mgt/io.entgra.sms.mgt.core/src/main/java/io/entgra/sms/mgt/core/impl/SampleSenderImpl.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.impl; + +import io.entgra.sms.mgt.common.bean.SMSMessage; +import io.entgra.sms.mgt.common.config.SMSGateway; +import io.entgra.sms.mgt.common.exception.SMSSenderException; +import io.entgra.sms.mgt.common.spi.SMSSender; +import io.entgra.sms.mgt.core.config.SMSConfigurationManager; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Sample sender class on how to implement the SMSSender + */ +public class SampleSenderImpl implements SMSSender { + + private static final Log log = LogFactory.getLog(SampleSenderImpl.class); + + @Override + public void sendSMS(SMSMessage smsMessage) throws SMSSenderException { + + //Retrieve the default (isDefault=true) SMS Gateway in the SMS configuration in sms-config.xml + SMSGateway smsGateway = SMSConfigurationManager.getInstance().getSMSConfig().getDefaultSMSGateway(); + + //Retrieve the SMS Gateway by passing the Gateway name + smsGateway = SMSConfigurationManager.getInstance().getSMSConfig().getSMSGateway("sample"); + + //Retrieve the properties in the SMS Gateway by passing the property name + String sampleProperty = smsGateway.getPropertyByName("sample-property").getValue(); + + if (log.isDebugEnabled()) { + log.debug("This is a Sample Sender Implementation and the property value retrieved is '" + + sampleProperty + "'"); + } + + //If any exception is catched, wrap and throw as SMSSenderException + } +}