[jboss-cvs] JBossAS SVN: r88172 - in projects/fresh/trunk: fresh-shell/src/main/java/org/jboss/fresh/deployer and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon May 4 17:57:04 EDT 2009


Author: ctomc
Date: 2009-05-04 17:57:03 -0400 (Mon, 04 May 2009)
New Revision: 88172

Removed:
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/LazySystemShellService.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/LazySystemShellServiceMBean.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/SystemShellService.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/SystemShellServiceMBean.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/deployer/PoolService.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/PoolServiceMBean.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/RegistryNamingBinder.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/impl/LazySystemShellImpl.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/Process.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/ProcessGroup.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/SystemShellImpl.java
Log:
FRESH-5 FRESH-6

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-04 21:52:50 UTC (rev 88171)
+++ projects/fresh/trunk/fresh-jar/src/main/resources/META-INF/fresh-jboss-beans.xml	2009-05-04 21:57:03 UTC (rev 88172)
@@ -1,12 +1,30 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <deployment xmlns="urn:jboss:bean-deployer:2.0">
+    
+   <lifecycle-configure xmlns="urn:jboss:aop-beans:1.0" name="DependencyAdvice"
+ 	      class="org.jboss.aop.microcontainer.aspects.jndi.JndiLifecycleCallback"
+ 	      classes="@org.jboss.aop.microcontainer.aspects.jndi.JndiBinding">
+ 	      <property name="env">
+	           <map class="java.util.Properties" keyClass="java.lang.String" valueClass="java.lang.String">
+	              <entry>
+ 	                 <key>java.naming.factory.initial</key>
+ 	                 <value>org.jnp.interfaces.NamingContextFactory</value>
+	               </entry>
+	              <entry>
+	                 <key>java.naming.factory.url.pkgs</key>
+	                 <value>org.jboss.naming:org.jnp.interfaces</value>
+ 	               </entry>
+	           </map>
+	      </property>
+ 	   </lifecycle-configure>
 
+
   <bean name="FreshSSHServer" class="org.jboss.fresh.deployer.SSHService">
       <depends>FreshSystemShell</depends>
   </bean>
 
-  <bean name="FreshSystemShell" class="org.jboss.fresh.deployer.LazySystemShellService" >
-      <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="FRESH:service=SystemShell",exposedInterface=org.jboss.fresh.deployer.LazySystemShellServiceMBean.class)</annotation>
+  <bean name="FreshSystemShell" class="org.jboss.fresh.shell.impl.LazySystemShellImpl" >
+      <!--annotation>@org.jboss.aop.microcontainer.aspects.jndi.JndiBinding(name = "java:/FRESH/SystemShell")</annotation-->
       <constructor>
         <parameter><inject bean="jboss.kernel:service=KernelController"/></parameter>
         <parameter>
@@ -15,7 +33,7 @@
             but we need to get off JNDI first in order to make it proper.             
           -->
           <list elementClass="java.lang.String">
-            <value>FreshPoolService</value>
+            <!--value>FreshPoolService</value-->
             <value>FreshVFSService</value>
             <value>FreshRootVFSService</value>
             <value>FreshVFSInit</value>
@@ -24,11 +42,15 @@
             <value>FreshContextBinder</value>
           </list>
         </parameter>
+        <parameter>java:/FRESH/VFS</parameter>
       </constructor>
       <property name="JNDIName">java:/FRESH/SystemShell</property>
-      <property name="threadPoolJNDIName">java:/FRESH/ThreadPool</property>
+      <!--property name="threadPoolName">java:/FRESH/ThreadPool</property-->
+      <!--property name="JNDIName">java:/FRESH/SystemShell</property>
+      <property name="threadPoolName">java:/FRESH/ThreadPool</property>
       <property name="VFSJNDIName">java:/FRESH/VFS</property>
-      <property name="GCInterval">10000</property>
+      <property name="GCInterval">10000</property-->
+      <property name="threadPool"><inject bean="jboss.system:service=ThreadPool"/></property>
       <property name="executableRegistry"><inject bean="LazyExecutableRegistry"/></property>
   </bean>
 
@@ -40,7 +62,7 @@
 
   <!-- On Demand -->
 
-    <bean name="FreshPoolService" class="org.jboss.fresh.deployer.PoolService" mode="On Demand">
+    <!--bean name="FreshPoolService" class="org.jboss.fresh.deployer.PoolService" mode="On Demand">
         <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="FRESH:service=ThreadPool",exposedInterface=org.jboss.fresh.deployer.PoolServiceMBean.class)</annotation>
         <property name="JNDIName">java:/FRESH/ThreadPool</property>
         <property name="factoryName">org.jboss.fresh.cpii.services.PoolRunnerFactory</property>
@@ -49,7 +71,7 @@
         <property name="maxSize">1000</property>
         <property name="blocking">true</property>
         <property name="blockingTimeout">10000</property>
-    </bean>
+    </bean-->
 
     <bean name="FreshVFSService" class="org.jboss.fresh.deployer.VFSService" mode="On Demand">
         <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="FRESH:service=VFS.Mem",exposedInterface=org.jboss.fresh.deployer.VFSServiceMBean.class)</annotation>

Deleted: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/LazySystemShellService.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/LazySystemShellService.java	2009-05-04 21:52:50 UTC (rev 88171)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/LazySystemShellService.java	2009-05-04 21:57:03 UTC (rev 88172)
@@ -1,27 +0,0 @@
-package org.jboss.fresh.deployer;
-
-import java.util.List;
-
-import org.jboss.dependency.spi.Controller;
-import org.jboss.fresh.shell.impl.LazySystemShellImpl;
-import org.jboss.fresh.shell.impl.SystemShellImpl;
-
-public class LazySystemShellService extends SystemShellService implements LazySystemShellServiceMBean
-{
-   private Controller controller;
-   private List<String> onDemandBeans;
-
-   public LazySystemShellService(Controller controller, List<String> onDemandBeans)
-   {
-      if (controller == null && (onDemandBeans != null &&  onDemandBeans.isEmpty() == false))
-         throw new IllegalArgumentException("Null controller");
-
-      this.controller = controller;
-      this.onDemandBeans = onDemandBeans;
-   }
-
-   protected SystemShellImpl createSystemShell()
-   {
-      return new LazySystemShellImpl(getThreadPoolJNDIName(), getVFSJNDIName(), controller, onDemandBeans);
-   }
-}
\ No newline at end of file

Deleted: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/LazySystemShellServiceMBean.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/LazySystemShellServiceMBean.java	2009-05-04 21:52:50 UTC (rev 88171)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/LazySystemShellServiceMBean.java	2009-05-04 21:57:03 UTC (rev 88172)
@@ -1,4 +0,0 @@
-package org.jboss.fresh.deployer;
-
-public interface LazySystemShellServiceMBean extends SystemShellServiceMBean {
-}
\ No newline at end of file

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/PoolService.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/PoolService.java	2009-05-04 21:52:50 UTC (rev 88171)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/PoolService.java	2009-05-04 21:57:03 UTC (rev 88172)
@@ -8,6 +8,7 @@
 /**
  * This is a simple service that sustains a file on the disk. It it it simply puts an integer specifying the number of invocations made from beginning of its running.
  */
+ at Deprecated
 public class PoolService extends RegistryNamingBinder implements PoolServiceMBean {
 
 	private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(PoolService.class);

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/PoolServiceMBean.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/PoolServiceMBean.java	2009-05-04 21:52:50 UTC (rev 88171)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/PoolServiceMBean.java	2009-05-04 21:57:03 UTC (rev 88172)
@@ -1,6 +1,7 @@
 package org.jboss.fresh.deployer;
 
 
+ at Deprecated
 public interface PoolServiceMBean extends RegistryNamingBinderMBean {
 
     public void setFactoryName(String name);

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/RegistryNamingBinder.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/RegistryNamingBinder.java	2009-05-04 21:52:50 UTC (rev 88171)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/RegistryNamingBinder.java	2009-05-04 21:57:03 UTC (rev 88172)
@@ -87,6 +87,7 @@
         if (name == null)
             return;
 
+        log.info("name: "+name);
         // if (!name.startsWith("java:/")) {
         //    name = "java:/" + name;
         // }

Deleted: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/SystemShellService.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/SystemShellService.java	2009-05-04 21:52:50 UTC (rev 88171)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/SystemShellService.java	2009-05-04 21:57:03 UTC (rev 88172)
@@ -1,93 +0,0 @@
-package org.jboss.fresh.deployer;
-
-import org.jboss.fresh.shell.ExecutableRegistry;
-import org.jboss.fresh.shell.SystemShell;
-import org.jboss.fresh.shell.impl.SystemShellImpl;
-
-public class SystemShellService extends RegistryNamingBinder implements SystemShellServiceMBean {
-
-    // Attributes ----------------------------------------------------
-
-    private String tpName;
-    private String vfsName;
-
-    private long gcInterval = 10000L;
-    private SystemShellImpl ss;
-    private ExecutableRegistry registry;
-
-   public void setExecutableRegistry(ExecutableRegistry registry)
-   {
-      this.registry = registry;
-   }
-
-   public String getName() {
-        return "CP2 SystemShell Binder Service";
-    }
-
-
-    public void setThreadPoolJNDIName(String name) {
-
-        tpName = name;
-    }
-
-
-    public String getThreadPoolJNDIName() {
-        return tpName;
-    }
-
-    public void setVFSJNDIName(String name) {
-
-        vfsName = name;
-    }
-
-
-    public String getVFSJNDIName() {
-        return vfsName;
-    }
-
-
-    public void setGCInterval(long val) {
-        gcInterval = val;
-        if (ss != null)
-            ss.setGCInterval(val);
-    }
-
-    public long getGCInterval() {
-        if (ss == null) return gcInterval;
-        return ss.getGCInterval();
-    }
-
-    protected String getBindClass() {
-        return SystemShell.class.getName();
-    }
-
-    protected Object classToInstance(Class c) {
-
-        try {
-            ss = createSystemShell();
-            ss.setGCInterval(gcInterval);
-            ss.setExecutableRegistry(registry);
-
-            SystemShell ssold = (SystemShell) getServiceObject();
-            if (ssold != null) ssold.shutdown();
-
-            setServiceObject(ss);
-
-            //SystemShellJMXProxy proxy = new SystemShellJMXProxy(getRegisteredName());
-            //return proxy;
-            return ss;
-
-        } catch (Exception ex) {
-            throw new RuntimeException(ex.toString());
-        }
-    }
-
-    protected SystemShellImpl createSystemShell()
-    {
-       return new SystemShellImpl(tpName, vfsName);
-    }
-
-    protected boolean bindByReference() {
-        return true;
-    }
-}

Deleted: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/SystemShellServiceMBean.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/SystemShellServiceMBean.java	2009-05-04 21:52:50 UTC (rev 88171)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/SystemShellServiceMBean.java	2009-05-04 21:57:03 UTC (rev 88172)
@@ -1,20 +0,0 @@
-package org.jboss.fresh.deployer;
-
-import org.jboss.fresh.shell.ExecutableRegistry;
-
-public interface SystemShellServiceMBean extends RegistryNamingBinderMBean {
-
-    public void setThreadPoolJNDIName(String name);
-
-    public String getThreadPoolJNDIName();
-
-    public void setVFSJNDIName(String name);
-
-    public String getVFSJNDIName();
-
-    public void setGCInterval(long val);
-
-    public long getGCInterval();
-
-    public void setExecutableRegistry(ExecutableRegistry registry);
-}
\ 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-04 21:52:50 UTC (rev 88171)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/MBeanInvokeExe.java	2009-05-04 21:57:03 UTC (rev 88172)
@@ -11,6 +11,7 @@
 
 import org.apache.log4j.Logger;
 import org.jboss.fresh.io.BufferObjectWriter;
+import org.jboss.beans.metadata.api.annotations.Bean;
 
 
 public class MBeanInvokeExe extends AbstractInvokeExe {

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/LazySystemShellImpl.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/LazySystemShellImpl.java	2009-05-04 21:52:50 UTC (rev 88171)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/LazySystemShellImpl.java	2009-05-04 21:57:03 UTC (rev 88172)
@@ -15,9 +15,8 @@
    private List<String> onDemandBeans;
    private AtomicBoolean initialized = new AtomicBoolean(false);
 
-   public LazySystemShellImpl(String tpname, String vfsname, Controller controller, List<String> onDemandBeans)
-   {
-      super(tpname, vfsname);
+   public LazySystemShellImpl(Controller controller, List<String> onDemandBeans,String vfsName)throws Exception {
+      super(vfsName);
       this.controller = controller;
       this.onDemandBeans = onDemandBeans;
    }

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/Process.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/Process.java	2009-05-04 21:52:50 UTC (rev 88171)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/Process.java	2009-05-04 21:57:03 UTC (rev 88172)
@@ -1,18 +1,14 @@
 package org.jboss.fresh.shell.impl;
 
-import org.jboss.fresh.vfs.VFSException;
+import org.apache.log4j.Logger;
 import org.jboss.fresh.cpii.services.PoolRunner;
 import org.jboss.fresh.io.CloseProtectedOutBufferImpl;
 import org.jboss.fresh.io.InBuffer;
 import org.jboss.fresh.io.OutBuffer;
-import org.jboss.fresh.shell.EnvProperties;
-import org.jboss.fresh.shell.ShellException;
-import org.jboss.fresh.shell.Executable;
-import org.jboss.fresh.shell.Shell;
-import org.jboss.fresh.shell.SystemShell;
+import org.jboss.fresh.shell.*;
+import org.jboss.fresh.vfs.VFSException;
+import org.jboss.util.threadpool.ThreadPool;
 
-import org.apache.log4j.Logger;
-
 import java.util.HashMap;
 import java.util.LinkedList;
 
@@ -22,303 +18,305 @@
 
 public class Process implements Runnable {
 
-	private String procid;
+    private String procid;
 
-	private InBuffer in;
-	private OutBuffer out;
+    private InBuffer in;
+    private OutBuffer out;
 
-	private PoolRunner runner;
+    //private PoolRunner runner;
     private Thread thread;
     private Executable executable;
 
-	private String cmdline;
-	private String exepath;
-	private String[] params;
-	private String[] origParams;
-	
-//	private int retVal;
-	private boolean finished = false;
-	private boolean done = false;
+    private String cmdline;
+    private String exepath;
+    private String[] params;
+    private String[] origParams;
 
-	private ProcessGroup group;
-	private SystemShell sshell;
-	private Shell shell;
+    //	private int retVal;
+    private boolean finished = false;
+    private boolean done = false;
 
-	private long iotimeout;
-	private long lastUsed;
+    private ProcessGroup group;
+    private SystemShell sshell;
+    private Shell shell;
 
-	private long startTime;
-	private long finishTime;
+    private long iotimeout;
+    private long lastUsed;
 
+    private long startTime;
+    private long finishTime;
 
-	HashMap extras = new HashMap();
 
-	Throwable t = null;
+    HashMap extras = new HashMap();
 
-	private boolean ui = false;
-	private boolean redirected = false;
-	private boolean markedComplete = false;
-	
-	private EnvProperties props;
+    Throwable t = null;
 
-	private Process parent;
-	private static ThreadLocal lineage = new ThreadLocal();
+    private boolean ui = false;
+    private boolean redirected = false;
+    private boolean markedComplete = false;
+
+    private EnvProperties props;
+
+    private Process parent;
+    private static ThreadLocal lineage = new ThreadLocal();
     //private static ThreadLocal trap_flag = new ThreadLocal();
     //private boolean trap_on = false;
 
     //String trace;
 
-	private static Logger log = Logger.getLogger("org.jboss.fresh.shell.impl.Process");
+    private static Logger log = Logger.getLogger("org.jboss.fresh.shell.impl.Process");
     private static Logger plog = Logger.getLogger("org.jboss.fresh.shell.impl.Process_Trap");
+    private ThreadPool threadPool;
 
     // around the Buffer readers and writers are allocated
-	public Process(String id, Process parent, PoolRunner runner, SystemShell sshell, Shell shell) {
-		procid = id;
-		this.runner = runner;
-		this.parent = parent;
-		this.sshell = sshell;
-		this.shell = shell;
-		this.lastUsed = System.currentTimeMillis();
-		this.startTime = System.currentTimeMillis();
-	}
+    public Process(String id, Process parent, SystemShell sshell, Shell shell, ThreadPool threadPool) {
+        procid = id;
+        this.parent = parent;
+        this.sshell = sshell;
+        this.shell = shell;
+        this.lastUsed = System.currentTimeMillis();
+        this.startTime = System.currentTimeMillis();
+        this.threadPool = threadPool;
+    }
 
-	public Thread getThread() {
-		return thread;
-	}
-	
-	private String getClientAndProjectInfo() {
+    public Thread getThread() {
+        return thread;
+    }
 
-		String cuser = null;
-		String capp = null;
-		String chost = null;
-		String project = null;
+    private String getClientAndProjectInfo() {
 
-		try {
-			cuser = shell.getEnvProperty("cp2.client.user");
-		} catch(Exception ex) {
-		}
-		
-		try {
-			capp = shell.getEnvProperty("cp2.client.app");
-		} catch(Exception ex) {
-		}
-		
-		try {
-			chost = shell.getEnvProperty("cp2.client.host");
-		} catch(Exception ex) {
-		}
-		
-		if(cuser == null) cuser = "cuser_unknown";
-		if(chost == null) chost = "chost_unknown";
-		if(capp == null) capp = "capp_unknown";
+        String cuser = null;
+        String capp = null;
+        String chost = null;
+        String project = null;
 
-		try {
-			project = shell.getEnvProperty("PROJECT");
-		} catch(Exception ex) {
-		}
-				
-		if(project == null) project = "";
+        try {
+            cuser = shell.getEnvProperty("cp2.client.user");
+        } catch (Exception ex) {
+        }
 
-		return cuser + "@" + chost + " [" + capp + "] [" + project + "] ";
-	}
+        try {
+            capp = shell.getEnvProperty("cp2.client.app");
+        } catch (Exception ex) {
+        }
 
+        try {
+            chost = shell.getEnvProperty("cp2.client.host");
+        } catch (Exception ex) {
+        }
 
-	public String getID() {
-		return procid;
-	}
+        if (cuser == null) cuser = "cuser_unknown";
+        if (chost == null) chost = "chost_unknown";
+        if (capp == null) capp = "capp_unknown";
 
-	public Shell getShell() {
-		return shell;
-	}
+        try {
+            project = shell.getEnvProperty("PROJECT");
+        } catch (Exception ex) {
+        }
 
-	public void setGroup(ProcessGroup p) {
-		group = p;
-	}
+        if (project == null) project = "";
 
-	public ProcessGroup getGroup() {
-		return group;
-	}
+        return cuser + "@" + chost + " [" + capp + "] [" + project + "] ";
+    }
 
-	public void setInputBuffer(InBuffer buf) {
-		in = buf;
-	}
 
-	public InBuffer getInputBuffer() {
-		return in;
-	}
+    public String getID() {
+        return procid;
+    }
 
-	public void setOutputBuffer(OutBuffer buf) {
-		out = buf;
-	}
+    public Shell getShell() {
+        return shell;
+    }
 
-	public OutBuffer getOutputBuffer() {
-		return out;
-	}
+    public void setGroup(ProcessGroup p) {
+        group = p;
+    }
 
-	public void setCommandLine(String val) {
-		cmdline = val;
-	}
+    public ProcessGroup getGroup() {
+        return group;
+    }
 
-	public String getCommandLine() {
-		return cmdline;
-	}
+    public void setInputBuffer(InBuffer buf) {
+        in = buf;
+    }
 
-	public void setExePath(String path) {
-		exepath = path;
-	}
+    public InBuffer getInputBuffer() {
+        return in;
+    }
 
-	public String getExePath() {
-		return exepath;
-	}
+    public void setOutputBuffer(OutBuffer buf) {
+        out = buf;
+    }
 
-	public void setParams(String[] val) {
-		params = val;
-	}
+    public OutBuffer getOutputBuffer() {
+        return out;
+    }
 
-	public String[] getParams() {
-		return params;
-	}
+    public void setCommandLine(String val) {
+        cmdline = val;
+    }
 
-	public void setExecutable(Executable ex) {
-		executable = ex;
-	}
+    public String getCommandLine() {
+        return cmdline;
+    }
 
-	public Executable getExecutable() {
-		return executable;
-	}
+    public void setExePath(String path) {
+        exepath = path;
+    }
 
-	public void setRedirected(boolean val) {
-		redirected = val;
-	}
-	
-	public boolean isRedirected() {
-		return redirected;
-	}
-	
-	public void markCompleted() {
-		markedComplete = true;
-	}
-	
-	public boolean isMarkedComplete() {
-		return markedComplete;
-	}
+    public String getExePath() {
+        return exepath;
+    }
+
+    public void setParams(String[] val) {
+        params = val;
+    }
+
+    public String[] getParams() {
+        return params;
+    }
+
+    public void setExecutable(Executable ex) {
+        executable = ex;
+    }
+
+    public Executable getExecutable() {
+        return executable;
+    }
+
+    public void setRedirected(boolean val) {
+        redirected = val;
+    }
+
+    public boolean isRedirected() {
+        return redirected;
+    }
+
+    public void markCompleted() {
+        markedComplete = true;
+    }
+
+    public boolean isMarkedComplete() {
+        return markedComplete;
+    }
 /*
 	public void setPoolRunner(PoolRunner runner) {
 		this.runner=runner;
 	}
 */
 
-/*
-	public int getRetVal() {
-		return retVal;
-	}
-*/
-	public boolean isFinished() {
-		return finished;
-	}
+    /*
+        public int getRetVal() {
+            return retVal;
+        }
+    */
+    public boolean isFinished() {
+        return finished;
+    }
 
-	public boolean isDone() {
-		return done;
-	}
+    public boolean isDone() {
+        return done;
+    }
 
-	public boolean isComplete() {
-		return done && (out == null || out.isClosed());
-	}
+    public boolean isComplete() {
+        return done && (out == null || out.isClosed());
+    }
 
 
-	public boolean canDispose() {
+    public boolean canDispose() {
 //		try {		//log.debug("[Process] out.size " + out.size());
 ////		if(out.size()>0) System.out.println("got from out: " + out.get(10000L));
 //		} catch (Exception ex) {
 //			log.error("Could not dispose", ex);
 //		}
-		//return finished && (out == null || out.isClosed());
-		return isComplete();
-	}
+        //return finished && (out == null || out.isClosed());
+        return isComplete();
+    }
 
-	public void setThrowable(Throwable t) {
-		if (group != null) {
-			group.setThrowable(t);
-		}
-		this.t = t;
+    public void setThrowable(Throwable t) {
+        if (group != null) {
+            group.setThrowable(t);
+        }
+        this.t = t;
 
         Throwable th = t;
-        while(th != null) {
-            if(th instanceof java.sql.SQLException) {
-                Throwable sqlc = ((java.sql.SQLException)th).getNextException();
-                if(sqlc != null && th.getCause() == null)
+        while (th != null) {
+            if (th instanceof java.sql.SQLException) {
+                Throwable sqlc = ((java.sql.SQLException) th).getNextException();
+                if (sqlc != null && th.getCause() == null)
                     th.initCause(sqlc);
             }
             th = th.getCause();
         }
     }
 
-	public Throwable getThrowable() {
-		return t;
-	}
+    public Throwable getThrowable() {
+        return t;
+    }
 
-	public void start() {
-        if(runner==null) {
-//System.out.println("        *Process  -  START  (same thread)");
-        	run();
-            //trace = null;
+    public void start() {
+        if (threadPool == null) {
+            run();
         } else {
-            //trace = StringUtils.getStackTrace(new RuntimeException());
-//System.out.println("        *Process  -  START  (other thread)");
-            runner.runJob(this, exepath + " - " + cmdline);
+            //runner.runJob(this, exepath + " - " + cmdline);
+            threadPool.run(this);
         }
-	}
+    }
 
-	public void startjoin() {
-		if(runner==null) run();
-		else runner.joinJob(this, exepath + " - " + cmdline);
-	}
+    public void startjoin() {
+        if (threadPool == null) {
+            run();
+        } else {
+            //runner.joinJob(this, exepath + " - " + cmdline); //todo is this ok?
+            threadPool.run(this);
+        }
+    }
 
-	private void closeJob(Throwable th) {
-		try {
-			// now make sure we deregister this process with SysShell
+    private void closeJob(Throwable th) {
+        try {
+            // now make sure we deregister this process with SysShell
 //log.debug("[Process <<<<<<] Process no. " + procid + " closing in.");
-			in.setThrowable(th);
-		} catch (Throwable ex) {
-			log.error(getClientAndProjectInfo() + "Could not set exception", ex);
-		}
+            in.setThrowable(th);
+        } catch (Throwable ex) {
+            log.error(getClientAndProjectInfo() + "Could not set exception", ex);
+        }
 
-		try {
+        try {
 //HERESystem.out.println("[process.closeJob] closing in " + in);
-			in.close();
-		} catch (Throwable ex) {
-			log.error(getClientAndProjectInfo() + "Could not close Job", ex);
-		}
+            in.close();
+        } catch (Throwable ex) {
+            log.error(getClientAndProjectInfo() + "Could not close Job", ex);
+        }
 
 //log.debug("[Process <<<<<<] Process no. " + procid + " closing out.");
-		try {
-			out.setThrowable(th);
-		} catch (Throwable ex) {
-			log.error(getClientAndProjectInfo() + "Could not set exception", ex);
-		}
+        try {
+            out.setThrowable(th);
+        } catch (Throwable ex) {
+            log.error(getClientAndProjectInfo() + "Could not set exception", ex);
+        }
 
-		try {
+        try {
 //log.debug("[process.closeJob] closing out " + out);
-			out.close();
-		} catch (Throwable ex) {
-			log.error(getClientAndProjectInfo() + "Could not close Job", ex);
-		}
+            out.close();
+        } catch (Throwable ex) {
+            log.error(getClientAndProjectInfo() + "Could not close Job", ex);
+        }
 
 //log.debug("[Process <<<<<<] Process no. " + procid + " ending process through SystemShell.");
-		try {
-			sshell.endProcess(procid);
-		} catch (Throwable ex) {
-			log.error(getClientAndProjectInfo() + "Could not end process", ex);
-		}
+        try {
+            sshell.endProcess(procid);
+        } catch (Throwable ex) {
+            log.error(getClientAndProjectInfo() + "Could not end process", ex);
+        }
 
 //log.debug("[Process ======] Process no. " + procid + " finished.");
 
-		// remove references to runner executable, sshell and shell
-		runner = null;
-		executable = null;
-		sshell = null;
-		props = null;
-		//shell = null;  // we need this to get to parent shell of still outstanding processes
+        // remove references to runner executable, sshell and shell
+        threadPool = null;
+        executable = null;
+        sshell = null;
+        props = null;
+        //shell = null;  // we need this to get to parent shell of still outstanding processes
 
         // remove references to most everything else
         in = null;
@@ -327,19 +325,19 @@
 
 
         done = true;
-	}
+    }
 
-	// if exception occurs we save it.
-	// But let's not let any exceptions get out. There is a leak in PoolRunner I think.
-	public void run() {
-		Throwable th = null;
-		try {
+    // if exception occurs we save it.
+    // But let's not let any exceptions get out. There is a leak in PoolRunner I think.
+    public void run() {
+        Throwable th = null;
+        try {
 //log.debug("[Process] Process no. " + procid + " started.");
 //			TxSupport.begin();
-			if(log.isDebugEnabled())
+            if (log.isDebugEnabled())
                 log.debug(getClientAndProjectInfo() + "executing: " + cmdline + formatParams(origParams));
 
-			try {
+            try {
                 thread = Thread.currentThread();
                 //if(trap_flag.get() == null) {
                 //    trap_on = true;
@@ -351,161 +349,160 @@
                 executable.setStdOut(new CloseProtectedOutBufferImpl(bufOut));
                 executable.execute(exepath, params);
 
-    			/*if(!"1".equals(shell.getEnvProperty("TX_ACTIVE")) && TxSupport.isActive())
-    				TxSupport.commit();*/
-			
-			} finally {
+                /*if(!"1".equals(shell.getEnvProperty("TX_ACTIVE")) && TxSupport.isActive())
+                        TxSupport.commit();*/
+
+            } finally {
 //System.out.println("          Execute   DONE : " + executable);
-				thread = null;
+                thread = null;
                 finishTime = System.currentTimeMillis();
-				finished = true;
-				popLineage();
+                finished = true;
+                popLineage();
             }
 
 
-		} catch (VFSException t) {
-			// procid, sessid, cmdline ... bi morali biti na context porinjeni log.getTLMap().put("shell.procid", procid)
-			// log.getTLMap().put("shell.sessid", sessid), log.getTLMap().put("shell.cmdline", cmdline)
-			//log.error("/shell/execution", "Exception while executing", t.getUnderlyingThrowable());
-			//if(trace != null)
+        } catch (VFSException t) {
+            // procid, sessid, cmdline ... bi morali biti na context porinjeni log.getTLMap().put("shell.procid", procid)
+            // log.getTLMap().put("shell.sessid", sessid), log.getTLMap().put("shell.cmdline", cmdline)
+            //log.error("/shell/execution", "Exception while executing", t.getUnderlyingThrowable());
+            //if(trace != null)
             //    log.error(getClientAndProjectInfo() + "Exception while executing: " + cmdline + " ON BEHALF OF: " + trace);
             log.error(getClientAndProjectInfo() + "Exception while executing: " + cmdline + formatParams(origParams), t.getUnderlyingThrowable());
-			setThrowable(t);
-			th = t;
-			/*try {
-				if(!"1".equals(shell.getEnvProperty("TX_ACTIVE")) && TxSupport.isActive())
-					TxSupport.rollback();
-			} catch (Exception e) {
-			} */
+            setThrowable(t);
+            th = t;
+            /*try {
+                   if(!"1".equals(shell.getEnvProperty("TX_ACTIVE")) && TxSupport.isActive())
+                       TxSupport.rollback();
+               } catch (Exception e) {
+               } */
 
-		} catch (Throwable t) {
-			//log.debug("[Process] " + procid + " : Exception occured: ");
-			//log.error("/shell/execution", "Exception while executing", t);
+        } catch (Throwable t) {
+            //log.debug("[Process] " + procid + " : Exception occured: ");
+            //log.error("/shell/execution", "Exception while executing", t);
             //if(trace != null)
             //    log.error(getClientAndProjectInfo() + "Exception while executing: " + cmdline + " ON BEHALF OF: " + trace);
 
-            if(t instanceof java.io.EOFException && log.isDebugEnabled()) {
+            if (t instanceof java.io.EOFException && log.isDebugEnabled()) {
                 log.debug(getClientAndProjectInfo() + "Client didn't finish reading from " + cmdline + formatParams(origParams), t);
-			} else {
-				log.error(getClientAndProjectInfo() + "Exception while executing: " + cmdline + formatParams(origParams), t);
-			}
-			setThrowable(t);
-			th = t;
-			/*try {
-				if(!"1".equals(shell.getEnvProperty("TX_ACTIVE")) && TxSupport.isActive())
-					TxSupport.rollback();
-			} catch (Exception e) {
-			}*/
+            } else {
+                log.error(getClientAndProjectInfo() + "Exception while executing: " + cmdline + formatParams(origParams), t);
+            }
+            setThrowable(t);
+            th = t;
+            /*try {
+                   if(!"1".equals(shell.getEnvProperty("TX_ACTIVE")) && TxSupport.isActive())
+                       TxSupport.rollback();
+               } catch (Exception e) {
+               }*/
 
-		} finally {
+        } finally {
 
             closeJob(th);
-		}
-	}
+        }
+    }
 
 
+    public void putExtra(Object name, Object value) {
+        extras.put(name, value);
+    }
 
-   public void putExtra(Object name, Object value) {
-		extras.put(name, value);
-	}
+    public Object getExtra(Object name) {
+        return extras.get(name);
+    }
 
-	public Object getExtra(Object name) {
-		return extras.get(name);
-	}
+    public Object removeExtra(Object name) {
+        return extras.remove(name);
+    }
 
-	public Object removeExtra(Object name) {
-		return extras.remove(name);
-	}
+    public void setIOTimeout(long val) {
+        iotimeout = val;
+    }
 
-	public void setIOTimeout(long val) {
-		iotimeout = val;
-	}
+    public long getIOTimeout() {
+        return iotimeout;
+    }
 
-	public long getIOTimeout() {
-		return iotimeout;
-	}
+    public long getStartTime() {
+        return startTime;
+    }
 
-	public long getStartTime() {
-		return startTime;
-	}
+    public long getFinishTime() {
+        return finishTime;
+    }
 
-	public long getFinishTime() {
-		return finishTime;
-	}
+    public long lastUsed() {
+        return lastUsed;
+    }
 
-	public long lastUsed() {
-		return lastUsed;
-	}
+    public void setUserInitiated(boolean ui) {
+        this.ui = ui;
+    }
 
-	public void setUserInitiated(boolean ui) {
-		this.ui = ui;
-	}
+    public boolean isUserInitiated() {
+        return ui;
+    }
 
-	public boolean isUserInitiated() {
-		return ui;
-	}
+    public void using() throws ShellException {
+        if (shell == null)
+            return;
+        lastUsed = System.currentTimeMillis();
+        shell.using();
+    }
 
-	public void using() throws ShellException {
-		if(shell == null)
-			return;
-		lastUsed = System.currentTimeMillis();
-		shell.using();
-	}
 
+    public void setOriginalParams(String[] originalParams) {
+        origParams = originalParams;
+    }
 
-	public void setOriginalParams(String[] originalParams) {
-		origParams = originalParams;		
-	}
-	
-	public String [] getOriginalParams() {
-		return origParams;
-	}
+    public String[] getOriginalParams() {
+        return origParams;
+    }
 
-	public void setEnv(EnvProperties env) {
-		props = env;
-	}
-	
-	public EnvProperties getEnv() {
-		return props;
-	}
+    public void setEnv(EnvProperties env) {
+        props = env;
+    }
 
-	public Process getParent() {
-		return parent;
-	}
-	
-	public static Process getThreadParent() {
-		LinkedList<Process> ls = (LinkedList <Process>) lineage.get();
-		if(ls != null)
-			return ls.getLast();
-		return null;
-	}
+    public EnvProperties getEnv() {
+        return props;
+    }
 
+    public Process getParent() {
+        return parent;
+    }
+
+    public static Process getThreadParent() {
+        LinkedList<Process> ls = (LinkedList<Process>) lineage.get();
+        if (ls != null)
+            return ls.getLast();
+        return null;
+    }
+
     public static LinkedList getThreadLineage() {
         return new LinkedList(prepareLineage());
     }
 
-    private static LinkedList <Process> prepareLineage() {
-		LinkedList <Process> ls = (LinkedList <Process>) lineage.get();
-		if(ls == null) {
-			ls = new LinkedList<Process>();
-			lineage.set(ls);
-		}
-		return ls;
-	}
-	
-	private static void popLineage() {
-		LinkedList <Process> ls = (LinkedList <Process>) lineage.get();
-		ls.removeLast();
-		if(ls.isEmpty())
-			lineage.remove();
-	}
+    private static LinkedList<Process> prepareLineage() {
+        LinkedList<Process> ls = (LinkedList<Process>) lineage.get();
+        if (ls == null) {
+            ls = new LinkedList<Process>();
+            lineage.set(ls);
+        }
+        return ls;
+    }
 
-    private static String formatParams(String [] params) {
+    private static void popLineage() {
+        LinkedList<Process> ls = (LinkedList<Process>) lineage.get();
+        ls.removeLast();
+        if (ls.isEmpty())
+            lineage.remove();
+    }
+
+    private static String formatParams(String[] params) {
         StringBuffer sb = new StringBuffer();
-        if(params == null)
+        if (params == null)
             return "";
 
-        for(int i=0; i < params.length; i++) {
+        for (int i = 0; i < params.length; i++) {
             sb.append(" ").append(params[i]);
         }
 

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/ProcessGroup.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/ProcessGroup.java	2009-05-04 21:52:50 UTC (rev 88171)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/ProcessGroup.java	2009-05-04 21:57:03 UTC (rev 88172)
@@ -23,7 +23,7 @@
 // But processchain only gets thrown out after the last process in the chain has finished.
 	public ProcessGroup(String id, Process parent, LinkedList procs) {
 		//super(id, null, null, (procs != null && procs.size() > 0 ? ((Process)procs.getFirst()).getShell() : null));
-		super(id, parent, null, null, null);
+		super(id, parent, null, null,null);
 		if (procs != null)
 			this.procs = procs;
 	}

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-04 21:52:50 UTC (rev 88171)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/SystemShellImpl.java	2009-05-04 21:57:03 UTC (rev 88172)
@@ -1,300 +1,302 @@
 package org.jboss.fresh.shell.impl;
 
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Timer;
-import java.util.TimerTask;
-import javax.naming.NamingException;
-
-import org.jboss.fresh.cpii.services.PoolRunner;
-import org.jboss.fresh.pool.pool.Pool;
-import org.jboss.fresh.pool.pool.PoolException;
+import org.jboss.beans.metadata.api.annotations.Inject;
+import org.jboss.fresh.deployer.RegistryNamingBinder;
 import org.jboss.fresh.registry.RegistryContext;
-import org.jboss.fresh.shell.EnvProperties;
-import org.jboss.fresh.shell.ExecutableRegistry;
-import org.jboss.fresh.shell.Shell;
-import org.jboss.fresh.shell.ShellException;
-import org.jboss.fresh.shell.SystemShell;
+import org.jboss.fresh.shell.*;
 import org.jboss.fresh.vfs.UserCtx;
 import org.jboss.fresh.vfs.VFS;
+import org.jboss.util.threadpool.ThreadPool;
 
+import javax.naming.NamingException;
+import java.util.*;
+
 /**
-// 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.
-// And load them in if accessed after a long time.
-// 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
-
+ * // 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.
+ * // And load them in if accessed after a long time.
+ * // 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
  */
-public class SystemShellImpl implements SystemShell {
-	protected static org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(SystemShellImpl.class);
 
-	HashMap shellmap = new HashMap();
-	HashMap procmap = new HashMap();
+//@Bean(name = "SystemShell")
+//@JndiBinding(name = "java:/FRESH/SystemShell")
+public class SystemShellImpl extends RegistryNamingBinder implements SystemShell {
+    protected static org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(SystemShellImpl.class);
 
-	private String tpName, vfsName;
+    HashMap shellmap = new HashMap();
+    HashMap procmap = new HashMap();
 
-	private Date startTime;
+    //private String threadPoolName;
+    private String vfsName;
 
-   private ExecutableRegistry registry;
+    private Date startTime;
 
-    
-//	GCThread gc;
-	Timer gc;
-	long gcPeriod = 10000L;
+    private ExecutableRegistry registry;
 
-	public SystemShellImpl(String tpname, String vfsname) {
-		tpName = tpname;
-		vfsName = vfsname;
-		startTime = new Date();
-//		gc=new GCThread(this, "SystemShellImpl GC Daemon Thread");
-//		gc.setDaemon(true);
-//		gc.setPriority(Thread.MIN_PRIORITY);
-//		gc.start();
-		reinitGC();
-	}
+    @Inject(bean = "jboss.system:service=ThreadPool")
+    private ThreadPool threadPool;
 
-   public void setExecutableRegistry(ExecutableRegistry registry) {
-      this.registry = registry;
-   }
+    //	GCThread gc;
+    Timer gc;
+    long gcPeriod = 10000L;
 
-	public void reinitGC() {
 
-		if (gc != null) gc.cancel();
+    public SystemShellImpl(String vfsname) throws Exception {
+        this.vfsName = vfsname;
+        log.info("calling do start!");
+        startTime = new Date();
+        doStart();
+        reinitGC();
 
-		gc = new Timer(true);
-		TimerTask tt = new TimerTask() {
-			public void run() {
-				doGC();
-			}
-		};
+    }
 
-		gc.scheduleAtFixedRate(tt, gcPeriod, gcPeriod);
-	}
+    public void setThreadPool(ThreadPool threadPool) {
+        this.threadPool = threadPool;
+    }
 
-	public void setGCInterval(long val) {
-		//gc.setInterval(val);
-		if (val == gcPeriod) return;
-		gcPeriod = val;
-		reinitGC();
-	}
+    protected String getBindClass() {
+        return SystemShell.class.getName();
+    }
 
-	public long getGCInterval() {
-		//return gc.getInterval();
-		return gcPeriod;
-	}
+    protected Object classToInstance(Class c) {
+        return this;
+    }
 
-	synchronized private String newID() {
-		return org.jboss.fresh.util.UniqueNumberGenerator.getGUID();
-	}
+    /*public void setThreadPoolName(String threadPoolName) {
+        this.threadPoolName = threadPoolName;
+    }*/
 
-	private String newProcessID() {
-		return newID();
-	}
+    /*public SystemShellImpl(String tpname, String vfsname) {
+        threadPoolName = tpname;
+        vfsName = vfsname;
+        startTime = new Date();
+        reinitGC();
+    }*/
 
-	private Pool getThreadPool() {
-		Pool pool = null;
-		try {
-			RegistryContext ictx = new RegistryContext();
-			pool = (Pool) ictx.lookup(tpName);
-		} catch (Exception ex) {
-			log.error(ex.getMessage(),ex);
-			throw new RuntimeException("org.jboss.fresh.shell.impl.SystemShellImpl: getThreadPool: " + tpName + " not bound.");
-		}
+    public void setExecutableRegistry(ExecutableRegistry registry) {
+        this.registry = registry;
+    }
 
-		return pool;
-	}
+    public void reinitGC() {
 
+        if (gc != null) gc.cancel();
 
-	public VFS getVFS() {
-		VFS vfs = null;
-		try {
-			RegistryContext ctx = new RegistryContext();
-			vfs = (VFS) ctx.lookup(vfsName);
-		} catch (NamingException ex) {
-			log.error(ex.getMessage(),ex);
-			throw new RuntimeException("org.jboss.fresh.shell.impl.SystemShellImpl: startSession: " + vfsName + " not bound.");
-		}
+        gc = new Timer(true);
+        TimerTask tt = new TimerTask() {
+            public void run() {
+                doGC();
+            }
+        };
 
-		return vfs;
-	}
+        gc.scheduleAtFixedRate(tt, gcPeriod, gcPeriod);
+    }
 
-	public Shell startSession(UserCtx uctx, boolean interactive) {
-		// create new shell object
-		// assign id to it
-		// assign uctx to it
-		String id = newID();
-		VFS vfs = getVFS();
-		ShellImpl shell = new ShellImpl(id, interactive, this, uctx, vfs);
-      shell.setRegistry(registry);
+    public void setGCInterval(long val) {
+        //gc.setInterval(val);
+        if (val == gcPeriod) return;
+        gcPeriod = val;
+        reinitGC();
+    }
 
-		// put it in shellmap
-		shellmap.put(id, shell);
+    public long getGCInterval() {
+        //return gc.getInterval();
+        return gcPeriod;
+    }
 
-		// return it
-		return shell;
-	}
+    synchronized private String newID() {
+        return org.jboss.fresh.util.UniqueNumberGenerator.getGUID();
+    }
 
-	public Shell continueSession(String sessid) {
-		// lookup shell in the shellmap
-		Shell shell = (Shell) shellmap.get(sessid);
+    private String newProcessID() {
+        return newID();
+    }
 
-		// return it
-		return shell;
-	}
 
-	public void closeSession(String sessid) {
-		// remove shell from map
-		//log.debug("### removing session: " + sessid);
-		log.debug("Removing session: " + sessid);
-		ShellImpl shell = (ShellImpl) shellmap.remove(sessid);
+    public VFS getVFS() {
+        VFS vfs = null;
+        try {
+            RegistryContext ctx = new RegistryContext();
+            vfs = (VFS) ctx.lookup(vfsName);
+        } catch (NamingException ex) {
+            log.error(ex.getMessage(), ex);
+            throw new RuntimeException("org.jboss.fresh.shell.impl.SystemShellImpl: startSession: " + vfsName + " not bound.");
+        }
 
-		// kill all jobs that are active on this shell
-		// call dispose on ShellImpl
-		//log.debug("### disposing... " + shell);
-		log.debug("Disposing: " + shell);
-		if (shell != null) shell.dispose();
-	}
+        return vfs;
+    }
 
-	public Process findProcess(String id) throws ShellException {
-		return (Process) procmap.get(id);
-	}
+    public Shell startSession(UserCtx uctx, boolean interactive) {
+        // create new shell object
+        // assign id to it
+        // assign uctx to it
+        String id = newID();
+        VFS vfs = getVFS();
+        ShellImpl shell = new ShellImpl(id, interactive, this, uctx, vfs);
+        shell.setRegistry(registry);
 
-	public Process createProcess(Shell shell) throws ShellException {
-		// take PoolRunner from pool
-		try {
-			Pool pool = null;
-			PoolRunner r = null;
-			if(!"SINGLE".equals(shell.getEnvProperty("TMODE"))) {
-				pool = getThreadPool();
-				r = (PoolRunner) pool.checkout();
-				if (r == null) throw new ShellException("No thread available. Either you have a thread leak on client side (you closing resources when finished with them?) or you should increase the max size of connection pool.");
+        // put it in shellmap
+        shellmap.put(id, shell);
 
-			}
-			
-			String id = newProcessID();			
-			Process parent = Process.getThreadParent();
-			Process p = new Process(id, parent, r, this, shell);
-			if(parent == null)
-				p.setEnv(new EnvProperties(shell.getEnv()));
-			else
-				p.setEnv(new EnvProperties(parent.getEnv()));
+        // return it
+        return shell;
+    }
 
-			procmap.put(id, p);
-			return p;
-		} catch(InterruptedException ex) {
-			throw new RuntimeException("createProcess operation has been interrupted: ", ex);
-		} catch(PoolException ex) {
-			throw new ShellException(ex);
-		}
-	}
+    public Shell continueSession(String sessid) {
+        // lookup shell in the shellmap
+        Shell shell = (Shell) shellmap.get(sessid);
 
-	public Process createProcess(Shell shell, boolean useThreadPool) throws ShellException {
-		// take PoolRunner from pool
-		if(useThreadPool) return createProcess(shell);
+        // return it
+        return shell;
+    }
 
-		String id = newProcessID();
-		Process parent = Process.getThreadParent();
-		Process p = new Process(id, parent, null, this, shell);
-		if(parent == null)
-			p.setEnv(new EnvProperties(shell.getEnv()));
-		else
-			p.setEnv(new EnvProperties(parent.getEnv()));
+    public void closeSession(String sessid) {
+        // remove shell from map
+        //log.debug("### removing session: " + sessid);
+        log.debug("Removing session: " + sessid);
+        ShellImpl shell = (ShellImpl) shellmap.remove(sessid);
 
-		procmap.put(id, p);
-		return p;
-	}
+        // kill all jobs that are active on this shell
+        // call dispose on ShellImpl
+        //log.debug("### disposing... " + shell);
+        log.debug("Disposing: " + shell);
+        if (shell != null) shell.dispose();
+    }
 
-	public ProcessGroup createProcessGroup(LinkedList procs) throws ShellException {
-		String id = newProcessID();
-		Process parent = Process.getThreadParent();
-		ProcessGroup pc = new ProcessGroup(id, parent, procs);
-		if(parent == null)
-			pc.setEnv(new EnvProperties(((Process)procs.getFirst()).getShell().getEnv()));
-		else
-			pc.setEnv(new EnvProperties(parent.getEnv()));
+    public Process findProcess(String id) throws ShellException {
+        return (Process) procmap.get(id);
+    }
 
-		Iterator it = procs.iterator();
-		while (it.hasNext()) {
-			Process p = (Process) it.next();
-			p.setGroup(pc);
-		}
+    public Process createProcess(Shell shell) throws ShellException {
+        // take PoolRunner from pool
+        try {
+            if (!"SINGLE".equals(shell.getEnvProperty("TMODE"))) {
+                //Object ob = threadPool.
 
-		procmap.put(id, pc);
-		return pc;
-	}
 
-	public synchronized void endProcess(String id) {
-		// remove this id - nothing else
-		//log.debug("### SystemShellImpl : endProcess : " + id);
-		Process p = (Process) procmap.remove(id);
-		if (p == null) return;
-		//log.debug("SystemShellImpl : endProcess : 1");
-		p.getShell().removeProcess(id);
-		//log.debug("SystemShellImpl : endProcess : 2");
-		// All the following code only makes sure the ProcessGroup is removed when
-		// none of the Processes it contains is active any more.
-		ProcessGroup p2 = (ProcessGroup) p.getGroup();
-		//log.debug("SystemShellImpl : endProcess : 3");
-		if (p2 == null) return;
-		//log.debug("SystemShellImpl : endProcess : 4");
-		Iterator it = p2.getProcessList().iterator();
-		//log.debug("SystemShellImpl : endProcess : 5");
-		boolean keep = false;
-		//log.debug("SystemShellImpl : endProcess : 6");
-		while (it.hasNext()) {
-			Process p3 = (Process) it.next();
-			if (p3 == p) {
-				it.remove();
-			} else {
-				Process p4 = (Process) procmap.get(p3.getID());
-				if (p4 != null) {
-					keep = true;
-					break;
-				}
-			}
-		}
-		//log.debug("SystemShellImpl : endProcess : 7");
-		if (!keep) {
-			//log.debug("SystemShellImpl : endProcess : 8 (" + p2.getID() + ")");
-			procmap.remove(p2.getID());
-			if (p2 != p) p.getShell().removeProcess(p2.getID());
-		}
-		//log.debug("SystemShellImpl : endProcess : 9");
-	}
+                if (threadPool == null)
+                    throw new ShellException("No thread available. Either you have a thread leak on client side (you closing resources when finished with them?) or you should increase the max size of connection pool.");
 
-	public Map getProcMap() {
-		return new HashMap(procmap);
-	}
+            }
 
-	public Map getShellMap() {
-		return new HashMap(shellmap);
-	}
+            String id = newProcessID();
+            Process parent = Process.getThreadParent();
+            Process p = new Process(id, parent, this, shell, threadPool);
+            if (parent == null)
+                p.setEnv(new EnvProperties(shell.getEnv()));
+            else
+                p.setEnv(new EnvProperties(parent.getEnv()));
 
+            procmap.put(id, p);
+            return p;
+        } catch (Exception ex) {
+            throw new ShellException(ex);
+        }
+    }
 
-	public void shutdown() {
-		//gc.interrupt();
-		gc.cancel();
-	}
+    public Process createProcess(Shell shell, boolean useThreadPool) throws ShellException {
+        // take PoolRunner from pool
+        if (useThreadPool) return createProcess(shell);
 
-	// we simply call doGC on every session we have
-	public void doGC() {
-		Map m = new HashMap(shellmap);
-		Iterator it = m.values().iterator();
-		// Commented out by boky (it's annoying!)
-		//log.debug("\n####\n#### GC: ");
-		while (it.hasNext()) {
-			ShellImpl sh = (ShellImpl) it.next();
-			sh.doGC();
-		}
-	}
+        String id = newProcessID();
+        Process parent = Process.getThreadParent();
+        Process p = new Process(id, parent, this, shell, threadPool);
+        if (parent == null)
+            p.setEnv(new EnvProperties(shell.getEnv()));
+        else
+            p.setEnv(new EnvProperties(parent.getEnv()));
 
+        procmap.put(id, p);
+        return p;
+    }
 
+    public ProcessGroup createProcessGroup(LinkedList procs) throws ShellException {
+        String id = newProcessID();
+        Process parent = Process.getThreadParent();
+        ProcessGroup pc = new ProcessGroup(id, parent, procs);
+        if (parent == null)
+            pc.setEnv(new EnvProperties(((Process) procs.getFirst()).getShell().getEnv()));
+        else
+            pc.setEnv(new EnvProperties(parent.getEnv()));
+
+        Iterator it = procs.iterator();
+        while (it.hasNext()) {
+            Process p = (Process) it.next();
+            p.setGroup(pc);
+        }
+
+        procmap.put(id, pc);
+        return pc;
+    }
+
+    public synchronized void endProcess(String id) {
+        // remove this id - nothing else
+        //log.debug("### SystemShellImpl : endProcess : " + id);
+        Process p = (Process) procmap.remove(id);
+        if (p == null) return;
+        //log.debug("SystemShellImpl : endProcess : 1");
+        p.getShell().removeProcess(id);
+        //log.debug("SystemShellImpl : endProcess : 2");
+        // All the following code only makes sure the ProcessGroup is removed when
+        // none of the Processes it contains is active any more.
+        ProcessGroup p2 = (ProcessGroup) p.getGroup();
+        //log.debug("SystemShellImpl : endProcess : 3");
+        if (p2 == null) return;
+        //log.debug("SystemShellImpl : endProcess : 4");
+        Iterator it = p2.getProcessList().iterator();
+        //log.debug("SystemShellImpl : endProcess : 5");
+        boolean keep = false;
+        //log.debug("SystemShellImpl : endProcess : 6");
+        while (it.hasNext()) {
+            Process p3 = (Process) it.next();
+            if (p3 == p) {
+                it.remove();
+            } else {
+                Process p4 = (Process) procmap.get(p3.getID());
+                if (p4 != null) {
+                    keep = true;
+                    break;
+                }
+            }
+        }
+        //log.debug("SystemShellImpl : endProcess : 7");
+        if (!keep) {
+            //log.debug("SystemShellImpl : endProcess : 8 (" + p2.getID() + ")");
+            procmap.remove(p2.getID());
+            if (p2 != p) p.getShell().removeProcess(p2.getID());
+        }
+        //log.debug("SystemShellImpl : endProcess : 9");
+    }
+
+    public Map getProcMap() {
+        return new HashMap(procmap);
+    }
+
+    public Map getShellMap() {
+        return new HashMap(shellmap);
+    }
+
+
+    public void shutdown() {
+        //gc.interrupt();
+        gc.cancel();
+    }
+
+    // we simply call doGC on every session we have
+    public void doGC() {
+        Map m = new HashMap(shellmap);
+        Iterator it = m.values().iterator();
+        // Commented out by boky (it's annoying!)
+        //log.debug("\n####\n#### GC: ");
+        while (it.hasNext()) {
+            ShellImpl sh = (ShellImpl) it.next();
+            sh.doGC();
+        }
+    }
+
+
 /*	class GCThread extends Thread {
 
 		private long ms=10000L; // 10 sec default
@@ -330,7 +332,7 @@
 */
 
 
-	public Date getStartTime() {
-		return startTime;
-	}
+    public Date getStartTime() {
+        return startTime;
+    }
 }
\ No newline at end of file




More information about the jboss-cvs-commits mailing list