Revision: 7cb2aa510b9e
Author: [email protected] <[email protected]>
Date: Sat Apr 28 23:38:02 2012
Log: Issue 10 : CLI command to configure the ESME
http://code.google.com/p/smscgateway/source/detail?r=7cb2aa510b9e
Added:
/core/oam/src/main/java/org/mobicents/smsc/oam/Subject.java
/core/smpp/src/main/java/org/mobicents/smsc/smpp/AddressNPIType.java
/core/smpp/src/main/java/org/mobicents/smsc/smpp/AddressTONType.java
/core/smpp/src/main/java/org/mobicents/smsc/smpp/Esme.java
/core/smpp/src/main/java/org/mobicents/smsc/smpp/SMSCOAMMessages.java
/core/smpp/src/main/java/org/mobicents/smsc/smpp/SMSCShellExecutor.java
/core/smpp/src/main/java/org/mobicents/smsc/smpp/SmppInterfaceVersionType.java
/core/smpp/src/main/java/org/mobicents/smsc/smpp/SmscManagement.java
Modified:
/core/bootstrap/src/main/config/META-INF/jboss-beans.xml
/core/oam/pom.xml
/core/oam/src/main/java/org/mobicents/smsc/oam/ShellExecutor.java
/core/smpp/pom.xml
/core/smpp/src/main/java/org/mobicents/smsc/smpp/DefaultSmppServerHandler.java
/core/smpp/src/main/java/org/mobicents/smsc/smpp/SmppServer.java
=======================================
--- /dev/null
+++ /core/oam/src/main/java/org/mobicents/smsc/oam/Subject.java Sat Apr 28
23:38:02 2012
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.smsc.oam;
+
+/**
+ * Represents the Subject of command formated as "subject <options>".
+ *
+ * @author zaheer abbas
+ *
+ */
+public enum Subject {
+
+ /**
+ * linkset subject. Any command to manipulate the linkset, should begin
with
+ * linkset subject
+ */
+ LINKSET("linkset"),
+
+ SCCP("sccp"),
+ /**
+ * M3UA Subject. Any command to manage the M3UA should begin with m3ua
+ * subject
+ */
+ M3UA("m3ua"),
+
+ SCTP("sctp"),
+
+ /**
+ * SMSC Subject. Any command to manage the SMSC should begin with smsc
+ * subject
+ */
+ SMSC("smsc");
+
+ private String subject = null;
+
+ private Subject(String subject) {
+ this.subject = subject;
+ }
+
+ /**
+ * get the string representation of this subject enum
+ *
+ * @return
+ */
+ public String getSubject() {
+ return subject;
+ }
+
+ /**
+ * get the corresponding enum for passed subject String. Returns null if
+ * there is no subject enum defined for passed subject string
+ *
+ * @param subject
+ * @return
+ */
+ public static Subject getSubject(String subject) {
+ if (subject.equals(LINKSET.getSubject())) {
+ return LINKSET;
+ } else if (subject.equals(M3UA.getSubject())) {
+ return M3UA;
+ } else if (subject.equals(SCCP.getSubject())) {
+ return SCCP;
+ } else if (subject.equals(SCTP.getSubject())) {
+ return SCTP;
+ }else if (subject.equals(SMSC.getSubject())) {
+ return SMSC;
+ }
+ return null;
+ }
+}
+
=======================================
--- /dev/null
+++ /core/smpp/src/main/java/org/mobicents/smsc/smpp/AddressNPIType.java
Sat Apr 28 23:38:02 2012
@@ -0,0 +1,50 @@
+package org.mobicents.smsc.smpp;
+
+public enum AddressNPIType {
+ UNKNOWN("0"), ISDN("1"), DATA("3"), TELEX("4"),
LANDMOBILE("6"),
+ NATIONAL("8"), PRIVATE("9"), ERMES("10"), IP("14"),
WAPCLIENTID("18");
+
+ private static final String TYPE_UNKNOWN = "0";
+ private static final String TYPE_ISDN = "1";
+ private static final String TYPE_TELEX = "3";
+ private static final String TYPE_LANDMOBILE = "4";
+ private static final String TYPE_NATIONAL = "6";
+ private static final String TYPE_PRIVATE = "8";
+ private static final String TYPE_ERMES = "9";
+ private static final String TYPE_IP = "14";
+ private static final String TYPE_WAPCLIENTID = "18";
+
+ private String type = null;
+
+ private AddressNPIType(String type) {
+ this.type = type;
+ }
+
+ public static AddressNPIType getAddressNPIType(String type) {
+ if (TYPE_UNKNOWN.equals(type)) {
+ return UNKNOWN;
+ } else if (TYPE_ISDN.equals(type)) {
+ return ISDN;
+ } else if (TYPE_TELEX.equals(type)) {
+ return TELEX;
+ } else if (TYPE_LANDMOBILE.equals(type)) {
+ return LANDMOBILE;
+ } else if (TYPE_NATIONAL.equals(type)) {
+ return NATIONAL;
+ } else if (TYPE_PRIVATE.equals(type)) {
+ return PRIVATE;
+ } else if (TYPE_ERMES.equals(type)) {
+ return ERMES;
+ } else if (TYPE_IP.equals(type)) {
+ return IP;
+ } else if (TYPE_WAPCLIENTID.equals(type)) {
+ return WAPCLIENTID;
+ } else {
+ return null;
+ }
+ }
+
+ public String getType() {
+ return this.type;
+ }
+}
=======================================
--- /dev/null
+++ /core/smpp/src/main/java/org/mobicents/smsc/smpp/AddressTONType.java
Sat Apr 28 23:38:02 2012
@@ -0,0 +1,50 @@
+
+package org.mobicents.smsc.smpp;
+
+public enum AddressTONType {
+ UNKNOWN("0"), INTERNATIONAL("1"), NATIONAL("2"), NETWORKSPECIFIC("3"),
SUBSCRIBERNUMBER("4"),
+ ALPHANUMBERIC("5"), ABBREVIATED("6");
+
+ private static final int TYPE_UNKNOWN = 0;
+ private static final int TYPE_INTERNATIONAL = 1;
+ private static final int TYPE_NATIONAL = 2;
+ private static final int TYPE_NETWORKSPECIFIC = 3;
+ private static final int TYPE_SUBSCRIBERNUMBER = 4;
+ private static final int TYPE_ALPHANUMBERIC = 5;
+ private static final int TYPE_ABBREVIATED = 6;
+
+ private String type = null;
+
+ private AddressTONType(String type) {
+ this.type = type;
+ }
+
+ public static AddressTONType getAddressTONType(String type) {
+ try {
+ int intTon = Integer.parseInt(type);
+ if (TYPE_UNKNOWN == intTon) {
+ return UNKNOWN;
+ } else if (TYPE_INTERNATIONAL == intTon) {
+ return INTERNATIONAL;
+ } else if (TYPE_NATIONAL == intTon) {
+ return NATIONAL;
+ } else if (TYPE_NETWORKSPECIFIC == intTon) {
+ return NETWORKSPECIFIC;
+ } else if (TYPE_SUBSCRIBERNUMBER == intTon) {
+ return SUBSCRIBERNUMBER;
+ }else if (TYPE_ALPHANUMBERIC == intTon) {
+ return ALPHANUMBERIC;
+ }else if (TYPE_ABBREVIATED == intTon) {
+ return ABBREVIATED;
+ } else {
+ return null;
+ }
+ } catch (NumberFormatException e) {
+ return null;
+ }
+ }
+
+ public String getType() {
+ return this.type;
+ }
+}
=======================================
--- /dev/null
+++ /core/smpp/src/main/java/org/mobicents/smsc/smpp/Esme.java Sat Apr 28
23:38:02 2012
@@ -0,0 +1,273 @@
+/*
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.smsc.smpp;
+
+import javolution.xml.XMLFormat;
+import javolution.xml.XMLSerializable;
+import javolution.xml.stream.XMLStreamException;
+
+import org.apache.log4j.Logger;
+
+/**
+ *
+ * @author zaheer abbas
+ *
+ */
+public class Esme implements XMLSerializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger logger = Logger.getLogger(Esme.class);
+
+ private static final String ESME_SYSTEM_ID = "systemId";
+ private static final String ESME_PASSWORD = "password";
+ private static final String REMOTE_HOST_IP = "host";
+ private static final String REMOTE_HOST_PORT = "port";
+ private static final String ESME_SYSTEM_TYPE = "systemType";
+ private static final String ESME_INTERFACE_VERSION = "smppVersion";
+ private static final String ESME_TON = "ton";
+ private static final String ESME_NPI = "npi";
+ private static final String ESME_ADDRESS_RANGE = "addressRange";
+
+ private String systemId;
+ private String password;
+ private String host;
+ private String port;
+ private String systemType;
+ private SmppInterfaceVersionType smppVersion = null;
+ private AddressTONType ton = null;
+ private AddressNPIType npi = null;
+ private String addressRange;
+
+
+ protected SmscManagement smscManagement = null;
+
+ public Esme() {
+
+ }
+
+ public Esme(String systemId, String pwd, String host, String port, String
systemType, SmppInterfaceVersionType version,
+ AddressTONType ton, AddressNPIType npi, String address)
{
+ this.systemId = systemId;
+ this.password = pwd;
+ this.host = host;
+ this.port = port;
+ this.systemType = systemType;
+ this.smppVersion = version;
+ this.ton = ton;
+ this.npi = npi;
+ this.addressRange = address;
+ }
+
+
+
+ /**
+ * Every As has unique name
+ *
+ * @return String name of this As
+ */
+ public String getSystemId() {
+ return this.systemId;
+ }
+
+ public void setSmscManagement(SmscManagement smscManagement) {
+ smscManagement = smscManagement;
+ }
+
+ public SmscManagement getSmscManagement() {
+ return smscManagement;
+ }
+
+ /**
+ * XML Serialization/Deserialization
+ */
+ protected static final XMLFormat<Esme> ESME_XML = new
XMLFormat<Esme>(Esme.class) {
+
+ @Override
+ public void read(javolution.xml.XMLFormat.InputElement xml, Esme esme)
throws XMLStreamException {
+ esme.systemId = xml.getAttribute(ESME_SYSTEM_ID, "");
+ esme.password = xml.getAttribute(ESME_PASSWORD, "");
+ esme.host = xml.getAttribute(REMOTE_HOST_IP, "");
+ esme.port = xml.getAttribute(REMOTE_HOST_PORT, "");
+ esme.systemType = xml.getAttribute(ESME_SYSTEM_TYPE,
"");
+ esme.smppVersion =
SmppInterfaceVersionType.getInterfaceVersionType(xml.getAttribute(ESME_INTERFACE_VERSION, ""));
+ esme.ton =
AddressTONType.getAddressTONType(xml.getAttribute(ESME_TON, ""));
+ esme.npi =
AddressNPIType.getAddressNPIType(xml.getAttribute(ESME_NPI, ""));
+ esme.addressRange = xml.getAttribute(ESME_ADDRESS_RANGE,
"");
+
+ }
+
+ @Override
+ public void write(Esme esme, javolution.xml.XMLFormat.OutputElement xml)
throws XMLStreamException {
+ xml.setAttribute(ESME_SYSTEM_ID, esme.systemId);
+ xml.setAttribute(ESME_PASSWORD, esme.password);
+ xml.setAttribute(REMOTE_HOST_IP, esme.host);
+ xml.setAttribute(REMOTE_HOST_PORT, esme.port);
+ xml.setAttribute(ESME_INTERFACE_VERSION,
esme.smppVersion.getType());
+ if (esme.systemType != null) {
+ xml.setAttribute(ESME_SYSTEM_TYPE,
esme.systemType);
+ }
+ if (esme.ton != null) {
+ xml.setAttribute(ESME_TON, esme.ton.getType());
+ }
+ if (esme.npi != null) {
+ xml.setAttribute(ESME_NPI, esme.ton.getType());
+ }
+ if (esme.addressRange != null) {
+ xml.setAttribute(ESME_ADDRESS_RANGE,
esme.addressRange);
+ }
+ }
+ };
+
+ public void show(StringBuffer sb) {
+
sb.append(SMSCOAMMessages.SHOW_ESME_SYSTEM_ID).append(this.systemId).append(SMSCOAMMessages.SHOW_ESME_PASSWORD).append(this.password)
+
.append(SMSCOAMMessages.SHOW_ESME_HOST).append(this.host).append(SMSCOAMMessages.SHOW_ESME_PORT).append(this.port)
+
.append(SMSCOAMMessages.SHOW_ESME_SYSTEM_TYPE).append(this.systemType).append(SMSCOAMMessages.SHOW_ESME_INTERFACE_VERSION).append(this.smppVersion)
+
.append(SMSCOAMMessages.SHOW_ESME_TON).append(this.ton).append(SMSCOAMMessages.SHOW_ESME_NPI).append(this.npi)
+
.append(SMSCOAMMessages.SHOW_ESME_ADDRESS_RANGE).append(this.addressRange);
+
+ sb.append(SMSCOAMMessages.NEW_LINE);
+ }
+
+ /**
+ * @return the password
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * @param password the password to set
+ */
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ /**
+ * @return the host
+ */
+ public String getHost() {
+ return host;
+ }
+
+ /**
+ * @param host the host to set
+ */
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ /**
+ * @return the port
+ */
+ public String getPort() {
+ return port;
+ }
+
+ /**
+ * @param port the port to set
+ */
+ public void setPort(String port) {
+ this.port = port;
+ }
+
+ /**
+ * @return the systemType
+ */
+ public String getSystemType() {
+ return systemType;
+ }
+
+ /**
+ * @param systemType the systemType to set
+ */
+ public void setSystemType(String systemType) {
+ this.systemType = systemType;
+ }
+
+ /**
+ * @return the smppVersion
+ */
+ public SmppInterfaceVersionType getSmppVersion() {
+ return smppVersion;
+ }
+
+ /**
+ * @param smppVersion the smppVersion to set
+ */
+ public void setSmppVersion(SmppInterfaceVersionType smppVersion) {
+ this.smppVersion = smppVersion;
+ }
+
+ /**
+ * @return the ton
+ */
+ public AddressTONType getTon() {
+ return ton;
+ }
+
+ /**
+ * @param ton the ton to set
+ */
+ public void setTon(AddressTONType ton) {
+ this.ton = ton;
+ }
+
+ /**
+ * @return the npi
+ */
+ public AddressNPIType getNpi() {
+ return npi;
+ }
+
+ /**
+ * @param npi the npi to set
+ */
+ public void setNpi(AddressNPIType npi) {
+ this.npi = npi;
+ }
+
+ /**
+ * @return the addressRange
+ */
+ public String getAddressRange() {
+ return addressRange;
+ }
+
+ /**
+ * @param addressRange the addressRange to set
+ */
+ public void setAddressRange(String addressRange) {
+ this.addressRange = addressRange;
+ }
+
+ /**
+ * @param systemId the systemId to set
+ */
+ public void setSystemId(String systemId) {
+ this.systemId = systemId;
+ }
+}
=======================================
--- /dev/null
+++ /core/smpp/src/main/java/org/mobicents/smsc/smpp/SMSCOAMMessages.java
Sat Apr 28 23:38:02 2012
@@ -0,0 +1,98 @@
+/*
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.smsc.smpp;
+
+/**
+ *
+ * @author zaheer abbas
+ *
+ */
+public interface SMSCOAMMessages {
+
+ /**
+ * Pre defined messages
+ */
+ public static final String INVALID_COMMAND = "Invalid Command";
+
+ /* public static final String ADD_ROUTING_RULE_SUCESSFULL = "Successfully
added Routing rule name=%s";
+
+ public static final String ADD_ROUTING_RULE_FAIL_NO_SYSTEM_ID = "Creation
of Routing rule failed, as no ESME added with the System Id name=%s"; */
+
+ public static final String ESME_START_SUCCESSFULL = "Successfully started
ESME name=%s";
+
+ public static final String ESME_STOP_SUCCESSFULL = "Successfully stopped
ESME name=%s";
+
+ public static final String CREATE_ESME_SUCCESSFULL = "Successfully
created ESME name=%s";
+
+ public static final String CREATE_EMSE_FAIL_ALREADY_EXIST = "Creation of
EMSE failed. Other ESME with name=%s already exist"; //name = systemid
+
+ public static final String CREATE_ROUTING_RULE_SUCCESSFULL
= "Successfully created Routing rule name=%s";
+
+ public static final String CREATE_ROUTING_RULE_FAIL_ALREADY_EXIST
= "Creation of Routing rule failed. Other Route with name=%s already
exist"; //name = systemid
+
+ public static final String NOT_SUPPORTED_YET = "Not supported yet";
+
+ public static final String NO_ESME_DEFINED_YET = "No ESME defined yet";
+
+ public static final String NO_ROUTING_RULE_DEFINED_YET = "No Routing rule
defined yet";
+
+ public static final String DELETE_ESME_FAILED_NO_ESME_FOUND = "No Esme
found with given systemId %s";
+
+ public static final String DELETE_ESME_SUCCESSFUL = "Successfully deleted
Esme with given systemId %s";
+ /**
+ * Generic constants
+ */
+ public static final String TAB = " ";
+
+ public static final String NEW_LINE = "\n";
+
+ public static final String COMMA = ",";
+
+ /**
+ * Show command specific constants
+ */
+ public static final String SHOW_ASSIGNED_TO = "Assigned to :\n";
+
+ public static final String SHOW_ESME_SYSTEM_ID = "ESME systemId = ";
+
+ public static final String SHOW_ESME_PASSWORD = " password = ";
+
+ public static final String SHOW_ESME_HOST = " host = ";
+
+ public static final String SHOW_ESME_PORT = " port = ";
+
+ public static final String SHOW_ESME_SYSTEM_TYPE = " systemType = ";
+
+ public static final String SHOW_ESME_INTERFACE_VERSION = "
smppInterfaceVersion = ";
+
+ public static final String SHOW_ESME_TON = " ton = ";
+
+ public static final String SHOW_ESME_NPI = " npi = ";
+
+ public static final String SHOW_ESME_ADDRESS_RANGE = " addressRange = ";
+
+ public static final String SHOW_ROUTING_RULE_NAME = "Routing rule
name=";
+
+ public static final String SHOW_STARTED = " started=";
+
+}
=======================================
--- /dev/null
+++ /core/smpp/src/main/java/org/mobicents/smsc/smpp/SMSCShellExecutor.java
Sat Apr 28 23:38:02 2012
@@ -0,0 +1,273 @@
+/*
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.smsc.smpp;
+
+import java.util.Arrays;
+
+import javolution.util.FastList;
+
+import org.apache.log4j.Logger;
+import org.mobicents.ss7.management.console.ShellExecutor;
+
+/**
+ *
+ * @author zaheer abbas
+ *
+ */
+public class SMSCShellExecutor implements ShellExecutor {
+
+ private static final Logger logger =
Logger.getLogger(SMSCShellExecutor.class);
+
+ private SmscManagement smscManagement;
+
+ public SMSCShellExecutor() {
+
+ }
+
+ /**
+ * @return the m3uaManagement
+ */
+ public SmscManagement getSmscManagement() {
+ return smscManagement;
+ }
+
+ /**
+ * @param m3uaManagement the m3uaManagement to set
+ */
+ public void setSmscManagement(SmscManagement smscManagement) {
+ this.smscManagement = smscManagement;
+ }
+
+
+ /**
+ * smsc esme create <Any 4/5 digit number> <Specify password>
+ * <host-ip> <port> system-type <sms | vms | ota >
+ * interface-version <3.3 | 3.4 | 5.0> esme-ton <esme address ton>
+ * esme-npi <esme address npi> esme-range <esme address range>
+ *
+ * @param args
+ * @return
+ */
+ private String createEsme(String[] args) throws Exception {
+ if (args.length < 5 || args.length > 20) {
+ return SMSCOAMMessages.INVALID_COMMAND;
+ }
+
+ // Create new Rem ESME
+ String systemId = args[3];
+ if (systemId == null) {
+ return SMSCOAMMessages.INVALID_COMMAND;
+ }
+ String password = args[4];
+ if (password == null) {
+ return SMSCOAMMessages.INVALID_COMMAND;
+ }
+ String host = args[5];
+ if (host == null) {
+ return SMSCOAMMessages.INVALID_COMMAND;
+ }
+ String strPort = args[6];
+ int intPort = -1;
+ if (strPort == null) {
+ return SMSCOAMMessages.INVALID_COMMAND;
+ }else{
+ try{
+ intPort = Integer.parseInt(strPort);
+ }catch(Exception e){
+ return SMSCOAMMessages.INVALID_COMMAND;
+ }
+ }
+
+
+ String systemType = null;
+ SmppInterfaceVersionType smppVersionType = null;
+ AddressTONType esmeTonType = null;
+ AddressNPIType esmeNpiType = null;
+ String esmeAddrRange = null;
+
+ int count = 7;
+
+ while (count < args.length) {
+ //These are all optional parameters for a Tx/Rx/Trx
binds
+ String key = args[count++];
+ if (key == null) {
+ return SMSCOAMMessages.INVALID_COMMAND;
+ }
+
+ if (key.equals("system-type")) {
+ systemType = args[count++];
+ } else if (key.equals("interface-version")) {
+ smppVersionType =
SmppInterfaceVersionType.getInterfaceVersionType(args[count++]);
+ if (smppVersionType == null) {
+ smppVersionType =
SmppInterfaceVersionType.SMPP34;
+ }
+ } else if (key.equals("esme-ton")) {
+ esmeTonType =
AddressTONType.getAddressTONType(args[count++]);
+ } else if (key.equals("esme-npi")) {
+ esmeNpiType =
AddressNPIType.getAddressNPIType(args[count++]);
+ } else if (key.equals("esme-range")) {
+ esmeAddrRange = /*Regex*/args[count++];
+ } else {
+ return SMSCOAMMessages.INVALID_COMMAND;
+ }
+ }
+
+ Esme esme = this.smscManagement.createEsme(systemId, password, host,
strPort, systemType, smppVersionType, esmeTonType, esmeNpiType,
esmeAddrRange);
+ return String.format(SMSCOAMMessages.CREATE_ESME_SUCCESSFULL,
esme.getSystemId());
+ }
+
+ /**
+ * smsc esme destroy <SystemId - 4/5 digit number>
+ *
+ * @param args
+ * @return
+ * @throws Exception
+ */
+ private String destroyEsme(String[] args) throws Exception {
+ if (args.length < 4) {
+ return SMSCOAMMessages.INVALID_COMMAND;
+ }
+
+ String systemId = args[3];
+ if (systemId == null) {
+ return SMSCOAMMessages.INVALID_COMMAND;
+ }
+
+ Esme esme = this.smscManagement.destroyEsme(systemId);
+
+ return String.format(SMSCOAMMessages.DELETE_ESME_SUCCESSFUL,
systemId);
+ }
+
+ private String showEsme() {
+ FastList<Esme> esmes = this.smscManagement.getEsmes();
+ if (esmes.size() == 0) {
+ return SMSCOAMMessages.NO_ESME_DEFINED_YET;
+ }
+ StringBuffer sb = new StringBuffer();
+ for (FastList.Node<Esme> n = esmes.head(), end = esmes.tail(); (n =
n.getNext()) != end;) {
+ Esme esme = n.getValue();
+ sb.append(SMSCOAMMessages.NEW_LINE);
+ esme.show(sb);
+ sb.append(SMSCOAMMessages.NEW_LINE);
+ }
+ return sb.toString();
+ }
+
+ private String executeSmsc(String[] args) {
+ try {
+ if (args.length < 3 || args.length > 20) {
+ // any command will have atleast 3 args
+ return SMSCOAMMessages.INVALID_COMMAND;
+ }
+
+ if (args[1] == null) {
+ return SMSCOAMMessages.INVALID_COMMAND;
+ }
+
+ if (args[1].equals("esme")) {
+ String rasCmd = args[2];
+ if (rasCmd == null) {
+ return SMSCOAMMessages.INVALID_COMMAND;
+ }
+
+ if (rasCmd.equals("create")) {
+ return this.createEsme(args);
+ } else if (rasCmd.equals("destroy")) {
+ return this.destroyEsme(args);
+ } else if (rasCmd.equals("show")) {
+ return this.showEsme();
+ }
+ return SMSCOAMMessages.INVALID_COMMAND;
+ } else if (args[1].equals("rule")) {/*
+
+ if (args.length > 5) {
+ return SMSCOAMMessages.INVALID_COMMAND;
+ }
+
+ // related to rem AS for SigGatewayImpl
+ String raspCmd = args[2];
+
+ if (raspCmd == null) {
+ return SMSCOAMMessages.INVALID_COMMAND;
+ } else if (raspCmd.equals("create")) {
+ // Create new rule
+ if (args.length < 5) {
+ return
SMSCOAMMessages.INVALID_COMMAND;
+ }
+
+ String aspname = args[3];
+ String assocName = args[4];
+
+ if (aspname == null || assocName ==
null) {
+ return
SMSCOAMMessages.INVALID_COMMAND;
+ }
+
+ AspFactory factory = this.m3uaManagement.createAspFactory(aspname,
assocName);
+ return String.format(SMSCOAMMessages.CREATE_ASP_SUCESSFULL,
factory.getName());
+ } else if (raspCmd.equals("destroy")) {
+ if (args.length < 4) {
+ return
SMSCOAMMessages.INVALID_COMMAND;
+ }
+
+ String aspName = args[3];
+
this.m3uaManagement.destroyAspFactory(aspName);
+ return String.format("Successfully destroyed
ASP name=%s", aspName);
+
+ } else if (raspCmd.equals("show")) {
+ return this.showAspFactories();
+
+ } else if (raspCmd.equals("start")) {
+ if (args.length < 4) {
+ return
SMSCOAMMessages.INVALID_COMMAND;
+ }
+
+ String aspName = args[3];
+ this.m3uaManagement.startAsp(aspName);
+ return
String.format(SMSCOAMMessages.ASP_START_SUCESSFULL, aspName);
+ } else if (raspCmd.equals("stop")) {
+ if (args.length < 4) {
+ return
SMSCOAMMessages.INVALID_COMMAND;
+ }
+
+ String aspName = args[3];
+ this.m3uaManagement.stopAsp(aspName);
+ return
String.format(SMSCOAMMessages.ASP_STOP_SUCESSFULL, aspName);
+ }
+
+ return SMSCOAMMessages.INVALID_COMMAND;
+ */}
+ return SMSCOAMMessages.INVALID_COMMAND;
+ } catch (Exception e) {
+ logger.error(String.format("Error while executing comand %s",
Arrays.toString(args)), e);
+ return e.getMessage();
+ }
+ }
+
+ public String execute(String[] args) {
+ if (args[0].equals("smsc")) {
+ return this.executeSmsc(args);
+ }
+ return SMSCOAMMessages.INVALID_COMMAND;
+ }
+
+}
=======================================
--- /dev/null
+++
/core/smpp/src/main/java/org/mobicents/smsc/smpp/SmppInterfaceVersionType.java
Sat Apr 28 23:38:02 2012
@@ -0,0 +1,31 @@
+package org.mobicents.smsc.smpp;
+
+public enum SmppInterfaceVersionType {
+ SMPP33("3.3"), SMPP34("3.4"), SMPP50("5.0");
+
+ private static final String TYPE_SMPP33 = "3.3";
+ private static final String TYPE_SMPP34 = "3.4";
+ private static final String TYPE_SMPP50 = "5.0";
+
+ private String type = null;
+
+ private SmppInterfaceVersionType(String type) {
+ this.type = type;
+ }
+
+ public static SmppInterfaceVersionType getInterfaceVersionType(String
type) {
+ if (TYPE_SMPP33.equals(type)) {
+ return SMPP33;
+ } else if (TYPE_SMPP34.equals(type)) {
+ return SMPP34;
+ } else if (TYPE_SMPP50.equals(type)) {
+ return SMPP50;
+ } else {
+ return null;
+ }
+ }
+
+ public String getType() {
+ return this.type;
+ }
+}
=======================================
--- /dev/null
+++ /core/smpp/src/main/java/org/mobicents/smsc/smpp/SmscManagement.java
Sat Apr 28 23:38:02 2012
@@ -0,0 +1,237 @@
+/*
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.smsc.smpp;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+
+import javolution.text.TextBuilder;
+import javolution.util.FastList;
+import javolution.xml.XMLBinding;
+import javolution.xml.XMLObjectReader;
+import javolution.xml.XMLObjectWriter;
+import javolution.xml.stream.XMLStreamException;
+
+import org.apache.log4j.Logger;
+
+/**
+ * @author zaheer abbas
+ *
+ */
+public class SmscManagement {
+ private static final Logger logger =
Logger.getLogger(SmscManagement.class);
+ private static final String ESME_LIST = "esmeList";
+ private static final String ROUTING_RULE_LIST = "routingRuleList";
+
+ private static final String SMSC_PERSIST_DIR_KEY = "smsc.persist.dir";
+ private static final String USER_DIR_KEY = "user.dir";
+ private static final String PERSIST_FILE_NAME = "smsc.xml";
+
+ private static final XMLBinding binding = new XMLBinding();
+ private static final String TAB_INDENT = "\t";
+ private static final String CLASS_ATTRIBUTE = "type";
+
+ protected FastList<Esme> esmes = new FastList<Esme>();
+
+ private final TextBuilder persistFile = TextBuilder.newInstance();
+
+ private final String name;
+
+ private String persistDir = null;
+
+ private SmppServer smppServer = null;
+
+ public SmscManagement(String name) {
+ this.name = name;
+ binding.setClassAttribute(CLASS_ATTRIBUTE);
+ binding.setAlias(Esme.class, "esme");
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getPersistDir() {
+ return persistDir;
+ }
+
+ public void setPersistDir(String persistDir) {
+ this.persistDir = persistDir;
+ }
+
+ public SmppServer getSmppServer() {
+ return smppServer;
+ }
+
+ public void setSmppServer(SmppServer smppServer) {
+ this.smppServer = smppServer;
+ }
+
+ public void start() throws Exception {
+
+ if(this.smppServer == null){
+ throw new Exception("SmppServer not set");
+ }
+
+ this.persistFile.clear();
+
+ if (persistDir != null) {
+
this.persistFile.append(persistDir).append(File.separator).append(this.name).append("_")
+ .append(PERSIST_FILE_NAME);
+ } else {
+ persistFile.append(System.getProperty(SMSC_PERSIST_DIR_KEY,
System.getProperty(USER_DIR_KEY)))
+
.append(File.separator).append(this.name).append("_").append(PERSIST_FILE_NAME);
+ }
+
+ logger.info(String.format("SMSC configuration file path %s",
persistFile.toString()));
+
+ try {
+ this.load();
+ } catch (FileNotFoundException e) {
+ logger.warn(String.format("Failed to load the SS7 configuration file.
\n%s", e.getMessage()));
+ }
+
+ this.smppServer.setSmscManagement(this);
+
+ logger.info("Started SmscManagement");
+ }
+
+ public void stop() throws Exception {
+
+ this.store();
+ }
+
+ public FastList<Esme> getEsmes() {
+ return esmes;
+ }
+
+ protected Esme getEsme(String systemId) {
+ for (FastList.Node<Esme> n = esmes.head(), end = esmes.tail(); (n =
n.getNext()) != end;) {
+ Esme esme = n.getValue();
+ if (esme.getSystemId().equals(systemId)) {
+ return esme;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * <p>
+ * Create new {@link Esme}
+ * </p>
+ * <p>
+ * Command is smsc esme create <Any 4/5 digit number> <Specify password>
+ * <host-ip> <port> system-type <sms | vms | ota > interface-version <3.3
|
+ * 3.4 | 5.0> esme-ton <esme address ton> esme-npi <esme address npi>
+ * esme-range <esme address range>
+ * </p>
+ * <p>
+ * where system-type, interface-version, esme-ton, esme-npi, esme-range
are
+ * optional, by default interface-version is 3.4.
+ *
+ * </p>
+ *
+ * @param args
+ * @return
+ * @throws Exception
+ */
+ public Esme createEsme(String systemId, String password, String host,
String port, String systemType,
+ SmppInterfaceVersionType smppIntVersion, AddressTONType ton,
AddressNPIType npi, String addressRange)
+ throws Exception {
+
+ /* Esme system id should be unique and mandatory for each esme
*/
+ Esme esme = this.getEsme(systemId);
+ if (esme != null) {
+ throw new
Exception(String.format(SMSCOAMMessages.CREATE_EMSE_FAIL_ALREADY_EXIST,
systemId));
+ }
+
+ // TODO check if RC is already taken?
+ if (smppIntVersion == null) {
+ smppIntVersion = SmppInterfaceVersionType.SMPP34;
+ }
+
+ esme = new Esme(systemId, password, host, port, systemType,
smppIntVersion, ton, npi, addressRange);
+ esme.setSmscManagement(this);
+ esmes.add(esme);
+
+ this.store();
+
+ return esme;
+ }
+
+ public Esme destroyEsme(String systemId) throws Exception {
+ Esme esme = this.getEsme(systemId);
+ if (esme == null) {
+ throw new
Exception(String.format(SMSCOAMMessages.DELETE_ESME_FAILED_NO_ESME_FOUND,
systemId));
+ }
+
+ esmes.remove(esme);
+
+ this.store();
+
+ return esme;
+ }
+
+ /**
+ * Persist
+ */
+ public void store() {
+
+ // TODO : Should we keep reference to Objects rather than
recreating
+ // everytime?
+ try {
+ XMLObjectWriter writer = XMLObjectWriter.newInstance(new
FileOutputStream(persistFile.toString()));
+ writer.setBinding(binding);
+ // Enables cross-references.
+ // writer.setReferenceResolver(new
XMLReferenceResolver());
+ writer.setIndentation(TAB_INDENT);
+ writer.write(esmes, ESME_LIST, FastList.class);
+
+ writer.close();
+ } catch (Exception e) {
+ logger.error("Error while persisting the Rule state in
file", e);
+ }
+ }
+
+ /**
+ * Load and create LinkSets and Link from persisted file
+ *
+ * @throws Exception
+ */
+ public void load() throws FileNotFoundException {
+
+ XMLObjectReader reader = null;
+ try {
+ reader = XMLObjectReader.newInstance(new
FileInputStream(persistFile.toString()));
+
+ reader.setBinding(binding);
+ esmes = reader.read(ESME_LIST, FastList.class);
+
+ } catch (XMLStreamException ex) {
+ // this.logger.info(
+ // "Error while re-creating Linksets from persisted
file", ex);
+ }
+ }
+}
=======================================
--- /core/bootstrap/src/main/config/META-INF/jboss-beans.xml Thu Apr 26
01:25:46 2012
+++ /core/bootstrap/src/main/config/META-INF/jboss-beans.xml Sat Apr 28
23:38:02 2012
@@ -72,28 +72,32 @@
<inject bean="SccpStack" />
</property>
</bean>
-
+
<!-- ====================================================================
-->
<!-- TCAP Service -->
- <!-- ====================================================================
-->
+ <!-- ====================================================================
-->
<bean name="TcapStack"
class="org.mobicents.protocols.ss7.tcap.TCAPStackImpl">
<constructor>
- <parameter><inject bean="SccpStack" property="sccpProvider"
/></parameter>
+ <parameter>
+ <inject bean="SccpStack" property="sccpProvider"
/>
+ </parameter>
<parameter>8</parameter>
<parameter>5000</parameter>
</constructor>
<property name="dialogIdleTimeout">60000</property>
<property name="invokeTimeout">30000</property>
</bean>
-
+
<!-- ====================================================================
-->
<!-- MAP Service -->
- <!-- ====================================================================
-->
+ <!-- ====================================================================
-->
<bean name="MapStack"
class="org.mobicents.protocols.ss7.map.MAPStackImpl">
<constructor>
- <parameter><inject bean="TcapStack" property="provider"
/></parameter>
+ <parameter>
+ <inject bean="TcapStack" property="provider" />
+ </parameter>
</constructor>
- </bean>
+ </bean>
<!-- ====================================================================
-->
<!-- Shell Service -->
@@ -109,6 +113,10 @@
<property name="m3UAShellExecutor">
<inject bean="M3UAShellExecutor" />
</property>
+
+ <property name="sMSCShellExecutor">
+ <inject bean="SMSCShellExecutor" />
+ </property>
</bean>
<!-- ====================================================================
-->
@@ -187,5 +195,24 @@
</property>
</bean>
+ <!-- ====================================================================
-->
+ <!-- SMSC -->
+ <!-- SmscManagement is managing the all Smsc server commands -->
+ <!-- ====================================================================
-->
+ <bean name="SmscManagement"
class="org.mobicents.smsc.smpp.SmscManagement">
+ <constructor>
+ <parameter>SmscManagement</parameter>
+ </constructor>
+ <property name="persistDir">${jboss.server.data.dir}</property>
+ <property name="smppServer">
+ <inject bean="SMPPServer" />
+ </property>
+ </bean>
+
+ <bean name="SMSCShellExecutor"
class="org.mobicents.smsc.smpp.SMSCShellExecutor">
+ <property name="smscManagement">
+ <inject bean="SmscManagement" />
+ </property>
+ </bean>
</deployment>
=======================================
--- /core/oam/pom.xml Thu Apr 26 01:25:46 2012
+++ /core/oam/pom.xml Sat Apr 28 23:38:02 2012
@@ -14,6 +14,12 @@
<name>Core : Operations and Management</name>
<dependencies>
+ <!-- SMSC SMPP -->
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>smpp</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
<!-- javolution -->
<dependency>
<groupId>javolution</groupId>
=======================================
--- /core/oam/src/main/java/org/mobicents/smsc/oam/ShellExecutor.java Thu
Apr 26 01:25:46 2012
+++ /core/oam/src/main/java/org/mobicents/smsc/oam/ShellExecutor.java Sat
Apr 28 23:38:02 2012
@@ -9,8 +9,8 @@
import org.apache.log4j.Logger;
import org.mobicents.protocols.ss7.m3ua.impl.oam.M3UAShellExecutor;
import org.mobicents.protocols.ss7.sccp.impl.oam.SccpExecutor;
+import org.mobicents.smsc.smpp.SMSCShellExecutor;
import org.mobicents.ss7.linkset.oam.LinksetExecutor;
-import org.mobicents.ss7.management.console.Subject;
import org.mobicents.ss7.management.transceiver.ChannelProvider;
import org.mobicents.ss7.management.transceiver.ChannelSelectionKey;
import org.mobicents.ss7.management.transceiver.ChannelSelector;
@@ -49,6 +49,8 @@
private volatile SccpExecutor sccpExecutor = null;
+ private volatile SMSCShellExecutor sMSCShellExecutor = null;
+
public ShellExecutor() throws IOException {
}
@@ -81,8 +83,7 @@
logger.info("Starting SS7 management shell environment");
provider = ChannelProvider.provider();
serverChannel = provider.openServerChannel();
- InetSocketAddress inetSocketAddress = new
InetSocketAddress(address,
- port);
+ InetSocketAddress inetSocketAddress = new InetSocketAddress(address,
port);
serverChannel.bind(inetSocketAddress);
selector = provider.openSelector();
@@ -90,8 +91,7 @@
messageFactory = ChannelProvider.provider().getMessageFactory();
- this.logger.info(String.format("ShellExecutor listening at %s",
- inetSocketAddress));
+ this.logger.info(String.format("ShellExecutor listening at %s",
inetSocketAddress));
this.started = true;
new Thread(this).start();
@@ -116,6 +116,14 @@
public void setM3UAShellExecutor(M3UAShellExecutor shellExecutor) {
m3UAShellExecutor = shellExecutor;
}
+
+ public SMSCShellExecutor getsMSCShellExecutor() {
+ return sMSCShellExecutor;
+ }
+
+ public void setsMSCShellExecutor(SMSCShellExecutor sMSCShellExecutor) {
+ this.sMSCShellExecutor = sMSCShellExecutor;
+ }
public void run() {
@@ -123,10 +131,8 @@
try {
FastSet<ChannelSelectionKey> keys =
selector.selectNow();
- for (FastSet.Record record = keys.head(), end = keys.tail(); (record =
record
- .getNext()) != end;) {
- ChannelSelectionKey key =
(ChannelSelectionKey) keys
- .valueOf(record);
+ for (FastSet.Record record = keys.head(), end = keys.tail(); (record =
record.getNext()) != end;) {
+ ChannelSelectionKey key =
(ChannelSelectionKey) keys.valueOf(record);
if (key.isAcceptable()) {
accept();
@@ -139,16 +145,13 @@
System.out.println("received
" + rxMessage);
if
(rxMessage.compareTo("disconnect") == 0) {
this.txMessage =
"Bye";
-
chan.send(messageFactory
-
.createMessage(txMessage));
+
chan.send(messageFactory.createMessage(txMessage));
} else {
String[] options =
rxMessage.split(" ");
- Subject subject
= Subject
-
.getSubject(options[0]);
+ Subject subject
= Subject.getSubject(options[0]);
if (subject ==
null) {
-
chan.send(messageFactory
-
.createMessage("Invalid Subject"));
+
chan.send(messageFactory.createMessage("Invalid Subject"));
} else {
//
Nullify examined options
//
options[0] = null;
@@ -158,8 +161,7 @@
if (this.linksetExecutor == null) {
this.txMessage = "Error! LinksetExecutor is null";
} else {
-
this.txMessage = this.linksetExecutor
-
.execute(options);
+
this.txMessage = this.linksetExecutor.execute(options);
}
break;
case
SCTP:
@@ -167,24 +169,28 @@
if (this.m3UAShellExecutor == null) {
this.txMessage = "Error! M3UAShellExecutor is null";
} else {
-
this.txMessage = this.m3UAShellExecutor
-
.execute(options);
+
this.txMessage = this.m3UAShellExecutor.execute(options);
}
break;
case
SCCP:
if (this.sccpExecutor == null) {
this.txMessage = "Error! SccpExecutor is null";
} else {
-
this.txMessage = this.sccpExecutor
-
.execute(options);
+
this.txMessage = this.sccpExecutor.execute(options);
+
}
+
break;
+ case
SMSC:
+
if (this.sMSCShellExecutor == null) {
+
this.txMessage = "Error! SMSCShellExecutor is null";
+
} else {
+
this.txMessage = this.sMSCShellExecutor.execute(options);
}
break;
default:
this.txMessage = "Invalid Subject";
break;
}
-
chan.send(messageFactory
-
.createMessage(this.txMessage));
+
chan.send(messageFactory.createMessage(this.txMessage));
}
} // if
(rxMessage.compareTo("disconnect")
} // if (msg != null)
@@ -220,8 +226,7 @@
}
} catch (Exception e) {
logger.error(
- "Exception while operating on ChannelSelectionKey. Client CLI
connection will be closed now",
- e);
+ "Exception while operating on ChannelSelectionKey. Client CLI
connection will be closed now", e);
try {
this.closeChannel();
} catch (IOException e1) {
@@ -252,8 +257,7 @@
private void accept() throws IOException {
channel = serverChannel.accept();
skey.cancel();
- skey = channel.register(selector, SelectionKey.OP_READ
- | SelectionKey.OP_WRITE);
+ skey = channel.register(selector, SelectionKey.OP_READ |
SelectionKey.OP_WRITE);
}
private void closeChannel() throws IOException {
=======================================
--- /core/smpp/pom.xml Thu Apr 26 01:25:46 2012
+++ /core/smpp/pom.xml Sat Apr 28 23:38:02 2012
@@ -14,6 +14,18 @@
<name>Core : SMPP Server</name>
<dependencies>
+ <!-- SS7 Shell -->
+ <dependency>
+ <artifactId>shell</artifactId>
+
<groupId>org.mobicents.protocols.ss7.management</groupId>
+ <version>${ss7.version}</version>
+ </dependency>
+ <!-- javolution -->
+ <dependency>
+ <groupId>javolution</groupId>
+ <artifactId>javolution</artifactId>
+ <version>${javolution.version}</version>
+ </dependency>
<!-- cloudhopper smpp -->
<dependency>
<groupId>cloudhopper</groupId>
=======================================
---
/core/smpp/src/main/java/org/mobicents/smsc/smpp/DefaultSmppServerHandler.java
Thu Apr 26 01:25:46 2012
+++
/core/smpp/src/main/java/org/mobicents/smsc/smpp/DefaultSmppServerHandler.java
Sat Apr 28 23:38:02 2012
@@ -18,6 +18,15 @@
private static final Logger logger =
Logger.getLogger(DefaultSmppServerHandler.class);
private transient SmppSessionHandlerInterface smppSessionHandlerInterface
= null;
+
+ private transient SmscManagement smscManagement = null;
+
+ public DefaultSmppServerHandler() {
+ }
+
+ public void setSmscManagement(SmscManagement smscManagement) {
+ this.smscManagement = smscManagement;
+ }
public SmppSessionHandlerInterface getSmppSessionHandlerInterface() {
return smppSessionHandlerInterface;
@@ -30,6 +39,26 @@
@Override
public void sessionBindRequested(Long sessionId, SmppSessionConfiguration
sessionConfiguration,
final BaseBind bindRequest) throws
SmppProcessingException {
+
+ if (this.smppSessionHandlerInterface == null) {
+ logger.error("No SmppSessionHandlerInterface registered yet! Will close
SmppServerSession");
+ throw new
SmppProcessingException(SmppConstants.STATUS_BINDFAIL);
+ }
+
+ Esme esme =
this.smscManagement.getEsme(bindRequest.getSystemId());
+
+ if (esme == null) {
+ logger.error(String.format("No ESME configured for SystemId=%s",
bindRequest.getSystemId()));
+ throw new
SmppProcessingException(SmppConstants.STATUS_INVSYSID);
+ }
+
+ if (!(esme.getPassword().equals(bindRequest.getPassword()))) {
+ logger.error(String.format("Invalid password for SystemId=%s",
bindRequest.getSystemId()));
+ throw new
SmppProcessingException(SmppConstants.STATUS_INVPASWD);
+ }
+
+ //TODO More parameters to compare
+
// test name change of sessions
// this name actually shows up as thread context....
sessionConfiguration.setName("Application.SMPP." +
sessionConfiguration.getSystemId());
@@ -45,6 +74,7 @@
logger.info(String.format("Session created: %s",
session.getConfiguration().getSystemId()));
}
+ //TODO smppSessionHandlerInterface should also expose boolean indicating
listener is ready to process the request
if (this.smppSessionHandlerInterface == null) {
logger.error("No SmppSessionHandlerInterface registered yet! Will close
SmppServerSession");
throw new
SmppProcessingException(SmppConstants.STATUS_BINDFAIL);
@@ -70,12 +100,12 @@
if (this.smppSessionHandlerInterface != null) {
this.smppSessionHandlerInterface.sessionDestroyed(sessionId, session);
}
-
+
// print out final stats
if (session.hasCounters()) {
logger.info(String.format("final session rx-submitSM: %s",
session.getCounters().getRxSubmitSM()));
}
-
+
// make sure it's really shutdown
session.destroy();
}
=======================================
--- /core/smpp/src/main/java/org/mobicents/smsc/smpp/SmppServer.java Thu
Apr 26 01:25:46 2012
+++ /core/smpp/src/main/java/org/mobicents/smsc/smpp/SmppServer.java Sat
Apr 28 23:38:02 2012
@@ -6,16 +6,22 @@
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.atomic.AtomicInteger;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.StandardMBean;
+
import org.apache.log4j.Logger;
+import org.jboss.mx.util.MBeanServerLocator;
import com.cloudhopper.smpp.SmppConstants;
import com.cloudhopper.smpp.SmppServerConfiguration;
import com.cloudhopper.smpp.SmppServerHandler;
import com.cloudhopper.smpp.impl.DefaultSmppServer;
+import com.cloudhopper.smpp.jmx.DefaultSmppServerMXBean;
import com.cloudhopper.smpp.type.SmppChannelException;
public class SmppServer {
-
+ private static final String JMX_DOMAIN = "org.mobicents.smsc";
private static final Logger logger = Logger.getLogger(SmppServer.class);
private String name = "SmppServer";
@@ -44,9 +50,18 @@
private SmppServerHandler smppServerHandler = null;
+ private MBeanServer mbeanServer = null;
+
+ private SmscManagement smscManagement = null;
+
public SmppServer() {
}
+
+ public void setSmscManagement(SmscManagement smscManagement) {
+ this.smscManagement = smscManagement;
+
((DefaultSmppServerHandler)this.smppServerHandler).setSmscManagement(smscManagement);
+ }
public void setName(String name) {
this.name = name;
@@ -153,13 +168,15 @@
// sendWindow.
configuration.setDefaultWindowWaitTimeout(this.defaultWindowWaitTimeout);
configuration.setDefaultSessionCountersEnabled(this.defaultSessionCountersEnabled);
+
+ // We bind to JBoss MBean
configuration.setJmxEnabled(false);
this.smppServerHandler = new DefaultSmppServerHandler();
// create a server, start it up
this.defaultSmppServer = new DefaultSmppServer(configuration,
smppServerHandler, executor, monitorExecutor);
-
+ this.registerMBean();
logger.info("Starting SMPP server...");
this.defaultSmppServer.start();
logger.info("SMPP server started");
@@ -171,6 +188,35 @@
logger.info("SMPP server stopped");
logger.info(String.format("Server counters: %s",
this.defaultSmppServer.getCounters()));
}
+
+ public void destroy() {
+ this.unregisterMBean();
+ }
+
+ private void registerMBean() {
+
+ try {
+ this.mbeanServer = MBeanServerLocator.locateJBoss();
+ ObjectName name = new ObjectName(JMX_DOMAIN + ":name="
+ this.name);
+ final StandardMBean mxBean = new StandardMBean(this.defaultSmppServer,
DefaultSmppServerMXBean.class, true);
+ this.mbeanServer.registerMBean(mxBean, name);
+
+ } catch (Exception e) {
+ // log the error, but don't throw an exception for this
datasource
+ logger.error(String.format("Unable to register
DefaultSmppServerMXBean %s", this.name), e);
+ }
+ }
+
+ private void unregisterMBean() {
+ try {
+ if (this.mbeanServer != null) {
+ ObjectName name = new ObjectName(JMX_DOMAIN +
":name=" + this.name);
+ this.mbeanServer.unregisterMBean(name);
+ }
+ } catch (Exception e) {
+ logger.error(String.format("Unable to unregister
DefaultSmppServerMXBean %s", this.name), e);
+ }
+ }
public DefaultSmppServerHandler getDefaultSmppServerHandler() {
return (DefaultSmppServerHandler) smppServerHandler;