Revision: 16036
Author: [email protected]
Date: Fri Dec 24 00:24:26 2010
Log: [No log message]
http://code.google.com/p/mobicents/source/detail?r=16036

Added:
/trunk/protocols/ss7/management/shell/src/main/java/org/mobicents/protocols/ss7/management/console/Version.java /trunk/protocols/ss7/management/shell/src/main/resources/org/mobicents/protocols/ss7/management/console
Deleted:
/trunk/protocols/ss7/management/shell/src/main/java/org/mobicents/protocols/ss7/management/shell/Version.java /trunk/protocols/ss7/management/shell/src/main/resources/org/mobicents/protocols/ss7/management/shell
Modified:
 /trunk/protocols/ss7/management/shell/src/main/config/ss7-run.bat
 /trunk/protocols/ss7/management/shell/src/main/config/ss7-run.sh
/trunk/protocols/ss7/management/shell/src/main/java/org/mobicents/protocols/ss7/management/console/Shell.java /trunk/protocols/ss7/management/shell/src/main/java/org/mobicents/protocols/ss7/management/shell/Shell.java /trunk/protocols/ss7/management/shell/src/test/java/org/mobicents/ss7/management/transceiver/ShellTransceiverTest.java

=======================================
--- /dev/null
+++ /trunk/protocols/ss7/management/shell/src/main/java/org/mobicents/protocols/ss7/management/console/Version.java Fri Dec 24 00:24:26 2010
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright XXXX, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.mobicents.protocols.ss7.management.console;
+
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Version class reads the version.properties packaged with cli.jar for
+ * run time display of Version
+ *
+ * @author amit.bhayani
+ *
+ */
+public final class Version {
+
+       /**
+        * The single instance.
+        */
+       public final static Version instance = new Version();
+
+       /**
+        * The version properties.
+        */
+       private Properties props;
+
+       /**
+        * Do not allow direct public construction.
+        */
+       private Version() {
+               props = loadProperties();
+       }
+
+       /**
+        * Returns an unmodifiable map of version properties.
+        *
+        * @return
+        */
+       public Map getProperties() {
+               return Collections.unmodifiableMap(props);
+       }
+
+       /**
+        * Returns the value for the given property name.
+        *
+        * @param name -
+        *            The name of the property.
+        * @return The property value or null if the property is not set.
+        */
+       public String getProperty(final String name) {
+               return props.getProperty(name);
+       }
+
+       /**
+        * Returns the version information as a string.
+        *
+        * @return Basic information as a string.
+        */
+       public String toString() {
+               StringBuilder sb = new StringBuilder("Mobicents SS7: ");
+               boolean first = true;
+               for (Object key : props.keySet()) {
+                       if (first) {
+                               first = false;
+                       } else {
+                               sb.append(",");
+                       }
+                       sb.append(key).append('=').append(props.get(key));
+               }
+               return sb.toString();
+       }
+
+       /**
+        * Load the version properties from a resource.
+        */
+       private Properties loadProperties() {
+
+               props = new Properties();
+
+               try {
+                       InputStream in = Version.class
+                                       
.getResourceAsStream("version.properties");
+                       props.load(in);
+                       in.close();
+               } catch (Exception e) {
+                       throw new Error("Missing version.properties");
+               }
+
+               return props;
+       }
+
+}
=======================================
--- /trunk/protocols/ss7/management/shell/src/main/java/org/mobicents/protocols/ss7/management/shell/Version.java Sun Dec 12 22:46:45 2010
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright XXXX, Red Hat Middleware LLC, and individual contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a full listing
- * of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU General Public License, v. 2.0.
- * This program is distributed in the hope that it will be useful, but WITHOUT A - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License,
- * v. 2.0 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.mobicents.protocols.ss7.management.shell;
-
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * Version class reads the version.properties packaged with cli.jar for
- * run time display of Version
- *
- * @author amit.bhayani
- *
- */
-public final class Version {
-
-       /**
-        * The single instance.
-        */
-       public final static Version instance = new Version();
-
-       /**
-        * The version properties.
-        */
-       private Properties props;
-
-       /**
-        * Do not allow direct public construction.
-        */
-       private Version() {
-               props = loadProperties();
-       }
-
-       /**
-        * Returns an unmodifiable map of version properties.
-        *
-        * @return
-        */
-       public Map getProperties() {
-               return Collections.unmodifiableMap(props);
-       }
-
-       /**
-        * Returns the value for the given property name.
-        *
-        * @param name -
-        *            The name of the property.
-        * @return The property value or null if the property is not set.
-        */
-       public String getProperty(final String name) {
-               return props.getProperty(name);
-       }
-
-       /**
-        * Returns the version information as a string.
-        *
-        * @return Basic information as a string.
-        */
-       public String toString() {
-               StringBuilder sb = new StringBuilder("Mobicents SS7: ");
-               boolean first = true;
-               for (Object key : props.keySet()) {
-                       if (first) {
-                               first = false;
-                       } else {
-                               sb.append(",");
-                       }
-                       sb.append(key).append('=').append(props.get(key));
-               }
-               return sb.toString();
-       }
-
-       /**
-        * Load the version properties from a resource.
-        */
-       private Properties loadProperties() {
-
-               props = new Properties();
-
-               try {
-                       InputStream in = Version.class
-                                       
.getResourceAsStream("version.properties");
-                       props.load(in);
-                       in.close();
-               } catch (Exception e) {
-                       throw new Error("Missing version.properties");
-               }
-
-               return props;
-       }
-
-}
=======================================
--- /trunk/protocols/ss7/management/shell/src/main/config/ss7-run.bat Tue Dec 21 23:59:35 2010 +++ /trunk/protocols/ss7/management/shell/src/main/config/ss7-run.bat Fri Dec 24 00:24:26 2010
@@ -136,7 +136,7 @@
 echo.

 :RESTART
-"%JAVA%" %JAVA_OPTS% -Djava.ext.dirs="%SHELL_ENDORSED_DIRS%" -classpath "%SHELL_CLASSPATH%" org.mobicents.protocols.ss7.management.shell.Shell %* +"%JAVA%" %JAVA_OPTS% -Djava.ext.dirs="%SHELL_ENDORSED_DIRS%" -classpath "%SHELL_CLASSPATH%" org.mobicents.protocols.ss7.management.console.Shell %*
 rem if ERRORLEVEL 10 goto RESTART

 :END
=======================================
--- /trunk/protocols/ss7/management/shell/src/main/config/ss7-run.sh Tue Dec 21 23:59:35 2010 +++ /trunk/protocols/ss7/management/shell/src/main/config/ss7-run.sh Fri Dec 24 00:24:26 2010
@@ -165,7 +165,7 @@
          -Djava.ext.dirs="$SHELL_ENDORSED_DIRS" \
          -Dmbrola.base="$SHELL_HOME/mbrola" \
          -classpath "$SHELL_CLASSPATH" \
-         org.mobicents.protocols.ss7.management.shell.Shell "$@"
+         org.mobicents.protocols.ss7.management.console.Shell "$@"
       SHELL_STATUS=$?

#java -Djava.ext.dirs=`pwd`/lib -Dmms.home=. -cp .:mms-standalone-2.0.0.BETA1-SNAPSHOT.jar org.mobicents.media.server.bootstrap.jmx.JMXMain
=======================================
--- /trunk/protocols/ss7/management/shell/src/main/java/org/mobicents/protocols/ss7/management/console/Shell.java Thu Dec 23 23:04:08 2010 +++ /trunk/protocols/ss7/management/shell/src/main/java/org/mobicents/protocols/ss7/management/console/Shell.java Fri Dec 24 00:24:26 2010
@@ -2,22 +2,60 @@

 public class Shell {

+    Version version = Version.instance;
+
+    public final String WELCOME_MESSAGE = version.toString()
+            + "\n"
+ + "This is free software, with components licensed under the GNU General Public License\n" + + "version 2 and other licenses. For further details visit http://mobicents.org\n"; + + "=========================================================================";
+
+ public static final String CONNECTED_MESSAGE = "Connected to %s currently running on %s";
+
+    public static final String cliPrefix = "Mobicents-SS7*CLI>";
+
     private final ConsoleListener listener;
     private final Console console;

+    private void showCliHelp() {
+        System.out.println(version.toString());
+        System.out.println("Usage: SS7 [OPTIONS]");
+        System.out.println("Valid Options");
+        System.out.println("-v           Display version number and exit");
+        System.out.println("-h           This help screen");
+    }
+
     public Shell() {
         listener = new ConsoleListenerImpl();
         console = new Console(System.in, System.out, listener);
     }

     public static void main(String args[]) {
-        // TODO : Oleg what about command line arguments?
         Shell shell = new Shell();
-        shell.start();
-
+        shell.start(args);
     }

-    private void start() {
+    private void start(String args[]) {
+
+        // Take care of Cmd Line arguments
+        if (args != null && args.length > 0) {
+
+            String cmd = args[0];
+
+            if (cmd.compareTo("-v") == 0) {
+                System.out.println(version.toString());
+                System.exit(0);
+            }
+
+            if (cmd.compareTo("-h") == 0) {
+                this.showCliHelp();
+                System.exit(0);
+            }
+
+        }
+
+        System.out.println(WELCOME_MESSAGE);
+
         console.start();
     }

=======================================
--- /trunk/protocols/ss7/management/shell/src/main/java/org/mobicents/protocols/ss7/management/shell/Shell.java Mon Dec 20 06:53:54 2010 +++ /trunk/protocols/ss7/management/shell/src/main/java/org/mobicents/protocols/ss7/management/shell/Shell.java Fri Dec 24 00:24:26 2010
@@ -25,6 +25,8 @@
 import java.util.Iterator;
 import java.util.Scanner;

+import org.mobicents.protocols.ss7.management.console.Version;
+
 /**
  *
  * @author amit bhayani
=======================================
--- /trunk/protocols/ss7/management/shell/src/test/java/org/mobicents/ss7/management/transceiver/ShellTransceiverTest.java Thu Dec 23 22:24:29 2010 +++ /trunk/protocols/ss7/management/shell/src/test/java/org/mobicents/ss7/management/transceiver/ShellTransceiverTest.java Fri Dec 24 00:24:26 2010
@@ -246,6 +246,5 @@
                 e.printStackTrace();
             }
         }
-
     }
 }

Reply via email to