Revision: 16130
Author: [email protected]
Date: Thu Dec 30 23:01:28 2010
Log: removed MessageListenerImpl
http://code.google.com/p/mobicents/source/detail?r=16130
Deleted:
/trunk/protocols/ss7/service/src/main/java/org/mobicents/ss7/LinksetListenerImpl.java
Modified:
/trunk/protocols/ss7/service/src/main/config/jboss-beans.xml
/trunk/protocols/ss7/service/src/main/java/org/mobicents/ss7/SS7Service.java
/trunk/protocols/ss7/service/src/main/java/org/mobicents/ss7/ShellExecutor.java
=======================================
---
/trunk/protocols/ss7/service/src/main/java/org/mobicents/ss7/LinksetListenerImpl.java
Thu Dec 30 02:51:30 2010
+++ /dev/null
@@ -1,88 +0,0 @@
-package org.mobicents.ss7;
-
-import org.apache.log4j.Logger;
-import org.mobicents.ss7.linkset.oam.LinkOAMMessages;
-import org.mobicents.ss7.linkset.oam.LinksetManager;
-import org.mobicents.ss7.management.console.LinksetListener;
-
-/**
- *
- * @author amit bhayani
- *
- */
-public class LinksetListenerImpl implements LinksetListener {
-
- private static final Logger logger = Logger
- .getLogger(LinksetListenerImpl.class);
-
- private LinksetManager linksetManager = null;
-
- protected LinksetListenerImpl(LinksetManager linksetManager) {
- this.linksetManager = linksetManager;
- }
-
- public String execute(String[] options) {
-
- try {
- // Atleast 1 option is passed?
- if (options == null || options.length < 2) {
- return LinkOAMMessages.INVALID_COMMAND;
- }
-
- String firstOption = options[1];
-
- if (firstOption == null) {
- return LinkOAMMessages.INVALID_COMMAND;
- }
-
- if(firstOption.compareTo("show") == 0){
- //Show
- return this.linksetManager.showLinkset(options);
- } else if (firstOption.compareTo("create") == 0) {
- // Create Linkset
- return this.linksetManager.createLinkset(options);
- } else if (firstOption.compareTo("delete") == 0) {
- // Delete Linkset
- return this.linksetManager.deleteLinkset(options);
-
- } else if (firstOption.compareTo("activate") == 0) {
- // noshutdown Linkset
- return this.linksetManager.activateLinkset(options);
-
- } else if (firstOption.compareTo("deactivate") == 0) {
- // shutdown Linkset
- return this.linksetManager.deactivateLinkset(options);
-
- } else if (firstOption.compareTo("link") == 0) {
- // Operation for Link
-
- // Check do we have more options
- if (options.length < 3) {
- return LinkOAMMessages.INVALID_COMMAND;
- }
-
- // Check if its create, delete, shutdown or noshutdown
- firstOption = options[2];
- if (firstOption == null) {
- return LinkOAMMessages.INVALID_COMMAND;
- }
-
- if (firstOption.compareTo("create") == 0) {
- return this.linksetManager.createLink(options);
- } else if (firstOption.compareTo("delete") == 0) {
- return this.linksetManager.deleteLink(options);
- } else if (firstOption.compareTo("deactivate") == 0) {
- return this.linksetManager.deactivateLink(options);
- } else if (firstOption.compareTo("activate") == 0) {
- return this.linksetManager.activateLink(options);
- }
- }
- } catch (Exception e) {
- logger.error("Error while executing command ", e);
- return e.toString();
- } catch (Throwable t){
- return t.toString();
- }
- return LinkOAMMessages.INVALID_COMMAND;
- }
-}
=======================================
--- /trunk/protocols/ss7/service/src/main/config/jboss-beans.xml Tue Dec 28
23:01:00 2010
+++ /trunk/protocols/ss7/service/src/main/config/jboss-beans.xml Thu Dec 30
23:01:28 2010
@@ -28,18 +28,19 @@
</property>
<property name="persistDir">${jboss.server.data.dir}</property>
</bean>
+
+ <bean name="ShellExecutor"
+ class="org.mobicents.ss7.ShellExecutor">
+ <property name="address">127.0.0.1</property>
+ <property name="port">3435</property>
+ </bean>
<!-- Mobicents SS7 service -->
<bean name="SS7Service" class="org.mobicents.ss7.SS7Service">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="org.mobicents.ss7:service=SS7Service",exposedInterface=org.mobicents.ss7.SS7ServiceMBean.class,registerDirectly=true)</annotation>
<property name="jndiName">java:/mobicents/ss7/sccp</property>
- <property name="configPath">
-
${catalina.home}/deploy/mobicents-ss7-service/sccp-routing.txt
- </property>
- <property name="shellAddress">${jboss.bind.address}</property>
- <property name="shellPort">3435</property>
- <property name="linksetManager">
- <inject bean="LinksetManager" />
- </property>
+ <property
name="configPath">${catalina.home}/deploy/mobicents-ss7-service/sccp-routing.txt</property>
+ <property name="linksetManager"><inject bean="LinksetManager"
/></property>
+ <property name="shellExecutor"><inject bean="ShellExecutor"
/></property>
</bean>
</deployment>
=======================================
---
/trunk/protocols/ss7/service/src/main/java/org/mobicents/ss7/SS7Service.java
Thu Dec 30 02:51:30 2010
+++
/trunk/protocols/ss7/service/src/main/java/org/mobicents/ss7/SS7Service.java
Thu Dec 30 23:01:28 2010
@@ -17,8 +17,6 @@
*/
package org.mobicents.ss7;
-import java.net.InetAddress;
-
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
@@ -29,6 +27,7 @@
import org.jboss.system.ServiceMBeanSupport;
import org.mobicents.protocols.ss7.sccp.impl.SccpStackImpl;
import org.mobicents.ss7.linkset.oam.Linkset;
+import org.mobicents.ss7.linkset.oam.LinksetExecutor;
import org.mobicents.ss7.linkset.oam.LinksetManager;
/**
@@ -37,7 +36,7 @@
*/
public class SS7Service extends ServiceMBeanSupport implements
SS7ServiceMBean {
- private ShellExecutor shell = null;
+ private ShellExecutor shellExecutor = null;
private LinksetManager linksetManager;
private SccpStackImpl sccpStack;
@@ -45,9 +44,6 @@
private String path;
private String jndiName;
- private String shellAddress = "127.0.0.1";
- private int shellPort = 3435;
-
private Logger logger = Logger.getLogger(SS7Service.class);
@Override
@@ -57,12 +53,13 @@
sccpStack = new SccpStackImpl();
sccpStack.setConfigPath(path);
-
+
FastMap<String, Linkset> map = this.linksetManager.getLinksets();
- for (FastMap.Entry<String, Linkset> e = map.head(), end =
map.tail(); (e = e.getNext()) != end;) {
- Linkset value = e.getValue();
- ((SccpStackImpl)sccpStack).add(value);
- }
+ for (FastMap.Entry<String, Linkset> e = map.head(), end =
map.tail(); (e = e
+ .getNext()) != end;) {
+ Linkset value = e.getValue();
+ ((SccpStackImpl) sccpStack).add(value);
+ }
// sccpStack.setLinksets(linksets);
sccpStack.start();
@@ -71,31 +68,15 @@
logger.info("SCCP stack Started. SccpProvider bound to "
+ this.jndiName);
- logger.info("Starting SS7 management shell environment");
- shell = new ShellExecutor(InetAddress.getByName(this.shellAddress),
- this.shellPort);
- shell.setLinksetManager(this.linksetManager);
- shell.start();
-
+ if (this.shellExecutor != null) {
+ LinksetExecutor linksetExec = new LinksetExecutor();
+ linksetExec.setLinksetManager(this.linksetManager);
+ this.shellExecutor.setLinksetExecutor(linksetExec);
+ this.shellExecutor.startService();
+ }
logger.info("Started SS7 service");
}
-
- public String getShellAddress() {
- return shellAddress;
- }
-
- public void setShellAddress(String shellAddress) {
- this.shellAddress = shellAddress;
- }
-
- public int getShellPort() {
- return shellPort;
- }
-
- public void setShellPort(int shellPort) {
- this.shellPort = shellPort;
- }
public void setJndiName(String jndiName) {
this.jndiName = jndiName;
@@ -108,15 +89,25 @@
public void setConfigPath(String path) {
this.path = path;
}
-
+
+ public ShellExecutor getShellExecutor() {
+ return shellExecutor;
+ }
+
+ public void setShellExecutor(ShellExecutor shellExecutor) {
+ this.shellExecutor = shellExecutor;
+ }
+
@Override
public void stopService() {
try {
unbind(jndiName);
} catch (Exception e) {
- }
-
- shell.stop();
+
+ }
+ if (this.shellExecutor != null) {
+ this.shellExecutor.stopService();
+ }
logger.info("Stopped SS7 service");
}
=======================================
---
/trunk/protocols/ss7/service/src/main/java/org/mobicents/ss7/ShellExecutor.java
Thu Dec 30 02:51:30 2010
+++
/trunk/protocols/ss7/service/src/main/java/org/mobicents/ss7/ShellExecutor.java
Thu Dec 30 23:01:28 2010
@@ -19,14 +19,13 @@
package org.mobicents.ss7;
import java.io.IOException;
-import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.channels.SelectionKey;
import javolution.util.FastSet;
import org.apache.log4j.Logger;
-import org.mobicents.ss7.linkset.oam.LinksetManager;
+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;
@@ -55,13 +54,41 @@
private String rxMessage = "";
private String txMessage = "";
- private volatile LinksetManager linksetManager = null;
-
- private LinksetListenerImpl linksetListenerImpl = null;
-
- private volatile boolean started = false;
-
- public ShellExecutor(InetAddress address, int port) throws IOException
{
+ private volatile boolean started = false;
+
+ private String address;
+
+ private int port;
+
+ private volatile LinksetExecutor linksetExecutor = null;
+
+ public ShellExecutor() throws IOException {
+
+ }
+
+ 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() {
+
+ }
+
+ public void startService() throws IOException {
+
+ logger.info("Starting SS7 management shell environment");
provider = ChannelProvider.provider();
serverChannel = provider.openServerChannel();
InetSocketAddress inetSocketAddress = new
InetSocketAddress(address,
@@ -75,28 +102,24 @@
this.logger.info(String.format("ShellExecutor listening at %s",
inetSocketAddress));
- }
-
- public void start() {
- this.linksetListenerImpl = new
LinksetListenerImpl(this.linksetManager);
+
this.started = true;
new Thread(this).start();
}
-
+
public void stop() {
- this.started = false;
}
- protected LinksetManager getLinksetManager() {
- return linksetManager;
+ public void stopService() {
+ this.started = false;
}
- protected void setLinksetManager(LinksetManager linksetManager) {
- this.linksetManager = linksetManager;
+ public LinksetExecutor getLinksetExecutor() {
+ return linksetExecutor;
}
- public String getReceivedMessage() {
- return rxMessage;
+ public void setLinksetExecutor(LinksetExecutor linksetExecutor) {
+ this.linksetExecutor = linksetExecutor;
}
public void run() {
@@ -118,7 +141,7 @@
if (msg != null) {
rxMessage = msg.toString();
-
+ System.out.println("received "+ rxMessage);
if (rxMessage.compareTo("disconnect") == 0) {
this.txMessage = "Bye";
chan.send(messageFactory
@@ -137,7 +160,7 @@
switch (subject) {
case LINKSET:
- this.txMessage =
this.linksetListenerImpl
+ this.txMessage =
this.linksetExecutor
.execute(options);
chan.send(messageFactory
.createMessage(this.txMessage));