[jboss-cvs] JBossAS SVN: r88931 - in projects/fresh/trunk: fresh-shell/src/main/java/org/jboss/fresh/shell/commands and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri May 15 07:02:02 EDT 2009
Author: alesj
Date: 2009-05-15 07:02:02 -0400 (Fri, 15 May 2009)
New Revision: 88931
Added:
projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/VersionExe.java
Modified:
projects/fresh/trunk/fresh-jar/src/main/resources/META-INF/fresh-jboss-beans.xml
projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/ShellRuntime.java
projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/Version.java
Log:
Add version cmd.
Modified: projects/fresh/trunk/fresh-jar/src/main/resources/META-INF/fresh-jboss-beans.xml
===================================================================
--- projects/fresh/trunk/fresh-jar/src/main/resources/META-INF/fresh-jboss-beans.xml 2009-05-15 10:33:48 UTC (rev 88930)
+++ projects/fresh/trunk/fresh-jar/src/main/resources/META-INF/fresh-jboss-beans.xml 2009-05-15 11:02:02 UTC (rev 88931)
@@ -195,6 +195,9 @@
touch /bin/mcinvoke
setffld /bin/mcinvoke mime cp2-shell/executable
setattr /bin/mcinvoke Class org.jboss.fresh.shell.commands.MCBeanInvokeExe
+ touch /bin/version
+ setffld /bin/version mime cp2-shell/executable
+ setattr /bin/version Class org.jboss.fresh.shell.commands.VersionExe
touch /bin/alias
setffld /bin/alias mime cp2-shell/executable
setattr /bin/alias Class org.jboss.fresh.shell.commands.AliasExe
Copied: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/VersionExe.java (from rev 88929, projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/AliasExe.java)
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/VersionExe.java (rev 0)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/VersionExe.java 2009-05-15 11:02:02 UTC (rev 88931)
@@ -0,0 +1,21 @@
+package org.jboss.fresh.shell.commands;
+
+import org.jboss.fresh.io.BufferObjectWriter;
+import org.jboss.fresh.shell.AbstractExecutable;
+import org.jboss.fresh.shell.impl.Version;
+
+/**
+ * @author Ales Justin
+ */
+public class VersionExe extends AbstractExecutable
+{
+ /**
+ * Displays version information.
+ */
+ public void process(String exename, String[] params) throws Exception
+ {
+ BufferObjectWriter oout = new BufferObjectWriter(getStdOut());
+ oout.writeObject(Version.getDescription());
+ oout.close();
+ }
+}
\ No newline at end of file
Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/ShellRuntime.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/ShellRuntime.java 2009-05-15 10:33:48 UTC (rev 88930)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/ShellRuntime.java 2009-05-15 11:02:02 UTC (rev 88931)
@@ -1,5 +1,12 @@
package org.jboss.fresh.shell.impl;
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.TreeMap;
+
import org.apache.log4j.Logger;
import org.jboss.fresh.ctx.FlatContext;
import org.jboss.fresh.io.Buffer;
@@ -12,10 +19,7 @@
import org.jboss.fresh.vfs.FileName;
import org.jboss.fresh.vfs.VFSException;
-import java.io.PrintWriter;
-import java.util.*;
-
public class ShellRuntime {
private static final Logger log = Logger.getLogger(ShellRuntime.class);
public static final String PWD = "PWD";
@@ -64,7 +68,7 @@
shellout.put("init.rc returned an error: " + ex.toString() + " : " + (ex.getCause() == null ? "" : ex.getCause().toString()), 10000);
}
- shell.setEnvProperty("VERSION", org.jboss.fresh.shell.impl.Version.getVersion());
+ shell.setEnvProperty("VERSION", org.jboss.fresh.shell.impl.Version.getDescription());
} catch (Throwable t) {
log.error(t.getMessage(), t);
@@ -136,8 +140,10 @@
// will eventually be returned to the pool
//wout=new PrintWriter(new BufferedWriter(bwo));
- if (out == null) return;
- wout.println("JBoss FRESH");
+ if (out == null)
+ return;
+
+ wout.println(Version.getDescription());
wout.println("(c) JBoss");
}
Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/Version.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/Version.java 2009-05-15 10:33:48 UTC (rev 88930)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/Version.java 2009-05-15 11:02:02 UTC (rev 88931)
@@ -1,11 +1,28 @@
package org.jboss.fresh.shell.impl;
-public class Version {
+import org.jboss.fresh.shell.Shell;
+/**
+ * @author Ales Justin
+ */
+public class Version
+{
+ private static final String DEFAULT_VERSION = "1.0";
+ private static final String name = "JBoss Fresh";
+ private static String version;
- private static final String ver = "JBoss FreSH 1.0";
+ public static String getDescription()
+ {
+ return name + " " + getVersion();
+ }
- public static String getVersion() {
- return ver;
- }
+ public static String getVersion()
+ {
+ if (version == null)
+ {
+ Package pkg = Shell.class.getPackage();
+ return pkg != null ? pkg.getImplementationVersion() : DEFAULT_VERSION;
+ }
+ return version;
+ }
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list