Revision: ae0f5a8c84c5
Author: [email protected] <[email protected]>
Date: Sun Aug 19 03:15:28 2012
Log: Issue 13:Adapt to latest SS7 CLI changes
http://code.google.com/p/ussdgateway/source/detail?r=ae0f5a8c84c5
Added:
/core/oam/cli/pom.xml
/core/oam/cli/src/main/java/org/mobicents/ussdgateway/management/console/impl/UssdCommandHandler.java
/core/oam/cli/src/main/resources/archive-files/org.mobicents.ss7.management.console.CommandHandler
Deleted:
/core/oam/pom.xml
/core/oam/src/main/java/org/mobicents/ussdgateway/oam/ShellExecutor.java
/core/oam/src/main/java/org/mobicents/ussdgateway/oam/Subject.java
Modified:
/core/bootstrap/pom.xml
/core/bootstrap/src/main/assembly/descriptor.xml
/core/bootstrap/src/main/config/META-INF/jboss-beans.xml
/core/pom.xml
=======================================
--- /dev/null
+++ /core/oam/cli/pom.xml Sun Aug 19 03:15:28 2012
@@ -0,0 +1,82 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.mobicents.ussd</groupId>
+ <artifactId>core</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>ussd-cli</artifactId>
+ <name>Core : Operations and Management : CLI</name>
+
+ <dependencies>
+ <!-- <dependency> <groupId>log4j</groupId>
<artifactId>log4j</artifactId>
+ <version>${log4j.version}</version> </dependency> -->
+ <!-- MTP3 -->
+ <dependency>
+
<groupId>org.mobicents.protocols.ss7.management</groupId>
+ <artifactId>shell</artifactId>
+ <version>${ss7.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${pom.artifactId}-${pom.version}</finalName>
+ <resources>
+ <resource>
+
<directory>src/main/resources/archive-files</directory>
+ <targetPath>META-INF/services</targetPath>
+ </resource>
+ <resource>
+ <directory>src/main/resources/help</directory>
+ <targetPath>help</targetPath>
+ </resource>
+ </resources>
+ </build>
+ <profiles>
+ <profile>
+ <!-- Adds the files to JBoss AS -->
+ <id>jboss</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+
<artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>deploy</id>
+
<phase>install</phase>
+ <goals>
+
<goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <copy
todir="${jboss.home}/lib"
+
file="${project.build.directory}/${build.finalName}.jar" />
+ </tasks>
+ </configuration>
+ </execution>
+ <execution>
+
<id>undeploy</id>
+
<phase>clean</phase>
+ <goals>
+
<goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <delete
failonerror="fals"
+
file="${jboss.home}/lib/${build.finalName}.jar" />
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
=======================================
--- /dev/null
+++
/core/oam/cli/src/main/java/org/mobicents/ussdgateway/management/console/impl/UssdCommandHandler.java
Sun Aug 19 03:15:28 2012
@@ -0,0 +1,76 @@
+package org.mobicents.ussdgateway.management.console.impl;
+
+import org.mobicents.ss7.management.console.CommandContext;
+import org.mobicents.ss7.management.console.CommandHandlerWithHelp;
+import org.mobicents.ss7.management.console.Tree;
+
+/**
+ * @author amit bhayani
+ *
+ */
+public class UssdCommandHandler extends CommandHandlerWithHelp {
+
+ static final Tree commandTree = new Tree("ussd");
+ static {
+// Node parent = commandTree.getTopNode();
+//
+// Node esme = parent.addChild("esme");
+// esme.addChild("create");
+// esme.addChild("delete");
+// esme.addChild("show");
+//
+// Node set = parent.addChild("set");
+// set.addChild("scgt");
+// set.addChild("scssn");
+// set.addChild("hlrssn");
+// set.addChild("mscssn");
+// set.addChild("maxmapv");
+//
+// Node get = parent.addChild("get");
+// get.addChild("scgt");
+// get.addChild("scssn");
+// get.addChild("hlrssn");
+// get.addChild("mscssn");
+// get.addChild("maxmapv");
+
+ };
+
+ public UssdCommandHandler() {
+ super(commandTree, CONNECT_MANDATORY_FLAG);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.mobicents.ss7.management.console.CommandHandler#isValid(java.lang
+ * .String)
+ */
+ @Override
+ public void handle(CommandContext ctx, String commandLine) {
+ // TODO Validate command
+ if (commandLine.contains("--help")) {
+ this.printHelp(commandLine, ctx);
+ return;
+ }
+
+ ctx.sendMessage(commandLine);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ *
org.mobicents.ss7.management.console.CommandHandler#isAvailable(org.mobicents
+ * .ss7.management.console.CommandContext)
+ */
+ @Override
+ public boolean isAvailable(CommandContext ctx) {
+ if (!ctx.isControllerConnected()) {
+ ctx.printLine("The command is not available in the current context.
Please connnect first");
+ return false;
+ }
+ return true;
+ }
+
+}
=======================================
--- /dev/null
+++
/core/oam/cli/src/main/resources/archive-files/org.mobicents.ss7.management.console.CommandHandler
Sun Aug 19 03:15:28 2012
@@ -0,0 +1,1 @@
+org.mobicents.ussdgateway.management.console.impl.UssdCommandHandler
=======================================
--- /core/oam/pom.xml Wed May 23 04:25:36 2012
+++ /dev/null
@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <packaging>jar</packaging>
-
- <parent>
- <groupId>org.mobicents.ussd</groupId>
- <artifactId>core</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>oam</artifactId>
- <name>Core : OAM</name>
-
- <dependencies>
- <!-- javolution -->
- <dependency>
- <groupId>javolution</groupId>
- <artifactId>javolution</artifactId>
- <version>${javolution.version}</version>
- </dependency>
- <!-- Management Shell -->
- <dependency>
- <artifactId>shell</artifactId>
-
<groupId>org.mobicents.protocols.ss7.management</groupId>
- <version>${ss7.version}</version>
- </dependency>
- <!-- Management linkset -->
- <dependency>
- <artifactId>linkset</artifactId>
-
<groupId>org.mobicents.protocols.ss7.management</groupId>
- <version>${ss7.version}</version>
- </dependency>
- <!-- M3UA -->
- <dependency>
- <artifactId>m3ua-impl</artifactId>
- <groupId>org.mobicents.protocols.ss7.m3ua</groupId>
- <version>${ss7.version}</version>
- </dependency>
- <!-- SCCP -->
- <dependency>
- <artifactId>sccp-impl</artifactId>
- <groupId>org.mobicents.protocols.ss7.sccp</groupId>
- <version>${ss7.version}</version>
- </dependency>
- </dependencies>
-</project>
=======================================
---
/core/oam/src/main/java/org/mobicents/ussdgateway/oam/ShellExecutor.java
Mon May 21 13:34:47 2012
+++ /dev/null
@@ -1,270 +0,0 @@
-package org.mobicents.ussdgateway.oam;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.nio.channels.SelectionKey;
-
-import javolution.util.FastSet;
-
-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.ss7.linkset.oam.LinksetExecutor;
-import org.mobicents.ss7.management.transceiver.ChannelProvider;
-import org.mobicents.ss7.management.transceiver.ChannelSelectionKey;
-import org.mobicents.ss7.management.transceiver.ChannelSelector;
-import org.mobicents.ss7.management.transceiver.Message;
-import org.mobicents.ss7.management.transceiver.MessageFactory;
-import org.mobicents.ss7.management.transceiver.ShellChannel;
-import org.mobicents.ss7.management.transceiver.ShellServerChannel;
-
-/**
- * @author amit bhayani
- */
-public class ShellExecutor implements Runnable {
-
- Logger logger = Logger.getLogger(ShellExecutor.class);
-
- private ChannelProvider provider;
- private ShellServerChannel serverChannel;
- private ShellChannel channel;
- private ChannelSelector selector;
- private ChannelSelectionKey skey;
-
- private MessageFactory messageFactory = null;
-
- private String rxMessage = "";
- private String txMessage = "";
-
- private volatile boolean started = false;
-
- private String address;
-
- private int port;
-
- private volatile LinksetExecutor linksetExecutor = null;
-
- private volatile M3UAShellExecutor m3UAShellExecutor = null;
-
- private volatile SccpExecutor sccpExecutor = null;
-
- public ShellExecutor() throws IOException {
-
- }
-
- public SccpExecutor getSccpExecutor() {
- return sccpExecutor;
- }
-
- public void setSccpExecutor(SccpExecutor sccpExecutor) {
- this.sccpExecutor = sccpExecutor;
- }
-
- public String getAddress() {
- return address;
- }
-
- public void setAddress(String address) {
- this.address = address;
- }
-
- public int getPort() {
- return port;
- }
-
- public void setPort(int port) {
- this.port = port;
- }
-
- public void start() throws IOException {
- logger.info("Starting SS7 management shell environment");
- provider = ChannelProvider.provider();
- serverChannel = provider.openServerChannel();
- InetSocketAddress inetSocketAddress = new
InetSocketAddress(address,
- port);
- serverChannel.bind(inetSocketAddress);
-
- selector = provider.openSelector();
- skey = serverChannel.register(selector, SelectionKey.OP_ACCEPT);
-
- messageFactory = ChannelProvider.provider().getMessageFactory();
-
- this.logger.info(String.format("ShellExecutor listening at %s",
- inetSocketAddress));
-
- this.started = true;
- new Thread(this).start();
- }
-
- public void stop() {
- this.started = false;
- }
-
- public LinksetExecutor getLinksetExecutor() {
- return linksetExecutor;
- }
-
- public void setLinksetExecutor(LinksetExecutor linksetExecutor) {
- this.linksetExecutor = linksetExecutor;
- }
-
- public M3UAShellExecutor getM3UAShellExecutor() {
- return m3UAShellExecutor;
- }
-
- public void setM3UAShellExecutor(M3UAShellExecutor shellExecutor) {
- m3UAShellExecutor = shellExecutor;
- }
-
- public void run() {
-
- while (started) {
- 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);
-
- if (key.isAcceptable()) {
- accept();
- } else if (key.isReadable()) {
- ShellChannel chan =
(ShellChannel) key.channel();
- Message msg = (Message)
chan.receive();
-
- if (msg != null) {
- rxMessage =
msg.toString();
- System.out.println("received
" + rxMessage);
- if
(rxMessage.compareTo("disconnect") == 0) {
- this.txMessage =
"Bye";
-
chan.send(messageFactory
-
.createMessage(txMessage));
-
- } else {
- String[] options =
rxMessage.split(" ");
- Subject subject
= Subject
-
.getSubject(options[0]);
- if (subject ==
null) {
-
chan.send(messageFactory
-
.createMessage("Invalid Subject"));
- } else {
- //
Nullify examined options
- //
options[0] = null;
-
- switch
(subject) {
- case
LINKSET:
-
if (this.linksetExecutor == null) {
-
this.txMessage = "Error! LinksetExecutor is null";
-
} else {
-
this.txMessage = this.linksetExecutor
-
.execute(options);
-
}
-
break;
- case
SCTP:
- case
M3UA:
-
if (this.m3UAShellExecutor == null) {
-
this.txMessage = "Error! M3UAShellExecutor is null";
-
} else {
-
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);
-
}
-
break;
- default:
-
this.txMessage = "Invalid Subject";
-
break;
- }
-
chan.send(messageFactory
-
.createMessage(this.txMessage));
- }
- } // if
(rxMessage.compareTo("disconnect")
- } // if (msg != null)
-
- // TODO Handle message
-
- rxMessage = "";
-
- } else if (key.isWritable() &&
txMessage.length() > 0) {
-
- if
(this.txMessage.compareTo("Bye") == 0) {
- this.closeChannel();
- }
-
- // else {
- //
- // ShellChannel chan =
(ShellChannel) key.channel();
- // System.out.println("Sending
" + txMessage);
- //
chan.send(messageFactory.createMessage(txMessage));
- // }
-
- this.txMessage = "";
- }
- }
- } catch (IOException e) {
- logger.error(
- "IO Exception while operating on ChannelSelectionKey. Client CLI
connection will be closed now",
- e);
- try {
- this.closeChannel();
- } catch (IOException e1) {
- logger.error("IO Exception while closing
Channel", e);
- }
- } catch (Exception e) {
- logger.error(
- "Exception while operating on ChannelSelectionKey. Client CLI
connection will be closed now",
- e);
- try {
- this.closeChannel();
- } catch (IOException e1) {
- logger.error("IO Exception while closing
Channel", e);
- }
- }
-
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- }
- }
-
- try {
- skey.cancel();
- if (channel != null) {
- channel.close();
- }
- serverChannel.close();
- selector.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- this.logger.info("Stopped ShellExecutor service");
- }
-
- private void accept() throws IOException {
- channel = serverChannel.accept();
- skey.cancel();
- skey = channel.register(selector, SelectionKey.OP_READ
- | SelectionKey.OP_WRITE);
- }
-
- private void closeChannel() throws IOException {
- if (channel != null) {
- try {
- this.channel.close();
- } catch (IOException e) {
- logger.error("Error closing channel", e);
- }
- }
- skey.cancel();
- skey = serverChannel.register(selector, SelectionKey.OP_ACCEPT);
- }
-
-}
=======================================
--- /core/oam/src/main/java/org/mobicents/ussdgateway/oam/Subject.java Tue
Jun 5 08:36:53 2012
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * 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.ussdgateway.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"),
-
- /**
- * USSD Subject. Any command to manage the USSD GW should begin with
ussd
- * subject
- */
- USSD("ussd");
-
- 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(USSD.getSubject())) {
- return USSD;
- }
- return null;
- }
-}
-
=======================================
--- /core/bootstrap/pom.xml Thu May 24 08:08:31 2012
+++ /core/bootstrap/pom.xml Sun Aug 19 03:15:28 2012
@@ -15,12 +15,11 @@
<dependencies>
<!-- USSD Dependency -->
- <!-- once some meat is added into oam, we will have to uncomment this
out -->
<dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>oam</artifactId>
- <version>${pom.version}</version>
- </dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-system-jmx</artifactId>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>${pom.groupId}</groupId>
@@ -86,11 +85,10 @@
<version>${ss7.version}</version>
</dependency>
- <!-- Clock -->
- <!-- Not really sure if clock is required for ussd gateway -->
+ <!-- Scheduler -->
<dependency>
- <groupId>org.mobicents.protocols.ss7.clock</groupId>
- <artifactId>clock</artifactId>
+ <artifactId>scheduler</artifactId>
+ <groupId>org.mobicents.protocols.ss7.scheduler</groupId>
<version>${ss7.version}</version>
</dependency>
@@ -105,7 +103,7 @@
<dependency>
<artifactId>linkset</artifactId>
<groupId>
- org.mobicents.protocols.ss7.management
+ org.mobicents.protocols.ss7.hardware
</groupId>
<version>${ss7.version}</version>
</dependency>
=======================================
--- /core/bootstrap/src/main/assembly/descriptor.xml Thu May 24 08:08:31
2012
+++ /core/bootstrap/src/main/assembly/descriptor.xml Sun Aug 19 03:15:28
2012
@@ -32,7 +32,6 @@
<includes>
<!-- USSD libraries -->
<include>org.mobicents.ussd:bootstrap</include>
- <include>org.mobicents.ussd:oam</include>
<include>org.mobicents.ussd:xml</include>
<!-- rules and domain library -->
@@ -49,6 +48,7 @@
<include>org.mobicents.protocols.asn:asn</include>
<!-- SS7 Libraries -->
+
<include>org.mobicents.protocols.ss7.scheduler:scheduler</include>
<include>org.mobicents.protocols.ss7.sccp:sccp-api</include>
<include>org.mobicents.protocols.ss7.sccp:sccp-impl</include>
<include>org.mobicents.protocols.ss7.isup:isup-api</include>
=======================================
--- /core/bootstrap/src/main/config/META-INF/jboss-beans.xml Thu May 24
08:08:31 2012
+++ /core/bootstrap/src/main/config/META-INF/jboss-beans.xml Sun Aug 19
03:15:28 2012
@@ -12,6 +12,12 @@
<property name="connectDelay">30000</property>
</bean>
+ <bean name="SCTPShellExecutor"
+
class="org.mobicents.protocols.ss7.m3ua.impl.oam.SCTPShellExecutor">
+ <property name="sctpManagement">
+ <inject bean="SCTPManagement" />
+ </property>
+ </bean>
<!-- ====================================================================
-->
<!-- M3UA -->
<!-- M3UAManagement is managing the m3ua side commands -->
@@ -33,11 +39,22 @@
<property name="m3uaManagement">
<inject bean="Mtp3UserPart" />
</property>
- <property name="sctpManagement">
- <inject bean="SCTPManagement" />
- </property>
</bean>
+
+ <!-- ====================================================================
-->
+ <!-- Scheduler -->
+ <!-- Scheduler for ss7 stack -->
+ <!-- ====================================================================
-->
+ <!-- -->
+ <bean name="SS7Clock"
class="org.mobicents.protocols.ss7.scheduler.DefaultClock">
+ </bean>
+ <bean name="SS7Scheduler"
class="org.mobicents.protocols.ss7.scheduler.Scheduler">
+ <property name="clock">
+ <inject bean="SS7Clock" />
+ </property>
+ </bean>
+
<!-- ====================================================================
-->
<!-- Dialogic Mtp3UserPart -->
<!-- ====================================================================
-->
@@ -103,22 +120,28 @@
<!-- Shell Service -->
<!-- ====================================================================
-->
<!-- Define Shell Executor -->
- <bean name="ShellExecutor"
class="org.mobicents.ussdgateway.oam.ShellExecutor">
+ <bean name="ShellExecutor"
class="org.mobicents.ss7.management.console.ShellServer">
+ <constructor>
+ <parameter>
+ <inject bean="SS7Scheduler" />
+ </parameter>
+ <parameter>
+ <list class="javolution.util.FastList"
elementClass="org.mobicents.ss7.management.console.ShellExecutor">
+ <inject bean="SccpExecutor" />
+ <inject bean="M3UAShellExecutor" />
+ <inject bean="SCTPShellExecutor" />
+ </list>
+ </parameter>
+ </constructor>
+
<property name="address">${jboss.bind.address}</property>
<property name="port">3435</property>
-
- <property name="sccpExecutor">
- <inject bean="SccpExecutor" />
- </property>
- <property name="m3UAShellExecutor">
- <inject bean="M3UAShellExecutor" />
- </property>
</bean>
<!-- ====================================================================
-->
<!-- Mobicents SS7 Service -->
<!-- ====================================================================
-->
- <bean name="SS7Service"
class="org.mobicents.applications.ussd.bootstrap.SS7Service">
+ <bean name="MAPSS7Service"
class="org.mobicents.applications.ussd.bootstrap.SS7Service">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="org.mobicents.ss7:service=SS7Service",exposedInterface=org.mobicents.applications.ussd.bootstrap.SS7ServiceMBean.class,registerDirectly=true)
</annotation>
<property name="jndiName">java:/mobicents/ss7/map</property>
=======================================
--- /core/pom.xml Wed May 23 04:00:49 2012
+++ /core/pom.xml Sun Aug 19 03:15:28 2012
@@ -17,7 +17,7 @@
<module>rules</module>
<module>domain</module>
<module>xml</module>
- <module>oam</module>
+ <module>oam/cli</module>
<module>slee</module>
<module>bootstrap</module>
</modules>