[jboss-cvs] JBossAS SVN: r88118 - in projects/fresh/trunk: fresh-jar/src/main/resources/META-INF and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri May 1 20:46:26 EDT 2009


Author: ctomc
Date: 2009-05-01 20:46:26 -0400 (Fri, 01 May 2009)
New Revision: 88118

Modified:
   projects/fresh/trunk/fresh-jar/src/main/resources/META-INF/fresh-jboss-beans.xml
   projects/fresh/trunk/fresh-shell/pom.xml
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/RootVFSService.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/AbstractInvokeExe.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/LsExe.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/MBeanInvokeExe.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/util/AntBuildExe.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/BeanFactoryExecutableRegistry.java
   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/SystemShellImpl.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/Version.java
   projects/fresh/trunk/pom.xml
Log:
refactoring, added dependancy to jboss-mc-aop-int

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-02 00:19:26 UTC (rev 88117)
+++ projects/fresh/trunk/fresh-jar/src/main/resources/META-INF/fresh-jboss-beans.xml	2009-05-02 00:46:26 UTC (rev 88118)
@@ -30,7 +30,6 @@
 
 
     <bean name="FreshRootVFSService" class="org.jboss.fresh.deployer.RootVFSService">
-        <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="FRESH:service=VFS.Root",exposedInterface=org.jboss.fresh.deployer.RootVFSServiceMBean.class)</annotation>
         <property name="JNDIName">java:/FRESH/VFS</property>
         <property name="automount">/=java:/FRESH/VFSMem</property>
         <depends>FreshVFSService</depends>

Modified: projects/fresh/trunk/fresh-shell/pom.xml
===================================================================
--- projects/fresh/trunk/fresh-shell/pom.xml	2009-05-02 00:19:26 UTC (rev 88117)
+++ projects/fresh/trunk/fresh-shell/pom.xml	2009-05-02 00:46:26 UTC (rev 88118)
@@ -39,6 +39,10 @@
         <groupId>org.jboss.microcontainer</groupId>
         <artifactId>jboss-kernel</artifactId>
       </dependency>
+      <dependency>
+        <groupId>org.jboss.microcontainer</groupId>
+        <artifactId>jboss-aop-mc-int</artifactId>
+      </dependency>
 
     <dependency>
       <groupId>junit</groupId>

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/RootVFSService.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/RootVFSService.java	2009-05-02 00:19:26 UTC (rev 88117)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/RootVFSService.java	2009-05-02 00:46:26 UTC (rev 88118)
@@ -6,6 +6,7 @@
 import org.jboss.fresh.vfs.RootVFS;
 import org.jboss.fresh.vfs.VFS;
 import org.jboss.fresh.vfs.impl.DefaultRootVFS;
+import org.jboss.aop.microcontainer.aspects.jmx.JMX;
 
 import java.util.Iterator;
 import java.util.Map;
@@ -17,9 +18,9 @@
  * @version $Revision: 3032 $
  * @modified $Author: strukelj $
  */
+ at JMX(name = "FRESH:service=VFS.Root", exposedInterface = RootVFSServiceMBean.class)
 public class RootVFSService extends RegistryNamingBinder implements RootVFSServiceMBean {
 
-
     private static Logger log = Logger.getLogger(RootVFSService.class);
     private RootVFS vfs;
     private Properties props;

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/AbstractInvokeExe.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/AbstractInvokeExe.java	2009-05-02 00:19:26 UTC (rev 88117)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/AbstractInvokeExe.java	2009-05-02 00:46:26 UTC (rev 88118)
@@ -15,7 +15,8 @@
 /**
  * @author ales.justin at jboss.org
  */
-public abstract class AbstractInvokeExe extends AbstractExecutable {
+public abstract class Abstra
+        ctInvokeExe extends AbstractExecutable {
     protected abstract Logger getLog();
 
     protected abstract String getCmd();

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/LsExe.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/LsExe.java	2009-05-02 00:19:26 UTC (rev 88117)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/LsExe.java	2009-05-02 00:46:26 UTC (rev 88118)
@@ -1,12 +1,12 @@
 package org.jboss.fresh.shell.commands;
 
-import org.jboss.fresh.vfs.FileInfo;
-import org.jboss.fresh.vfs.FileName;
-import org.jboss.fresh.vfs.VFS;
 import org.jboss.fresh.io.BufferObjectWriter;
 import org.jboss.fresh.io.BufferWriter;
 import org.jboss.fresh.shell.AbstractExecutable;
 import org.jboss.fresh.util.StringUtils;
+import org.jboss.fresh.vfs.FileInfo;
+import org.jboss.fresh.vfs.FileName;
+import org.jboss.fresh.vfs.VFS;
 
 import java.io.PrintWriter;
 import java.util.Iterator;
@@ -17,67 +17,66 @@
 // EX OK
 
 public class LsExe extends AbstractExecutable {
-	private static transient org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(LsExe.class);
+    private static transient org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(LsExe.class);
 
-	public static final String OUTPUT = "-out=";
-	public static final String OUTPUT_STRING = "string";
-	public static final String OUTPUT_FILENAME = "filename";
-	public static final String OUTPUT_FILEINFO = "fileinfo";
+    public static final String OUTPUT = "-out=";
+    public static final String OUTPUT_STRING = "string";
+    public static final String OUTPUT_FILENAME = "filename";
+    public static final String OUTPUT_FILEINFO = "fileinfo";
 
-	public static final String OPTION_LONG = "-l";
+    public static final String OPTION_LONG = "-l";
 
-	private static Integer pathLen = new Integer(34);
-	private static Integer modifiedLen = new Integer(16);
-	private static Integer typeLen = new Integer(5);
-	/*
-	private static Integer lenghtLen = new Integer(10);
-	private static Integer linkLen = new Integer(20);
-   */
+    private static Integer pathLen = new Integer(34);
+    private static Integer modifiedLen = new Integer(16);
+    private static Integer typeLen = new Integer(5);
+    /*
+     private static Integer lenghtLen = new Integer(10);
+     private static Integer linkLen = new Integer(20);
+    */
 
-	/**
-	 Displays the contents of the specified directory.
+    /**
+     * Displays the contents of the specified directory.
+     */
 
-	 */
+    public void process(String exename, String[] params) throws Exception {
+        log.debug("entered");
 
-	public void process(String exename, String[] params) throws Exception {
-		log.debug("entered");
+        if (helpRequested()) {
+            PrintWriter out = new PrintWriter(new BufferWriter(getStdOut()));
+            out.print("Usage: ls [--help] [-ex] [-out=OUTPUT] [-l] [--help]\n");
+            out.print("       OUTPUT = string | filename | fileinfo; String is default.\n");
+            out.print("       -l = long output; Makes difference only with -out=string.\n");
+            out.print("       --help = Prints this.\n");
+            out.close();
+            log.debug("done");
+            return;
+        }
 
-		if (helpRequested()) {
-			PrintWriter out = new PrintWriter(new BufferWriter(getStdOut()));
-			out.print("Usage: ls [--help] [-ex] [-out=OUTPUT] [-l] [--help]\n");
-			out.print("       OUTPUT = string | filename | fileinfo; String is default.\n");
-			out.print("       -l = long output; Makes difference only with -out=string.\n");
-			out.print("       --help = Prints this.\n");
-			out.close();
-			log.debug("done");
-			return;
-		}
+        BufferObjectWriter oout = new BufferObjectWriter(getStdOut());
+        VFS vfs = shell.getVFS();
 
-		BufferObjectWriter oout = new BufferObjectWriter(getStdOut());
-		VFS vfs = shell.getVFS();
+        FileName pwd = new FileName(shell.getEnvProperty("PWD"));
 
-		FileName pwd = new FileName(shell.getEnvProperty("PWD"));
+        String out = OUTPUT_STRING;
+        boolean output = false;        // was out param already processed
+        boolean longOut = false;
+        boolean rslvLinks = true;
+        // boolean help = false;
 
-		String out = OUTPUT_STRING;
-		boolean output = false;		// was out param already processed
-		boolean longOut = false;
-		boolean rslvLinks = true;
-		// boolean help = false;
+        List paths = new LinkedList();
 
-		List paths = new LinkedList();
+        for (int i = 0; i < params.length; i++) {
 
-		for (int i = 0; i < params.length; i++) {
+            String param = params[i];
 
-			String param = params[i];
+            if (!longOut && param.equals(OPTION_LONG))
+                longOut = true;
 
-			if (!longOut && param.equals(OPTION_LONG))
-				longOut = true;
+            else if (!output && param.startsWith(OUTPUT)) {
+                out = param.substring(OUTPUT.length());
+                output = true;
 
-			else if (!output && param.startsWith(OUTPUT)) {
-				out = param.substring(OUTPUT.length());
-				output = true;
-
-			}
+            }
 /*			 else if (param.equals(HELP)) {
 				help = true;
 				oout.writeObject("Usage: ls [--help] [-ex] [-out=OUTPUT] [-l] [--help]\n");
@@ -90,119 +89,119 @@
 
 			}
 */
-			else {
-				FileName path = new FileName(param);
-				if (path.isRelative())
-					path = pwd.absolutize(path);
+            else {
+                FileName path = new FileName(param);
+                if (path.isRelative())
+                    path = pwd.absolutize(path);
 
 //				path = vfs.resolve(shell.getUserCtx(), path, true);
-				paths.add(path);
-			}
-		}
+                paths.add(path);
+            }
+        }
 
-		// if no paths given, list working dir
-		if (paths.isEmpty())
-			paths.add(pwd);
+        // if no paths given, list working dir
+        if (paths.isEmpty())
+            paths.add(pwd);
 
 
-		// now we have all paths resolved and absolute in FileName form in the 'paths' list
-		//log.debug("Paths: " + paths);
+        // now we have all paths resolved and absolute in FileName form in the 'paths' list
+        //log.debug("Paths: " + paths);
 
 
-		List expPaths = new LinkedList();
-		Iterator it = paths.iterator();
-		while (it.hasNext()) {
-			FileName filename = (FileName) it.next();
-			List children = vfs.list(shell.getUserCtx(), filename, !rslvLinks);
-			//log.debug("Expanding children: " + children);
-			expPaths.addAll(children);
-		}
-		paths = expPaths;
+        List expPaths = new LinkedList();
+        Iterator it = paths.iterator();
+        while (it.hasNext()) {
+            FileName filename = (FileName) it.next();
+            List children = vfs.list(shell.getUserCtx(), filename, !rslvLinks);
+            //log.debug("Expanding children: " + children);
+            expPaths.addAll(children);
+        }
+        paths = expPaths;
 
-		//log.debug("Paths after expanding: " + paths);
+        //log.debug("Paths after expanding: " + paths);
 
-		//log.debug("long output = " +longOut);
-		//log.debug("output = " +out);
-		//log.debug("pwd = " +pwd);
-		//log.debug("paths = ");
-		//StringUtils.printCollection(paths);
+        //log.debug("long output = " +longOut);
+        //log.debug("output = " +out);
+        //log.debug("pwd = " +pwd);
+        //log.debug("paths = ");
+        //StringUtils.printCollection(paths);
 
-		List result = null;
-		if (out.equals(OUTPUT_STRING)) {
-			result = new LinkedList();
-			it = paths.iterator();
+        List result = null;
+        if (out.equals(OUTPUT_STRING)) {
+            result = new LinkedList();
+            it = paths.iterator();
 
-			while (it.hasNext()) {
-				FileInfo info = (FileInfo) it.next();
+            while (it.hasNext()) {
+                FileInfo info = (FileInfo) it.next();
 
-				if (longOut) {
-					List fields, lengths;
-					fields = new LinkedList();
-					lengths = new LinkedList();
+                if (longOut) {
+                    List fields, lengths;
+                    fields = new LinkedList();
+                    lengths = new LinkedList();
 
-					// field pathname
-					fields.add(info.getFileName().toString());
-					lengths.add(pathLen);
+                    // field pathname
+                    fields.add(info.getFileName().toString());
+                    lengths.add(pathLen);
 
-					// last modified
-					fields.add(info.isDirectory() ? "DIR" : info.isLink() ? "LINK" : "FILE");
-					lengths.add(typeLen);
+                    // last modified
+                    fields.add(info.isDirectory() ? "DIR" : info.isLink() ? "LINK" : "FILE");
+                    lengths.add(typeLen);
 
-					// modified
-					fields.add(info.getLastModified().toString());
-					lengths.add(modifiedLen);
+                    // modified
+                    fields.add(info.getLastModified().toString());
+                    lengths.add(modifiedLen);
 
 
-					if (info.isLink()) {
-						// link
-						fields.add(info.getTarget().toString());
-						lengths.add(new Integer(0));
+                    if (info.isLink()) {
+                        // link
+                        fields.add(info.getTarget().toString());
+                        lengths.add(new Integer(0));
 
-					} else {
-						// length
-						fields.add(new Long(info.getLength()).toString());
-						lengths.add(new Integer(0));
-					}
+                    } else {
+                        // length
+                        fields.add(new Long(info.getLength()).toString());
+                        lengths.add(new Integer(0));
+                    }
 
 //					System.out.println("Adding to results (1): " + StringUtils.row(fields, lengths)+"\n");
-					result.add(StringUtils.row(fields, lengths) + "\r\n");
+                    result.add(StringUtils.row(fields, lengths) + "\r\n");
 
-				} else {
+                } else {
 //					System.out.println("Adding to results (2) info: " + info);
 //					System.out.println("Adding to results (2) info.FileName: " + info.getFileName());
 //					System.out.println("Adding to results (2): " + info.getFileName().toString() + "\n");
-					result.add(info.getFileName().toString() + "\r\n");
-				}
-			}
+                    result.add(info.getFileName().toString() + "\r\n");
+                }
+            }
 
-		} else if (out.equals(OUTPUT_FILEINFO)) {
+        } else if (out.equals(OUTPUT_FILEINFO)) {
 //			System.out.println("Setting paths as result: " + paths);
-			result = paths;
+            result = paths;
 
-		} else if (out.equals(OUTPUT_FILENAME)) {
+        } else if (out.equals(OUTPUT_FILENAME)) {
 //			System.out.println("Iterating paths and replacing infos with names: " + paths);
-			result = new LinkedList();
-			it = paths.iterator();
+            result = new LinkedList();
+            it = paths.iterator();
 
-			while (it.hasNext()) {
-				FileInfo info = (FileInfo) it.next();
-				result.add(info.getFileName());
-			}
-		}
+            while (it.hasNext()) {
+                FileInfo info = (FileInfo) it.next();
+                result.add(info.getFileName());
+            }
+        }
 
-		it = result.iterator();
-		while (it.hasNext()) {
-			Object obj = it.next();
+        it = result.iterator();
+        while (it.hasNext()) {
+            Object obj = it.next();
 //			System.out.println("Writing to out: ");
 //			System.out.println(obj);
-			oout.writeObject(obj);
+            oout.writeObject(obj);
 
-		}
+        }
 
 
-		finish:
-		oout.close();
+        finish:
+        oout.close();
 
-		log.debug("done");
+        log.debug("done");
 	}
 }
\ No newline at end of file

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/MBeanInvokeExe.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/MBeanInvokeExe.java	2009-05-02 00:19:26 UTC (rev 88117)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/MBeanInvokeExe.java	2009-05-02 00:46:26 UTC (rev 88118)
@@ -12,6 +12,7 @@
 import org.apache.log4j.Logger;
 import org.jboss.fresh.io.BufferObjectWriter;
 
+
 public class MBeanInvokeExe extends AbstractInvokeExe {
 	private static transient org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(MBeanInvokeExe.class);
 

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/util/AntBuildExe.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/util/AntBuildExe.java	2009-05-02 00:19:26 UTC (rev 88117)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/util/AntBuildExe.java	2009-05-02 00:46:26 UTC (rev 88118)
@@ -4,6 +4,7 @@
 import org.jboss.fresh.io.BufferWriter;
 import org.jboss.fresh.io.PrintWriter2;
 import org.jboss.fresh.shell.AbstractExecutable;
+import org.jboss.beans.metadata.api.annotations.Inject;
 
 import java.io.BufferedReader;
 import java.io.BufferedWriter;
@@ -24,6 +25,7 @@
 
 	PrintWriter pout;
 
+    
 	public void throwException(String msg) throws Exception {
 		if (canThrowEx()) {
 			throw new Exception(msg);

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/BeanFactoryExecutableRegistry.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/BeanFactoryExecutableRegistry.java	2009-05-02 00:19:26 UTC (rev 88117)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/BeanFactoryExecutableRegistry.java	2009-05-02 00:46:26 UTC (rev 88118)
@@ -53,6 +53,7 @@
       if (factories == null)
          return null;
 
+
       BeanFactory factory = factories.get(command);
       if (factory != null)
       {

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-02 00:19:26 UTC (rev 88117)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/ShellRuntime.java	2009-05-02 00:46:26 UTC (rev 88118)
@@ -1,12 +1,5 @@
 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;
@@ -19,70 +12,72 @@
 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";
-	String pwd = "/";
+    public static final String PWD = "PWD";
+    String pwd = "/";
 
-	ShellImpl shell;
-	boolean interactive;
+    ShellImpl shell;
+    boolean interactive;
 
-	private PrintWriter wout;
-	private BufferWriter bwo;
-	private Buffer out;
+    private PrintWriter wout;
+    private BufferWriter bwo;
+    private Buffer out;
 
-	//private LinkedList pathNames = new LinkedList();
+    //private LinkedList pathNames = new LinkedList();
     private HashMap aliases = new HashMap();
 
-   private ExecutableRegistry registry = new DefaultExecutableRegistry();
+    private ExecutableRegistry registry = new DefaultExecutableRegistry();
 
     public ShellRuntime(ShellImpl shell, boolean interactive) {
-		this.shell = shell;
-		this.interactive = interactive;
-	}
+        this.shell = shell;
+        this.interactive = interactive;
+    }
 
-   public void setRegistry(ExecutableRegistry registry)
-   {
-      this.registry = registry;
-   }
+    public void setRegistry(ExecutableRegistry registry) {
+        this.registry = registry;
+    }
 
-   protected ExecutableRegistry getRegistry()
-   {
-      if (registry == null)
-         throw new IllegalArgumentException("Executable registry is null");
+    protected ExecutableRegistry getRegistry() {
+        if (registry == null)
+            throw new IllegalArgumentException("Executable registry is null");
 
-      return registry;
-   }
+        return registry;
+    }
 
-   public void init(Buffer shellout) {
-		try {
+    public void init(Buffer shellout) {
+        try {
 
-			// create new Cache Object implementation
-			//shell.setCache(new SimpleMemCache());
-			shell.setContext(new FlatContext());
-			try {
-				if(shell.getVFS().exists(null, new FileName("/etc/shell/init.rc"), true))
-					shell.executeAsObject("run /etc/shell/init.rc"); // NullInput In case no redirects specified of course
-			} catch(Exception ex) {
-				log.error("Error while executing 'run /etc/shell/init.rc'", ex);
-				if(shellout!=null) shellout.put("init.rc returned an error: " + ex.toString() + " : " + (ex.getCause()==null ? "" : ex.getCause().toString()), 10000 );
-			}
+            // create new Cache Object implementation
+            //shell.setCache(new SimpleMemCache());
+            shell.setContext(new FlatContext());
+            try {
+                if (shell.getVFS().exists(null, new FileName("/etc/shell/init.rc"), true))
+                    shell.executeAsObject("run /etc/shell/init.rc"); // NullInput In case no redirects specified of course
+            } catch (Exception ex) {
+                log.error("Error while executing 'run /etc/shell/init.rc'", ex);
+                if (shellout != null)
+                    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.getVersion());
 
-		} catch (Throwable t) {
-			log.error(t.getMessage(),t);
-			throw new RuntimeException("Init problems: " + t);
-		}
+        } catch (Throwable t) {
+            log.error(t.getMessage(), t);
+            throw new RuntimeException("Init problems: " + t);
+        }
 
-	}
+    }
 
-	// Never call this directly if you want to set PWD. Only ShellImpl calls this method within
-	// its _setPWD()
-	public void setPWD(String path) {
+    // Never call this directly if you want to set PWD. Only ShellImpl calls this method within
+    // its _setPWD()
+    public void setPWD(String path) {
 //log.debug("[ShellRuntime] setPWD: " + path);
-		pwd = path;
+        pwd = path;
 /*
 		try {
 			rebuildPath(shell.getEnvProperty("PATH"));
@@ -90,195 +85,188 @@
 			log.error(ex.getMessage(),ex);
 		}
 */
-	}
-/*
-	public void setEnvProperty(String name, String value) {
-//log.debug("[ShellRuntime] setEnvProperty: " + name + "  -  " + value);
-		if (name.equals("PATH")) {
-			rebuildPath(value);
-		}
+    }
 
-	}
+    /*
+        public void setEnvProperty(String name, String value) {
+    //log.debug("[ShellRuntime] setEnvProperty: " + name + "  -  " + value);
+            if (name.equals("PATH")) {
+                rebuildPath(value);
+            }
 
-	private void rebuildPath(String value) {
-//log.debug("[ShellRuntime] rebuildPath: " + value);
+        }
 
-		pathNames.clear();
-		if (value == null) return;
+        private void rebuildPath(String value) {
+    //log.debug("[ShellRuntime] rebuildPath: " + value);
 
-		FileName pwdnm = new FileName(pwd);
-		StringTokenizer t = new StringTokenizer(value, ":");
-		while (t.hasMoreTokens()) {
-			try {
-				FileName tk = new FileName(t.nextToken());
-				if (!tk.isAbsolute()) {
-					tk = pwdnm.absolutize(tk);
-				}
-				pathNames.add(tk);
-			} catch (Exception ex) {
-				log.error(ex.getMessage(),ex);
-			}
-		}
-	}
-*/
-	public String getPrompt() {
-		return "[" + pwd + "]";
-	}
+            pathNames.clear();
+            if (value == null) return;
 
-	public void setOutBuffer(Buffer out) {
-		this.out = out;
-		if (out == null) return;
-		bwo = new BufferWriter(out);
-		bwo.setTimeout(ShellImpl.PROC_INST_TIMEOUT);
-		wout = new PrintWriter(bwo, true);
-	}
+            FileName pwdnm = new FileName(pwd);
+            StringTokenizer t = new StringTokenizer(value, ":");
+            while (t.hasMoreTokens()) {
+                try {
+                    FileName tk = new FileName(t.nextToken());
+                    if (!tk.isAbsolute()) {
+                        tk = pwdnm.absolutize(tk);
+                    }
+                    pathNames.add(tk);
+                } catch (Exception ex) {
+                    log.error(ex.getMessage(),ex);
+                }
+            }
+        }
+    */
+    public String getPrompt() {
+        return "[" + pwd + "]";
+    }
 
-	public void started() {
+    public void setOutBuffer(Buffer out) {
+        this.out = out;
+        if (out == null) return;
+        bwo = new BufferWriter(out);
+        bwo.setTimeout(ShellImpl.PROC_INST_TIMEOUT);
+        wout = new PrintWriter(bwo, true);
+    }
 
-		// set the timeout so if client disconnects before reading from this buffer
-		// the thread running the process that we use to output shell messages
-		// will eventually be returned to the pool
-		//wout=new PrintWriter(new BufferedWriter(bwo));
+    public void started() {
 
-		if (out == null) return;
-		wout.println("Parsek Cp2 Shell");
-		wout.println("(c) Parsek");
-	}
+        // set the timeout so if client disconnects before reading from this buffer
+        // the thread running the process that we use to output shell messages
+        // will eventually be returned to the pool
+        //wout=new PrintWriter(new BufferedWriter(bwo));
 
-	public void prompt() {
+        if (out == null) return;
+        wout.println("JBoss FRESH");
+        wout.println("(c) JBoss");
+    }
+
+    public void prompt() {
 //new Exception("ShellRuntime: writting PROMPT to shell out.").printStackTrace();
-		if (out == null) return;
-		wout.println();
-		wout.print(getPrompt());
-		wout.flush();
-	}
+        if (out == null) return;
+        wout.println();
+        wout.print(getPrompt());
+        wout.flush();
+    }
 
-	public Executable loadExe(String command) throws ShellException {
+    public Executable loadExe(String command) throws ShellException {
 
-		FileInfo inf = null;
-		try {
+        FileInfo inf = null;
+        try {
 //log.debug("[ShellRuntime] Resolving filename to class");
 
-			FileName cmdnm = new FileName(command);
-			if (!cmdnm.isAbsolute()) {
-				
-				
-				
-				String path = getPATH();
+            FileName cmdnm = new FileName(command);
+            if (!cmdnm.isAbsolute()) {
 
-				FileName pwdnm = new FileName(pwd);
-				StringTokenizer t = new StringTokenizer(path, ":");
-				while (t.hasMoreTokens()) {
-					try {
-						FileName dir = new FileName(t.nextToken());
-						if (!dir.isAbsolute()) {
-							dir = pwdnm.absolutize(dir);
-						}
 
+                String path = getPATH();
 
-						FileName full = dir.absolutize(cmdnm);
+                FileName pwdnm = new FileName(pwd);
+                StringTokenizer t = new StringTokenizer(path, ":");
+                while (t.hasMoreTokens()) {
+                    try {
+                        FileName dir = new FileName(t.nextToken());
+                        if (!dir.isAbsolute()) {
+                            dir = pwdnm.absolutize(dir);
+                        }
+
+
+                        FileName full = dir.absolutize(cmdnm);
 //						log.debug("[ShellRuntime] trying: " + full);
-											inf = shell.getVFS().getFileInfo(shell.getUserCtx(), full, false);
-											if (inf != null) { // got it!
+                        inf = shell.getVFS().getFileInfo(shell.getUserCtx(), full, false);
+                        if (inf != null) { // got it!
 //						log.debug("[ShellRuntime] found file!");
-												break;
-											}
-						
-						
-						
-					} catch (Exception ex) {
-						log.error(ex.getMessage(),ex);
-					}
-				}
+                            break;
+                        }
 
-				
-				
-				
-				
-			} else {
-//log.debug("[ShellRuntime] trying.: " + cmdnm);
-				inf = shell.getVFS().getFileInfo(shell.getUserCtx(), cmdnm, false);
-			}
 
-			if (inf != null) {
-//log.debug("[ShellRuntime] checking mime.");
-				if (inf.getMime() == null || !inf.getMime().equals("cp2-shell/executable")) throw new ShellException("Mime type mismatch. Mime is " + inf.getMime() + ". Should be cp2-shell/executable. (" + command + ")");
-//log.debug("[ShellRuntime] checking Class.");
-				String clazz = (String) inf.getAttributes().get("Class");
-				if (clazz == null) throw new ShellException("No Class attribute specified. (" + command + ")");
-//log.debug("[ShellRuntime] SUCCESS");
-				command = clazz;
-			}
+                    } catch (Exception ex) {
+                        log.error(ex.getMessage(), ex);
+                    }
+                }
 
 
-			Executable exe = getInternal(command);
-			if (exe != null) return exe;
+            } else {
+                inf = shell.getVFS().getFileInfo(shell.getUserCtx(), cmdnm, false);
+            }
 
-		} catch (ShellException ex) {
+            if (inf != null) {
+                if (inf.getMime() == null || !inf.getMime().equals("cp2-shell/executable"))
+                    throw new ShellException("Mime type mismatch. Mime is " + inf.getMime() + ". Should be cp2-shell/executable. (" + command + ")");
+                String clazz = (String) inf.getAttributes().get("Class");
+                if (clazz == null) throw new ShellException("No Class attribute specified. (" + command + ")");
+                command = clazz;
+            }
 
-			log.error(ex.getMessage(),ex);
 
-			Executable exe = getInternal(command);
-			if (exe != null) return exe;
+            Executable exe = getInternal(command);
+            if (exe != null) return exe;
 
-			throw ex;
+        } catch (ShellException ex) {
 
-		} catch (VFSException ex) {
-			log.error(ex.getMessage(),ex);
-			throw new ShellException(ex.toString());
-		}
-		ClassLoader cl = Thread.currentThread().getContextClassLoader();
-		Class execls = null;
-		try {
-			execls = cl.loadClass(command);
-		} catch (ClassNotFoundException e) {
-			throw new BadCommandException("Unknown command.", command);
-		}
+            log.error(ex.getMessage(), ex);
 
-		Executable exe;
-		try {
-			exe = (Executable) execls.newInstance();
-		} catch (InstantiationException e) {
-			throw new ShellException("Could not instantiate class: " + execls);
-		} catch (IllegalAccessException e) {
-			throw new ShellException("Not allowed to instantiate class: " + execls);
-		}
+            Executable exe = getInternal(command);
+            if (exe != null) return exe;
 
-		exe.setFileInfo(inf);
+            throw ex;
 
-		return exe;
-	}
+        } catch (VFSException ex) {
+            log.error(ex.getMessage(), ex);
+            throw new ShellException(ex.toString());
+        }
+        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+        Class execls = null;
+        try {
+            execls = cl.loadClass(command);
+        } catch (ClassNotFoundException e) {
+            throw new BadCommandException("Unknown command.", command);
+        }
 
+        Executable exe;
+        try {
+            exe = (Executable) execls.newInstance();
+        } catch (InstantiationException e) {
+            throw new ShellException("Could not instantiate class: " + execls);
+        } catch (IllegalAccessException e) {
+            throw new ShellException("Not allowed to instantiate class: " + execls);
+        }
 
-	private String getPATH() throws ShellException {
-		String ret;
-		
-		Process p  = Process.getThreadParent();
-		if(p != null) {
-			ret = p.getEnv().getEnvProperty("PATH");
-		} else {
-			ret = shell.getEnv().getEnvProperty("PATH");
-		}
-		
-		if(ret == null)
-			ret = "";
-		
-		return ret;
-	}
+        exe.setFileInfo(inf);
 
-	protected Executable getInternal(String command) {
-      return getRegistry().getExecutable(command);
-	}
+        return exe;
+    }
 
+
+    private String getPATH() throws ShellException {
+        String ret;
+
+        Process p = Process.getThreadParent();
+        if (p != null) {
+            ret = p.getEnv().getEnvProperty("PATH");
+        } else {
+            ret = shell.getEnv().getEnvProperty("PATH");
+        }
+
+        if (ret == null)
+            ret = "";
+
+        return ret;
+    }
+
+    protected Executable getInternal(String command) {
+        return getRegistry().getExecutable(command);
+    }
+
     public String unaliasCmdLine(String cmdline) {
 
         // break cmdline by |
         StringBuilder b = new StringBuilder();
         StringTokenizer tkzr = new StringTokenizer(cmdline, "|", true);
-        while(tkzr.hasMoreTokens()) {
+        while (tkzr.hasMoreTokens()) {
             String tk = tkzr.nextToken();
 
-            if(tk.equals("|")) {
+            if (tk.equals("|")) {
                 b.append(tk);
                 continue;
             }
@@ -288,26 +276,26 @@
             int start = 0;
             int end = tk.length();
 
-            for(int i=start; i<end && tk.charAt(i) == ' '; i++, start++);
+            for (int i = start; i < end && tk.charAt(i) == ' '; i++, start++) ;
 
-            int sp = tk.indexOf(" ", start+1);
-            if(sp != -1)
+            int sp = tk.indexOf(" ", start + 1);
+            if (sp != -1)
                 end = sp;
 
-            sp = tk.indexOf("&", start+1);
-            if(sp != -1 && sp<end)
+            sp = tk.indexOf("&", start + 1);
+            if (sp != -1 && sp < end)
                 end = sp;
 
-            sp = tk.indexOf(".", start+1);
-            if(sp != -1 && sp<end)
+            sp = tk.indexOf(".", start + 1);
+            if (sp != -1 && sp < end)
                 end = sp;
 
-            sp = tk.indexOf("<", start+1);
-            if(sp != -1 && sp<end)
+            sp = tk.indexOf("<", start + 1);
+            if (sp != -1 && sp < end)
                 end = sp;
 
-            sp = tk.indexOf(">", start+1);
-            if(sp != -1 && sp<end)
+            sp = tk.indexOf(">", start + 1);
+            if (sp != -1 && sp < end)
                 end = sp;
 
             b.append(tk.substring(0, start))
@@ -320,9 +308,9 @@
 
     public String unalias(String cmd) {
         Iterator it = aliases.entrySet().iterator();
-        while(it.hasNext()) {
-            Map.Entry ent = (Map.Entry)it.next();
-            if(ent.getKey().equals(cmd)) {
+        while (it.hasNext()) {
+            Map.Entry ent = (Map.Entry) it.next();
+            if (ent.getKey().equals(cmd)) {
                 return (String) ent.getValue();
             }
         }
@@ -339,6 +327,6 @@
     }
 
     public Map listAliases() {
-            return new TreeMap(aliases);
+        return new TreeMap(aliases);
     }
 }
\ No newline at end of file

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/SystemShellImpl.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/SystemShellImpl.java	2009-05-02 00:19:26 UTC (rev 88117)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/SystemShellImpl.java	2009-05-02 00:46:26 UTC (rev 88118)
@@ -20,9 +20,9 @@
 import org.jboss.fresh.shell.SystemShell;
 import org.jboss.fresh.vfs.UserCtx;
 import org.jboss.fresh.vfs.VFS;
+import org.jboss.beans.metadata.api.annotations.Inject;
 
-//import org.jboss.pool.ObjectPool;
-
+/**
 // This class is a server. It has a set of Shell instances.
 // These instances have to timeout if inactive.
 // Like jboss does with sessions we could persist the inactive ones out of memory.
@@ -30,9 +30,8 @@
 // We can also time them out ... we could specify a pretty high timeout ...
 // When they timeout we kill the processes and remove the Shell objects.
 // Since we need to be able to do an id based lookup, we will contain them in HashMap
-// where key will be an Integer object - could be a String really.
-// Indeed - adapt it all to take a string.
 
+ */
 public class SystemShellImpl implements SystemShell {
 	private static org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(SystemShellImpl.class);
 
@@ -45,6 +44,7 @@
 
    private ExecutableRegistry registry;
 
+    
 //	GCThread gc;
 	Timer gc;
 	long gcPeriod = 10000L;

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-02 00:19:26 UTC (rev 88117)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/Version.java	2009-05-02 00:46:26 UTC (rev 88118)
@@ -3,7 +3,7 @@
 public class Version {
 
 
-    private static final String ver = "cp2.jar, 2.0 alpha";
+    private static final String ver = "JBoss FreSH 1.0";
 
     public static String getVersion() {
         return ver;

Modified: projects/fresh/trunk/pom.xml
===================================================================
--- projects/fresh/trunk/pom.xml	2009-05-02 00:19:26 UTC (rev 88117)
+++ projects/fresh/trunk/pom.xml	2009-05-02 00:46:26 UTC (rev 88118)
@@ -248,6 +248,12 @@
         <version>${version.jboss.microcontainer}</version>
       </dependency>
       <dependency>
+        <groupId>org.jboss.microcontainer</groupId>
+        <artifactId>jboss-aop-mc-int</artifactId>
+        <version>${version.jboss.microcontainer}</version>
+      </dependency>
+
+      <dependency>
         <groupId>org.jboss</groupId>
         <artifactId>jboss-common-core</artifactId>
         <version>${version.jboss.common.core}</version>




More information about the jboss-cvs-commits mailing list