[jboss-cvs] JBossAS SVN: r88013 - in projects/fresh/trunk: etc and 20 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Apr 29 12:31:09 EDT 2009


Author: ctomc
Date: 2009-04-29 12:31:09 -0400 (Wed, 29 Apr 2009)
New Revision: 88013

Added:
   projects/fresh/trunk/fresh-scripting/src/main/java/org/jboss/fresh/deployer/
   projects/fresh/trunk/fresh-scripting/src/main/java/org/jboss/fresh/deployer/ScriptingCentral.java
   projects/fresh/trunk/fresh-scripting/src/main/java/org/jboss/fresh/deployer/ScriptingService.java
   projects/fresh/trunk/fresh-scripting/src/main/java/org/jboss/fresh/deployer/ScriptingServiceMBean.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/ctx/
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/remoteshell/
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/remoteshell/ejb/
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/remoteshell/ejb/impl/
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/remoteshell/ejb/impl/RemoteShellImpl.java
Removed:
   projects/fresh/trunk/fresh-scripting/src/main/java/org/jboss/fresh/parsek/
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/cp2/
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/ctx/
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/debug/
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/remoteshell/ejb/impl/RemoteShellImpl.java
Modified:
   projects/fresh/trunk/etc/0010-cp2-system-service.xml
   projects/fresh/trunk/etc/0020-cp2-threadpool-service.xml
   projects/fresh/trunk/etc/0040-cp2-vfs-service.xml
   projects/fresh/trunk/etc/0050-cp2-systemshell-service.xml
   projects/fresh/trunk/etc/0053-cp2-scripting-service.xml
   projects/fresh/trunk/etc/0055-cp2-staticinit-service.xml
   projects/fresh/trunk/etc/0062-cp2-ssh-service.xml
   projects/fresh/trunk/fresh-scripting/src/main/java/org/jboss/fresh/shell/commands/ScriptExe.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/ctx/Context.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/ctx/FlatContext.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/ctx/JNDICtx.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/Event.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/EventBroadcaster.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/EventCentral.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/EventFilter.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/EventFilter2.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/EventListener.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/InvalidFormatException.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/RegistrationException.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/impl/EventCentralImpl.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/impl/RemoteShellEventNetConnector.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/net/ConnectorException.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/net/EventNetConnector.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/net/EventNetRouter.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/net/EventNetRouterImpl.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/net/TakenOverException.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/Shell.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/ContextExe.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/EventCentralQueryExe.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/EventNetAgentExe.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/EventsExe.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/HistoryExe.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/cms/CtxDelegateExe.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/ejb/UnremoterShell.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/events/ShellEvent.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/events/ShellEventBroadcaster.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/ShellImpl.java
   projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/ShellRuntime.java
   projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/io/IOUtils.java
   projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/io/InputStreamReader.java
   projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/io/NullOutputStream.java
   projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/io/ObjectFIFO.java
   projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/io/URLConnectionReader.java
   projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/util/ConfigurationChangeWatcher.java
   projects/fresh/trunk/pom.xml
Log:
deployers

Modified: projects/fresh/trunk/etc/0010-cp2-system-service.xml
===================================================================
--- projects/fresh/trunk/etc/0010-cp2-system-service.xml	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/etc/0010-cp2-system-service.xml	2009-04-29 16:31:09 UTC (rev 88013)
@@ -3,14 +3,14 @@
 <!--  # # #  SYSTEM  # # # -->
 <!-- we should change this ... don't use constructor to initialize parameters. -->
 <server>
-	<!--mbean code="org.jboss.fresh.parsek.deployer.modules.Cp2ConfigurationService" name="FRESH:service=Cp2ConfigurationService">
+	<mbean code="org.jboss.fresh.deployer.deployer.Cp2ConfigurationService" name="FRESH:service=Cp2ConfigurationService">
 		<attribute name="JNDIName">java:/FRESH/Configuration</attribute>
                 <attribute name="Properties">
 				cp2.UserTransaction.jndiName=UserTransaction
 		</attribute>
-	</mbean-->
+	</mbean>
 
-    <mbean code="org.jboss.fresh.parsek.deployer.modules.ContextBinder" name="FRESH:service=GlobalContext">
+    <mbean code="org.jboss.fresh.deployer.deployer.ContextBinder" name="FRESH:service=GlobalContext">
 	    <attribute name="JNDIName">java:/FRESH/GlobalContext</attribute>
     </mbean>
 

Modified: projects/fresh/trunk/etc/0020-cp2-threadpool-service.xml
===================================================================
--- projects/fresh/trunk/etc/0020-cp2-threadpool-service.xml	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/etc/0020-cp2-threadpool-service.xml	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <server>
-  <mbean code="org.jboss.fresh.parsek.deployer.modules.PoolService" name="FRESH:service=ThreadPool">
+  <mbean code="org.jboss.fresh.deployer.deployer.PoolService" name="FRESH:service=ThreadPool">
 		<attribute name="JNDIName">java:/FRESH/ThreadPool</attribute>
 		<attribute name="FactoryName">org.jboss.fresh.cpii.services.PoolRunnerFactory</attribute>
 		<attribute name="PoolName">ThreadPool</attribute>

Modified: projects/fresh/trunk/etc/0040-cp2-vfs-service.xml
===================================================================
--- projects/fresh/trunk/etc/0040-cp2-vfs-service.xml	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/etc/0040-cp2-vfs-service.xml	2009-04-29 16:31:09 UTC (rev 88013)
@@ -2,7 +2,7 @@
 
 <server>
 
-        <mbean code="org.jboss.fresh.parsek.deployer.modules.VFSService" name="FRESH:service=VFS.Mem">
+        <mbean code="org.jboss.fresh.deployer.deployer.VFSService" name="FRESH:service=VFS.Mem">
                 <attribute name="JNDIName">java:/FRESH/VFSMem</attribute>
                 <attribute name="VFSImpl">org.jboss.fresh.vfs.impl.DefaultVFS</attribute>
                 <attribute name="MetaClassFactory">org.jboss.fresh.vfs.impl.mem.MemVFSMetaFactory</attribute>
@@ -13,7 +13,7 @@
                 <depends>FRESH:service=Cp2ConfigurationService</depends>
         </mbean>
 
-        <mbean code="org.jboss.fresh.parsek.deployer.modules.RootVFSService" name="FRESH:service=VFS.Root">
+        <mbean code="org.jboss.fresh.deployer.deployer.RootVFSService" name="FRESH:service=VFS.Root">
                 <attribute name="JNDIName">java:/FRESH/VFS</attribute>
                 <attribute name="Automount">/=java:/FRESH/VFSMem</attribute>
                 <depends>FRESH:service=VFS.Mem</depends>

Modified: projects/fresh/trunk/etc/0050-cp2-systemshell-service.xml
===================================================================
--- projects/fresh/trunk/etc/0050-cp2-systemshell-service.xml	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/etc/0050-cp2-systemshell-service.xml	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <server>
-	<mbean code="org.jboss.fresh.parsek.deployer.modules.SystemShellService" name="FRESH:service=SystemShell">
+	<mbean code="org.jboss.fresh.deployer.deployer.SystemShellService" name="FRESH:service=SystemShell">
 		<attribute name="JNDIName">java:/FRESH/SystemShell</attribute>
 		<attribute name="ThreadPoolJNDIName">java:/FRESH/ThreadPool</attribute>
 		<attribute name="VFSJNDIName">java:/FRESH/VFS</attribute>

Modified: projects/fresh/trunk/etc/0053-cp2-scripting-service.xml
===================================================================
--- projects/fresh/trunk/etc/0053-cp2-scripting-service.xml	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/etc/0053-cp2-scripting-service.xml	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <server>
-	<mbean code="org.jboss.fresh.parsek.deployer.modules.ScriptingService" name="FRESH:service=Scripting">
+	<mbean code="org.jboss.fresh.deployer.ScriptingService" name="FRESH:service=Scripting">
 		<attribute name="JNDIName">java:/FRESH/Scripting</attribute>
 		<depends>FRESH:service=SystemShell</depends>
 		<depends>FRESH:service=VFS.Mem.Init</depends>

Modified: projects/fresh/trunk/etc/0055-cp2-staticinit-service.xml
===================================================================
--- projects/fresh/trunk/etc/0055-cp2-staticinit-service.xml	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/etc/0055-cp2-staticinit-service.xml	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <server>
-	<mbean code="org.jboss.fresh.parsek.deployer.modules.ShellExecutorService" name="FRESH:service=ShellExecutor,name=StaticInit">
+	<mbean code="org.jboss.fresh.deployer.deployer.ShellExecutorService" name="FRESH:service=ShellExecutor,name=StaticInit">
 		<attribute name="BatchFile">../cp2/vfs/init/static-init.sh</attribute>
 		<attribute name="StopOnError">false</attribute>
 		<attribute name="LogFile">../cp2/vfs/init/static-init.log</attribute>

Modified: projects/fresh/trunk/etc/0062-cp2-ssh-service.xml
===================================================================
--- projects/fresh/trunk/etc/0062-cp2-ssh-service.xml	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/etc/0062-cp2-ssh-service.xml	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <server>
-	<mbean code="org.jboss.fresh.parsek.deployer.modules.SSHService" name="CP2:service=SSHServer">
+	<mbean code="org.jboss.fresh.deployer.deployer.SSHService" name="CP2:service=SSHServer">
 		<attribute name="HomeDirectory">../cp2/ssh/</attribute>
 		<depends>CP2:service=SystemShell</depends>
 		<depends>CP2:service=VFS.Mem.Init</depends>

Copied: projects/fresh/trunk/fresh-scripting/src/main/java/org/jboss/fresh/deployer/ScriptingCentral.java (from rev 88008, projects/fresh/trunk/fresh-scripting/src/main/java/org/jboss/fresh/parsek/cp2/scripting/ScriptingCentral.java)
===================================================================
--- projects/fresh/trunk/fresh-scripting/src/main/java/org/jboss/fresh/deployer/ScriptingCentral.java	                        (rev 0)
+++ projects/fresh/trunk/fresh-scripting/src/main/java/org/jboss/fresh/deployer/ScriptingCentral.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -0,0 +1,17 @@
+package org.jboss.fresh.deployer;
+
+import java.util.List;
+import org.apache.bsf.BSFManager;
+
+public interface ScriptingCentral {
+	
+	public void setConfigPath(String val);
+	public String getConfigPath();
+	public void addProvider(String language, String filext, String clazz);
+	public void registerEventAdapter(String listenerClass, String adapterClass);
+	public List getSupportedLanguages();
+	public String getLanguageForExtension(String ext);
+	public String getLanguageForName(String name);
+	public boolean isLanguageSupported(String name);
+	public BSFManager getManager(String lang);
+}
\ No newline at end of file

Added: projects/fresh/trunk/fresh-scripting/src/main/java/org/jboss/fresh/deployer/ScriptingService.java
===================================================================
--- projects/fresh/trunk/fresh-scripting/src/main/java/org/jboss/fresh/deployer/ScriptingService.java	                        (rev 0)
+++ projects/fresh/trunk/fresh-scripting/src/main/java/org/jboss/fresh/deployer/ScriptingService.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -0,0 +1,338 @@
+package org.jboss.fresh.deployer;
+
+/**
+ *
+ * The usage would be something like: 
+ *
+ *   List l = svc.getSupportedLanguages();
+ *
+ *   // check if the language of our script is supported
+ *
+ *   BSFManager mgr = svc.getManager("javascript");
+ *
+ *   mgr.declareBean("out", System.out, System.out.getClass());
+ *   mgr.exec("javascript", "nofile", 0, 0, IOUtils.getStringFromReader(reader));
+ *   mgr.terminate();
+ *
+ */
+
+
+/*
+ *   // register our own events so we can register event handlers in script
+ *
+ *   svc.registerEventAdapter(new com.ibm.bsf.util.event.EventAdapterImpl() implements ScriptListener {
+ *     public void eventPerformed(ScriptEvent e){
+ *        eventProcessor.processEvent("scriptEventPerformed",new Object[]{e});
+ *     }
+ *   });
+ *   interface MyEventListener extends java.util.EventListener {
+ *     public void event(MyEvent e);
+ *   }
+*/
+
+
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.parsers.SAXParser;
+
+import org.apache.bsf.BSFManager;
+import org.apache.bsf.util.event.EventAdapterRegistry;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+import org.jboss.fresh.deployer.ScriptingCentral;
+
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.net.URL;
+import java.util.StringTokenizer;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.LinkedList;
+
+
+public class ScriptingService extends RegistryNamingBinder implements ScriptingServiceMBean {
+
+	private String cfgPath;
+	private List langs = new LinkedList();
+	private List languages = new LinkedList();
+
+	public String getName() {
+		return "Scripting Services";
+	}
+
+	// if not set we use a context classloader
+	public void setConfigPath(String val) {
+		cfgPath = val;
+	}
+	
+	public String getConfigPath() {
+		return cfgPath;
+	}
+	
+	
+	// The format of the config file
+	/*
+	
+	<scripting>
+		<provider language="javascript"  ext="js"  class="com.ibm.bsf.engines.javascript.JavaScriptEngine" />
+		<provider language="jython"      ext="jy"  class="com.ibm.bsf.engines.jython.JythonEngine" />
+		<provider language="beanshell"   ext="bsh" class="bsh.util.BeanShellBSFEngine" />
+		<provider language="judoscript"  ext="jud;judo" class="com.judoscript.BSFJudoEngine" />
+
+		<event-adaper listener-class="" adapter-class="" />
+		<event-adaper listener-class="" adapter-class="" />
+		<event-adaper listener-class="" adapter-class="" />
+	</scripting>
+	
+	*/
+	
+	public void doStart() throws Exception {
+		// lookup the config file and initialize stuff
+		
+		SAXParserFactory factory = SAXParserFactory.newInstance();
+		SAXParser parser = factory.newSAXParser();
+	
+		
+		InputStream in = null;
+		
+		if(cfgPath!=null) {
+			in = new FileInputStream(cfgPath);
+		} else {
+		        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+	        	URL url = cl.getResource("cp2-scripting.xml");
+	        	if (url != null) {
+		        	in = url.openStream();
+		        }
+		}
+		
+		parser.parse(in, new DefaultHandler() {
+		
+			int level = 0;
+			
+			public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
+		
+			   if(level==1) {
+				if(qName.equals("provider")) {
+	
+					String clazz = null;
+					String lang = null;
+					String ext = null;
+
+
+					int len = attrs.getLength();
+					for(int i=0; i<len; i++) {
+						String aname = attrs.getQName(i);
+						String   val = attrs.getValue(i);
+	
+						if(aname.equals("language")) {
+							lang = val;
+						} else if(aname.equals("ext")) {
+							ext = val;
+						} else if(aname.equals("class")) {
+							clazz = val;
+						} else {
+							throw new SAXException("Element provider does not support attribute: " + aname);
+						}
+					}
+
+					addProvider(lang, ext, clazz);
+
+				} else if(qName.equals("event-adapter")) {
+
+					String listener = null;
+					String adapter = null;
+
+					int len = attrs.getLength();
+					for(int i=0; i<len; i++) {
+						String aname = attrs.getQName(i);
+						String   val = attrs.getValue(i);
+	
+						if(aname.equals("listener-class")) {
+							listener = val;
+						} else if(aname.equals("adapter-class")) {
+							adapter = val;
+						} else {
+							throw new SAXException("Element event-adapter does not support attribute: " + aname);
+						}
+					}
+					
+					registerEventAdapter(listener, adapter);
+
+				} else {
+					throw new SAXException("Unknown element: " + qName);
+				}
+				
+			   } else if(level==0) {
+				if(!qName.equals("scripting"))
+					throw new SAXException("Unknown element: " + qName);
+
+			   }
+
+			   level++;
+			}
+			
+			public void endElement(String uri, String localName, String qName) {
+			   level--;
+			}
+		});
+	
+
+		super.doStart();
+	
+	}
+
+
+	public BSFManager getManager(String lang) {
+		Language scriptLang = getLanguage(lang);		
+		if(scriptLang==null) throw new RuntimeException("Language not supported: " + lang);
+		
+		BSFManager manager=new BSFManager();
+		BSFManager.registerScriptingEngine(scriptLang.getIdentifier(),scriptLang.getScriptEngine(),scriptLang.getExtensions());
+
+		return manager;
+	}
+
+
+	public void registerEventAdapter(String listenerClass, String adapterClass) {
+
+		ClassLoader cl = Thread.currentThread().getContextClassLoader();
+		Class cls1 = null;
+		Class cls2 = null;
+
+		try {
+			cls1 = cl.loadClass(listenerClass);
+		} catch(Exception ex) {
+			throw new RuntimeException("Failed to load class: " + listenerClass, ex);
+		}
+
+		try {
+			cls2 = cl.loadClass(adapterClass);	
+		} catch(Exception ex) {
+			throw new RuntimeException("Failed to load class: " + adapterClass, ex);
+		}
+
+		EventAdapterRegistry.register(cls1, cls2);
+	}
+
+
+	public void addProvider(String language, String filext, String clazz) {
+
+		if(language==null) throw new IllegalArgumentException("Language can't be null");
+		if(clazz==null) throw new IllegalArgumentException("Class can't be null");
+
+		// parse file extensions;
+		LinkedList exts = new LinkedList();
+		String [] aexts;
+		if(filext!=null) {
+			StringTokenizer st = new StringTokenizer(filext, "; ");
+			while(st.hasMoreTokens()) {
+				exts.add(st.nextToken());
+			}
+		}
+
+		aexts = new String[exts.size()];
+		Iterator it = exts.iterator();
+		for(int i=0; it.hasNext(); i++) {
+			aexts[i]=(String)it.next();
+		}
+
+	        languages.add(new Language(language, aexts, clazz));
+	        langs.add(language);
+	}
+
+
+	private Language getLanguage(String lang){
+
+	        Iterator it = languages.iterator();
+	        while(it.hasNext()) {
+	        	Language l = (Language)it.next();
+	        	if(l.getIdentifier().equals(lang)) return l;
+	        }
+
+		return null;
+	}
+
+	public List getSupportedLanguages() {
+		return new ArrayList(langs);
+	}
+
+
+	protected String getBindClass() {
+		return ScriptingCentral.class.getName();
+	}
+
+	protected Object classToInstance(Class c) {
+		setServiceObject( this );
+		//return new ScriptingServiceJMXProxy(getRegisteredName());
+		//return java.lang.reflect.Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class [] {com.parsek.cp2.scripting.ScriptingCentral.class}, new JMXProxyHandler(getRegisteredName()));
+		return this;
+	}
+ 
+ 	
+ 	// 
+ 	public boolean isLanguageSupported(String name) {
+		Iterator it = new ArrayList(langs).iterator();
+		while(it.hasNext()) {
+			if(it.next().equals(name)) return true;
+		}
+		
+		return false;
+	}
+	
+ 	// if we support aliases we return a logical name of the language
+ 	public String getLanguageForName(String name) {
+		Iterator it = new ArrayList(langs).iterator();
+		while(it.hasNext()) {
+			if(it.next().equals(name)) return name;
+		}
+		
+		return null;
+ 	}
+ 	
+ 	// we try determine a language for this extension
+ 	public String getLanguageForExtension(String ext) {
+ 		Iterator it = new ArrayList(languages).iterator();
+		while(it.hasNext()) {
+			Language lng = (Language)it.next();
+			String [] extz = lng.getExtensions();
+			for(int i=0; i<extz.length; i++) {
+				if(extz[i].equals(ext)) return lng.getIdentifier();
+			}
+		}
+
+		return null;
+ 	}
+
+
+
+    protected boolean bindByReference() {
+	return true;
+    }
+
+
+    public class Language {
+
+        private String identifier;
+        private String[] extensions;
+        private String scriptEngine;
+
+        public Language(String identifier,String[] extensions, String scriptEngine){
+            this.identifier=identifier;
+            this.extensions=extensions;
+            this.scriptEngine=scriptEngine;
+        }
+
+        public String getIdentifier(){
+            return identifier;
+        }
+        public String[] getExtensions(){
+            return extensions;
+        }
+        public String getScriptEngine(){
+            return scriptEngine;
+        }
+
+    }
+
+}
\ No newline at end of file

Added: projects/fresh/trunk/fresh-scripting/src/main/java/org/jboss/fresh/deployer/ScriptingServiceMBean.java
===================================================================
--- projects/fresh/trunk/fresh-scripting/src/main/java/org/jboss/fresh/deployer/ScriptingServiceMBean.java	                        (rev 0)
+++ projects/fresh/trunk/fresh-scripting/src/main/java/org/jboss/fresh/deployer/ScriptingServiceMBean.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -0,0 +1,8 @@
+package org.jboss.fresh.deployer;
+
+import org.jboss.fresh.deployer.ScriptingCentral;
+import org.jboss.fresh.deployer.RegistryNamingBinderMBean;
+
+public interface ScriptingServiceMBean extends ScriptingCentral, RegistryNamingBinderMBean {
+
+}
\ No newline at end of file

Modified: projects/fresh/trunk/fresh-scripting/src/main/java/org/jboss/fresh/shell/commands/ScriptExe.java
===================================================================
--- projects/fresh/trunk/fresh-scripting/src/main/java/org/jboss/fresh/shell/commands/ScriptExe.java	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/fresh-scripting/src/main/java/org/jboss/fresh/shell/commands/ScriptExe.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -11,8 +11,8 @@
 import org.jboss.fresh.vfs.impl.SecureVFS;
 import org.jboss.fresh.vfs.VFS;
 import org.jboss.fresh.vfs.FileName;
-import org.jboss.fresh.parsek.ctx.Context;
-import org.jboss.fresh.parsek.cp2.scripting.ScriptingCentral;
+import org.jboss.fresh.ctx.Context;
+import org.jboss.fresh.deployer.ScriptingCentral;
 import org.jboss.fresh.io.BufferInputStream;
 import org.jboss.fresh.io.BufferOutputStream;
 import org.jboss.fresh.io.BufferReader;
@@ -308,7 +308,7 @@
         out.print("    shell     ...  org.jboss.fresh.shell.impl.ShellImpl\n");
         out.print("    instream  ...  java.io.InputStream wrapped around stdin\n");
         out.print("    outstream ...  java.io.OutputStream wrapped around stdout\n");
-        out.print("    context   ...  org.jboss.fresh.parsek.ctx.Context - shell.getContext()\n");
+        out.print("    context   ...  org.jboss.fresh.ctx.Context - shell.getContext()\n");
         out.print("    props     ...  java.util.Properties - shell.getEnvProperties()\n");
         out.print("    out       ...  java.io.PrintWriter - wrapped around stdout\n");
         out.print("    cin       ...  java.io.BufferedReader - wrapped around stdin\n");

Copied: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/ctx (from rev 88008, projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/ctx)

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/ctx/Context.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/ctx/Context.java	2009-04-29 15:25:08 UTC (rev 88008)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/ctx/Context.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,4 +1,4 @@
-package org.jboss.fresh.parsek.ctx;
+package org.jboss.fresh.ctx;
 
 import java.util.Map;
 

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/ctx/FlatContext.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/ctx/FlatContext.java	2009-04-29 15:25:08 UTC (rev 88008)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/ctx/FlatContext.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,4 +1,4 @@
-package org.jboss.fresh.parsek.ctx;
+package org.jboss.fresh.ctx;
 
 import java.util.HashMap;
 import java.util.Map;

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/ctx/JNDICtx.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/ctx/JNDICtx.java	2009-04-29 15:25:08 UTC (rev 88008)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/ctx/JNDICtx.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,4 +1,4 @@
-package org.jboss.fresh.parsek.ctx;
+package org.jboss.fresh.ctx;
 
 import org.jboss.fresh.registry.RegistryContext;
 import java.util.Iterator;

Copied: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events (from rev 88008, projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/cp2/events)

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/Event.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/cp2/events/Event.java	2009-04-29 15:25:08 UTC (rev 88008)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/Event.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,4 +1,4 @@
-package org.jboss.fresh.parsek.cp2.events;
+package org.jboss.fresh.events;
 
 import java.util.LinkedList;
 

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/EventBroadcaster.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/cp2/events/EventBroadcaster.java	2009-04-29 15:25:08 UTC (rev 88008)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/EventBroadcaster.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,4 +1,4 @@
-package org.jboss.fresh.parsek.cp2.events;
+package org.jboss.fresh.events;
 
 
 public class EventBroadcaster {

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/EventCentral.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/cp2/events/EventCentral.java	2009-04-29 15:25:08 UTC (rev 88008)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/EventCentral.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,7 +1,7 @@
-package org.jboss.fresh.parsek.cp2.events;
+package org.jboss.fresh.events;
 
-import org.jboss.fresh.parsek.cp2.events.InvalidFormatException;
-import org.jboss.fresh.parsek.cp2.events.net.EventNetRouter;
+import org.jboss.fresh.events.InvalidFormatException;
+import org.jboss.fresh.events.net.EventNetRouter;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/EventFilter.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/cp2/events/EventFilter.java	2009-04-29 15:25:08 UTC (rev 88008)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/EventFilter.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,4 +1,4 @@
-package org.jboss.fresh.parsek.cp2.events;
+package org.jboss.fresh.events;
 
 import org.jboss.fresh.util.StringUtils;
 

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/EventFilter2.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/cp2/events/EventFilter2.java	2009-04-29 15:25:08 UTC (rev 88008)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/EventFilter2.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,4 +1,4 @@
-package org.jboss.fresh.parsek.cp2.events;
+package org.jboss.fresh.events;
 
 import java.util.List;
 import java.util.LinkedList;

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/EventListener.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/cp2/events/EventListener.java	2009-04-29 15:25:08 UTC (rev 88008)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/EventListener.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,4 +1,4 @@
-package org.jboss.fresh.parsek.cp2.events;
+package org.jboss.fresh.events;
 
 public interface EventListener {
 	public void event(Event ev);

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/InvalidFormatException.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/cp2/events/InvalidFormatException.java	2009-04-29 15:25:08 UTC (rev 88008)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/InvalidFormatException.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,4 +1,4 @@
-package org.jboss.fresh.parsek.cp2.events;
+package org.jboss.fresh.events;
 
 public class InvalidFormatException extends Exception {
 

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/RegistrationException.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/cp2/events/RegistrationException.java	2009-04-29 15:25:08 UTC (rev 88008)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/RegistrationException.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,4 +1,4 @@
-package org.jboss.fresh.parsek.cp2.events;
+package org.jboss.fresh.events;
 
 public class RegistrationException extends Exception {
 

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/impl/EventCentralImpl.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/cp2/events/impl/EventCentralImpl.java	2009-04-29 15:25:08 UTC (rev 88008)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/impl/EventCentralImpl.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,13 +1,13 @@
-package org.jboss.fresh.parsek.cp2.events.impl;
+package org.jboss.fresh.events.impl;
 
-import org.jboss.fresh.parsek.cp2.events.EventCentral;
-import org.jboss.fresh.parsek.cp2.events.EventListener;
-import org.jboss.fresh.parsek.cp2.events.EventFilter;
-import org.jboss.fresh.parsek.cp2.events.Event;
-import org.jboss.fresh.parsek.cp2.events.EventBroadcaster;
-import org.jboss.fresh.parsek.cp2.events.RegistrationException;
-import org.jboss.fresh.parsek.cp2.events.InvalidFormatException;
-import org.jboss.fresh.parsek.cp2.events.net.EventNetRouter;
+import org.jboss.fresh.events.EventCentral;
+import org.jboss.fresh.events.EventListener;
+import org.jboss.fresh.events.EventFilter;
+import org.jboss.fresh.events.Event;
+import org.jboss.fresh.events.EventBroadcaster;
+import org.jboss.fresh.events.RegistrationException;
+import org.jboss.fresh.events.InvalidFormatException;
+import org.jboss.fresh.events.net.EventNetRouter;
 
 import java.util.Map;
 import java.util.HashMap;

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/impl/RemoteShellEventNetConnector.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/cp2/events/impl/RemoteShellEventNetConnector.java	2009-04-29 15:25:08 UTC (rev 88008)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/impl/RemoteShellEventNetConnector.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,9 +1,9 @@
-package org.jboss.fresh.parsek.cp2.events.impl;
+package org.jboss.fresh.events.impl;
 
-import org.jboss.fresh.parsek.cp2.events.Event;
-import org.jboss.fresh.parsek.cp2.events.net.EventNetConnector;
-import org.jboss.fresh.parsek.cp2.events.net.ConnectorException;
-import org.jboss.fresh.parsek.cp2.events.net.TakenOverException;
+import org.jboss.fresh.events.Event;
+import org.jboss.fresh.events.net.EventNetConnector;
+import org.jboss.fresh.events.net.ConnectorException;
+import org.jboss.fresh.events.net.TakenOverException;
 import org.jboss.fresh.shell.ProcessInfo;
 import org.jboss.fresh.shell.ejb.RemoteShell;
 import org.jboss.fresh.shell.ejb.RemoteShellHome;
@@ -265,7 +265,7 @@
 			if(th instanceof org.jboss.fresh.io.ApplicationIOException) {
 				log.debug("CATCH  ApplicationIOException ");
 				th = th.getCause();
-				if(th instanceof org.jboss.fresh.parsek.cp2.events.net.TakenOverException) {
+				if(th instanceof org.jboss.fresh.events.net.TakenOverException) {
 					log.debug("CATCH  TakenOverException ");
 					throw (TakenOverException) th;
 				}
@@ -278,7 +278,7 @@
 					if(th instanceof ThrowableProxy) {
 						log.debug("CATCH ThrowableProxy ");
 						cname = ((ThrowableProxy) th).getClassName();
-						if("org.jboss.fresh.parsek.cp2.events.net.TakenOverException".equals(cname)) {
+						if("org.jboss.fresh.events.net.TakenOverException".equals(cname)) {
 							log.debug("CATCH LC TakenOverException ");
 							throw new TakenOverException(th.getMessage());
 						}
@@ -326,7 +326,7 @@
 			if(th instanceof org.jboss.fresh.io.ApplicationIOException) {
 				log.debug("CATCH  ApplicationIOException ");
 				th = th.getCause();
-				if(th instanceof org.jboss.fresh.parsek.cp2.events.net.TakenOverException) {
+				if(th instanceof org.jboss.fresh.events.net.TakenOverException) {
 					log.debug("CATCH  TakenOverException ");
 					throw (TakenOverException) th;
 				}
@@ -341,7 +341,7 @@
 					if(th instanceof ThrowableProxy) {
 						log.debug("CATCH ThrowableProxy ");
 						cname = ((ThrowableProxy) th).getClassName();
-						if("org.jboss.fresh.parsek.cp2.events.net.TakenOverException".equals(cname)) {
+						if("org.jboss.fresh.events.net.TakenOverException".equals(cname)) {
 							log.debug("CATCH LC TakenOverException ");
 							throw new TakenOverException(th.getMessage());
 						} else if("org.jboss.fresh.shell.UninitializedEnvironmentException".equals(cname)) {

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/net/ConnectorException.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/cp2/events/net/ConnectorException.java	2009-04-29 15:25:08 UTC (rev 88008)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/net/ConnectorException.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,4 +1,4 @@
-package org.jboss.fresh.parsek.cp2.events.net;
+package org.jboss.fresh.events.net;
 
 public class ConnectorException extends Exception {
 

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/net/EventNetConnector.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/cp2/events/net/EventNetConnector.java	2009-04-29 15:25:08 UTC (rev 88008)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/net/EventNetConnector.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,4 +1,4 @@
-package org.jboss.fresh.parsek.cp2.events.net;
+package org.jboss.fresh.events.net;
 
 import java.util.List;
 import java.io.IOException;

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/net/EventNetRouter.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/cp2/events/net/EventNetRouter.java	2009-04-29 15:25:08 UTC (rev 88008)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/net/EventNetRouter.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,4 +1,4 @@
-package org.jboss.fresh.parsek.cp2.events.net;
+package org.jboss.fresh.events.net;
 
 public interface EventNetRouter {
 

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/net/EventNetRouterImpl.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/cp2/events/net/EventNetRouterImpl.java	2009-04-29 15:25:08 UTC (rev 88008)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/net/EventNetRouterImpl.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,11 +1,11 @@
-package org.jboss.fresh.parsek.cp2.events.net;
+package org.jboss.fresh.events.net;
 
-import org.jboss.fresh.parsek.cp2.events.Event;
-import org.jboss.fresh.parsek.cp2.events.EventBroadcaster;
-import org.jboss.fresh.parsek.cp2.events.EventCentral;
-import org.jboss.fresh.parsek.cp2.events.EventFilter;
-import org.jboss.fresh.parsek.cp2.events.EventListener;
-import org.jboss.fresh.parsek.cp2.events.InvalidFormatException;
+import org.jboss.fresh.events.Event;
+import org.jboss.fresh.events.EventBroadcaster;
+import org.jboss.fresh.events.EventCentral;
+import org.jboss.fresh.events.EventFilter;
+import org.jboss.fresh.events.EventListener;
+import org.jboss.fresh.events.InvalidFormatException;
 import org.jboss.fresh.io.Buffer;
 import org.jboss.fresh.io.BufferImpl;
 import org.apache.log4j.Logger;

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/net/TakenOverException.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/cp2/events/net/TakenOverException.java	2009-04-29 15:25:08 UTC (rev 88008)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/events/net/TakenOverException.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,4 +1,4 @@
-package org.jboss.fresh.parsek.cp2.events.net;
+package org.jboss.fresh.events.net;
 
 public class TakenOverException extends ConnectorException {
 

Copied: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/remoteshell/ejb/impl (from rev 88008, projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/cp2/remoteshell/ejb/impl)

Deleted: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/remoteshell/ejb/impl/RemoteShellImpl.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/cp2/remoteshell/ejb/impl/RemoteShellImpl.java	2009-04-29 15:25:08 UTC (rev 88008)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/remoteshell/ejb/impl/RemoteShellImpl.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,751 +0,0 @@
-package org.jboss.fresh.parsek.cp2.remoteshell.ejb.impl;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Properties;
-import java.util.StringTokenizer;
-import java.util.List;
-import javax.ejb.SessionBean;
-import javax.ejb.SessionContext;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-import javax.transaction.UserTransaction;
-
-import org.jboss.fresh.vfs.vfs.UserCtx;
-import org.jboss.fresh.registry.RegistryContext;
-import org.jboss.fresh.shell.ProcessInfo;
-import org.jboss.fresh.shell.Shell;
-import org.jboss.fresh.shell.ShellException;
-import org.jboss.fresh.shell.ShellIOException;
-import org.jboss.fresh.shell.ShellInitializationException;
-import org.jboss.fresh.shell.SystemShell;
-import org.jboss.fresh.util.TxSupport;
-
-/**
- * Shell session can timeout. Using a timed-out session is like having a ghost around. Even the system is not aware of it, so
- * it can easily happen that resources are allocated and not released as long as remote object impl has a reference to shell impl
- * The logical thing to do would be to throw an exception to notify a client of a timeout. Client can then reconnect and try to repeat the action.
- * Automatic reinitalisation is very problematic since many sessions have their environment initialized at the beginning. And only client knows exactly
- * what's involved.
- *
- * @author mare
- * @version $Revision: 1.8 $
- * @modified $Author: cerar $
- */
-public class RemoteShellImpl implements SessionBean {
-	private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(RemoteShellImpl.class);
-	private static final org.apache.log4j.Logger log_cmd = org.apache.log4j.Logger.getLogger(RemoteShellImpl.class.getName() + ".commands");
-	private static final org.apache.log4j.Logger log_treplacer = org.apache.log4j.Logger.getLogger(RemoteShellImpl.class.getName() + ".throwable");
-	private static final String SYSTEM_SHELL_JNDI = "java:/SystemShell";
-	String sessid;
-	boolean interactive;
-	transient Shell shell;
-	UserCtx uctx;
-	public static final String KEEP_EXCEPTIONS_ENV_NAME = "KEEP_EXCEPTIONS";
-	private SessionContext sctx;
-
-	public void ejbCreate() throws ShellException {
-		ejbCreate(null, false, null);
-	}
-
-	public void ejbCreate(String sessid) throws ShellException {
-		ejbCreate(sessid, false, null);
-	}
-
-	public void ejbCreate(boolean interactive) throws ShellException {
-		ejbCreate(null, interactive, null);
-	}
-
-	public void ejbCreate(boolean interactive, Properties roProps) throws ShellException {
-		ejbCreate(null, interactive, roProps);
-	}
-
-	public void ejbCreate(String sessid, boolean interactive) throws ShellException {
-		ejbCreate(sessid, interactive, null);
-	}
-
-	public void ejbCreate(String sessid, boolean interactive, Properties roProps) throws ShellException {
-		this.interactive = interactive;
-		this.sessid = sessid;
-		try {
-			if (sctx != null) {
-				TxSupport.assignUTForThread(sctx.getUserTransaction());
-			}
-
-			reinitShell();
-
-			if (roProps != null) {
-				Iterator it = roProps.entrySet().iterator();
-				while (it.hasNext()) {
-					Map.Entry ent = (Map.Entry) it.next();
-					shell.setROEnvProperty((String) ent.getKey(), (String) ent.getValue());
-				}
-			}
-		} catch (Exception ex) {
-			throw new ShellInitializationException(ex);
-		} finally {
-			TxSupport.clearUTForThread();
-		}
-	}
-
-//	public void ejbPostCreate(String sessid) {
-//	}
-
-	public void ejbRemove() {
-		try {
-			if (sctx != null) {
-				TxSupport.assignUTForThread(sctx.getUserTransaction());
-			}
-
-			if (shell == null) {
-				ejbActivate();
-			}
-			if (shell != null) {
-				shell.close(); // means all processes
-			}
-			shell = null;
-			sessid = null;
-		} catch (Exception ex) {
-			if (ex instanceof org.jboss.fresh.shell.SessionTimeoutException) {
-				log.info("Shell session has timedout.");
-			} else {
-				log.error("Error while removing EJB!", ex);
-			}
-		} finally {
-			TxSupport.clearUTForThread();
-		}
-	}
-
-	public void setSessionContext(SessionContext ctx) {
-
-		sctx = ctx;
-
-		//log.debug("[RemoteShell] Session ctx set.");
-		/*
-		try {
-			 // this method never returns null
-			 Principal principal=ctx.getCallerPrincipal();
-
-			 InitialContext naming=new InitialContext();
-			 UserDirectory udir=(UserDirectory)naming.lookup("UserDirectory");
-			 uctx=udir.getUserCtx(principal);
-		} catch(Exception ex) {
-			 ex.printStackTrace();
-		}
-		*/
-	}
-
-	public void unsetSessionContext() {
-		uctx = null;
-	}
-
-	public void ejbActivate() {
-		//log.debug("ejbActivate called");
-		try {
-			if (sctx != null) {
-				TxSupport.assignUTForThread(sctx.getUserTransaction());
-			}
-			reinitShell();
-		} catch (Exception ex) {
-			if (ex instanceof org.jboss.fresh.shell.SessionTimeoutException) {
-				log.info("Shell session has timedout.");
-			} else {
-				log.error("Error while activating EJB!", ex);
-			}
-		} finally {
-			TxSupport.clearUTForThread();
-		}
-	}
-
-	public void ejbPassivate() {
-	}
-
-	private void reinitShell() throws NamingException, ShellException {
-		if (shell == null) {
-			InitialContext ctx = null;
-			SystemShell sysshell;
-			String sslookup = SYSTEM_SHELL_JNDI;
-			try {
-				ctx = new InitialContext();
-				Context env = (Context) ctx.lookup("java:comp/env");
-				sslookup = (String) env.lookup("SystemShellJNDI");
-			} catch (NameNotFoundException ex) {
-				log.info("SystemShellJNDI ENV not set. Using defaults.");
-			} finally {
-				if (ctx != null) {
-					try {
-						ctx.close();
-					} catch (Exception e) {
-						log.error("Could not close " + ctx + '!', e);
-					}
-				}
-			}
-			try {
-				sysshell = (SystemShell) new RegistryContext().lookup(sslookup);
-//			} catch(NameNotFoundException ex) {
-//				ex.printStackTrace();
-//				throw new RuntimeException(ex.getMessage());
-			} catch (NamingException ex) {
-				log.error("Error while reiniting shell!", ex);
-				throw new RuntimeException(ex);
-			}
-			if (sessid == null) {
-				shell = sysshell.startSession(uctx, interactive);
-				sessid = shell.getSessionID();
-			} else {
-				shell = sysshell.continueSession(sessid);
-			}
-			if (shell == null) {
-				throw new org.jboss.fresh.shell.SessionTimeoutException("Shell session has timed out.");
-			}
-		}
-	}
-
-	public String startNewSession() throws ShellException {
-		shell = null;
-		ejbActivate();
-		return sessid;
-	}
-
-	public ProcessInfo execute(String cmdline) throws ShellException {
-		return execute(cmdline, null);
-	}
-
-	public ProcessInfo execute(String cmdline, List input) throws ShellException {
-		try {
-			TxSupport.assignUTForThread(sctx.getUserTransaction());
-			reinitShell();
-			log_cmd.debug(cmdline);
-			return shell.execute(cmdline, input, true);
-		} catch (RuntimeException e) {
-			log.error("Error while executing " + cmdline + "!", e);
-			throw (RuntimeException) processThrowable(e);
-		} catch (org.jboss.fresh.shell.SessionTimeoutException e) {
-			log.info("Session has timed out");
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw (org.jboss.fresh.shell.SessionTimeoutException) th;
-			}
-		} catch (ShellException e) {
-			log.error("Error while executing " + cmdline + "!", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw (ShellException) th;
-			}
-		} catch (Throwable e) {
-			log.error("Error while executing " + cmdline + "!", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw new ShellException(th);
-			}
-		} finally {
-			TxSupport.clearUTForThread();
-		}
-	}
-/*
-	public String executeAsString(String cmdline) throws ShellException {
-		try {
-			reinitShell();
-			log_cmd.debug(cmdline);
-			return shell.executeAsString(cmdline, true);
-		} catch (RuntimeException e) {
-			log.error("Error while executing " + cmdline + "!", e);
-			throw (RuntimeException) processThrowable(e);
-		} catch (org.jboss.fresh.shell.SessionTimeoutException e) {
-			log.info("Session has timed out");
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw (org.jboss.fresh.shell.SessionTimeoutException) th;
-			}
-		} catch (ShellException e) {
-			log.error("Error while executing " + cmdline + "!", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw (ShellException) th;
-			}
-		} catch (Throwable e) {
-			log.error("Error while executing " + cmdline + "!", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw new ShellException(th);
-			}
-		}
-	}
-*/
-
-	public Object executeAsObject(String cmdline) throws ShellException {
-		return executeAsObject(cmdline, null);
-	}
-
-	public Object executeAsObject(String cmdline, List input) throws ShellException {
-		try {
-			UserTransaction tx = sctx.getUserTransaction();
-			TxSupport.assignUTForThread(tx);
-
-			reinitShell();
-			log_cmd.debug(cmdline);
-			return shell.executeAsObject(cmdline, input, true);
-		} catch (RuntimeException e) {
-			log.error("Error while executing " + cmdline + "!", e);
-			throw (RuntimeException) processThrowable(e);
-		} catch (org.jboss.fresh.shell.SessionTimeoutException e) {
-			log.info("Session has timed out");
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw (org.jboss.fresh.shell.SessionTimeoutException) th;
-			}
-		} catch (ShellException e) {
-			log.error("Error while executing " + cmdline + "!", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw (ShellException) th;
-			}
-		} catch (Throwable e) {
-			log.error("Error while executing " + cmdline + "!", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw new ShellException(th);
-			}
-		} finally {
-			TxSupport.clearUTForThread();
-		}
-	}
-
-	public String getEnvProperty(String propname) throws ShellException {
-		try {
-			TxSupport.assignUTForThread(sctx.getUserTransaction());
-			reinitShell();
-			return shell.getEnvProperty(propname);
-		} catch (RuntimeException e) {
-			log.error("Error while executing getEnvProperty(" + propname + ")", e);
-			throw (RuntimeException) processThrowable(e);
-		} catch (org.jboss.fresh.shell.SessionTimeoutException e) {
-			log.error("Error while executing getEnvProperties(" + propname + ")", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw (org.jboss.fresh.shell.SessionTimeoutException) th;
-			}
-		} catch (ShellException e) {
-			log.error("Error while executing getEnvProperties(" + propname + ")", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw (ShellException) th;
-			}
-		} catch (Throwable e) {
-			log.error("Error while executing getEnvProperties(" + propname + ")", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw new ShellException(th);
-			}
-		} finally {
-			TxSupport.clearUTForThread();
-		}
-	}
-
-	public Properties getEnvProperties() throws ShellException {
-		try {
-			TxSupport.assignUTForThread(sctx.getUserTransaction());
-			reinitShell();
-			return shell.getEnvProperties();
-		} catch (RuntimeException e) {
-			log.error("Error while executing getEnvProperties()", e);
-			throw (RuntimeException) processThrowable(e);
-		} catch (org.jboss.fresh.shell.SessionTimeoutException e) {
-			log.info("Session has timed out");
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw (org.jboss.fresh.shell.SessionTimeoutException) th;
-			}
-		} catch (ShellException e) {
-			log.error("Error while executing getEnvProperties()", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw (ShellException) th;
-			}
-		} catch (Throwable e) {
-			log.error("Error while executing getEnvProperties()", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw new ShellException(th);
-			}
-		} finally {
-			TxSupport.clearUTForThread();
-		}
-	}
-
-	public void setEnvProperty(String name, String value) throws ShellException {
-		try {
-			TxSupport.assignUTForThread(sctx.getUserTransaction());
-			reinitShell();
-			shell.setEnvProperty(name, value);
-		} catch (RuntimeException e) {
-			log.error("Error while executing setEnvProperty(" + name + ", " + value + ")", e);
-			throw (RuntimeException) processThrowable(e);
-		} catch (org.jboss.fresh.shell.SessionTimeoutException e) {
-			log.info("Session has timed out");
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw (org.jboss.fresh.shell.SessionTimeoutException) th;
-			}
-		} catch (ShellException e) {
-			log.error("Error while executing setEnvProperty(" + name + ", " + value + ")", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw (ShellException) th;
-			}
-		} catch (Throwable e) {
-			log.error("Error while executing setEnvProperty(" + name + ", " + value + ")", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw new ShellException(th);
-			}
-		} finally {
-			TxSupport.clearUTForThread();
-		}
-	}
-
-	public Object read(String id) throws IOException {
-		try {
-			TxSupport.assignUTForThread(sctx.getUserTransaction());
-			reinitShell();
-			Object obj = shell.read(id);
-			//log.debug("### obj: " + obj);
-			return replaceThrowable(obj);
-		} catch (RuntimeException e) {
-			log.error("Error while executing read(" + id + ")", e);
-			throw (RuntimeException) processThrowable(e);
-		} catch (IOException e) {
-			log.error("Error while executing read(" + id + ")", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw (IOException) th;
-			}
-		} catch (Throwable e) {
-			log.error("Error while executing read(" + id + ")", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw new ShellIOException(th);
-			}
-		} finally {
-			TxSupport.assignUTForThread(sctx.getUserTransaction());
-		}
-	}
-
-	public LinkedList readBuffer(String id, int maxsize) throws IOException {
-		try {
-			TxSupport.assignUTForThread(sctx.getUserTransaction());
-			reinitShell();
-			LinkedList l = shell.readBuffer(id, maxsize);
-			//log.debug("### list: (" + l.size() +") "  + l);
-			l = replaceThrowables(l);
-			return l;
-		} catch (RuntimeException e) {
-			log.error("Error while executing readBuffer(" + id + ", " + maxsize + ")", e);
-			throw (RuntimeException) processThrowable(e);
-		} catch (IOException e) {
-			log.error("Error while executing read(" + id + ")", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw (IOException) th;
-			}
-		} catch (Throwable e) {
-			log.error("Error while executing read(" + id + ")", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw new ShellIOException(th);
-			}
-		} finally {
-			TxSupport.clearUTForThread();
-		}
-	}
-
-	public void write(String id, Object obj) throws IOException {
-		try {
-			TxSupport.assignUTForThread(sctx.getUserTransaction());
-			reinitShell();
-			shell.write(id, obj);
-		} catch (RuntimeException e) {
-			log.error("Error while executing write(" + id + ", " + obj + ")", e);
-			throw (RuntimeException) processThrowable(e);
-		} catch (IOException e) {
-			log.error("Error while executing read(" + id + ")", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw (IOException) th;
-			}
-		} catch (Throwable e) {
-			log.error("Error while executing read(" + id + ")", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw new ShellIOException(th);
-			}
-		} finally {
-			TxSupport.clearUTForThread();
-		}
-	}
-
-	public void writeBuffer(String id, LinkedList obj) throws IOException {
-		try {
-			TxSupport.assignUTForThread(sctx.getUserTransaction());
-			reinitShell();
-			shell.writeBuffer(id, obj);
-		} catch (RuntimeException e) {
-			log.error("Error while executing writeBuffer(" + id + ", " + obj + ")", e);
-			throw (RuntimeException) processThrowable(e);
-		} catch (IOException e) {
-			log.error("Error while executing read(" + id + ")", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw (IOException) th;
-			}
-		} catch (Throwable e) {
-			log.error("Error while executing read(" + id + ")", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw new ShellIOException(th);
-			}
-		} finally {
-			TxSupport.clearUTForThread();
-		}
-	}
-
-	// means only the specified process
-	public void close(String id, int streamid) throws IOException {
-		try {
-			TxSupport.assignUTForThread(sctx.getUserTransaction());
-			reinitShell();
-			shell.close(id, streamid);
-		} catch (RuntimeException e) {
-			log.error("Error while executing stream close (processId: " + id + ", streamId: " + streamid + ")", e);
-			throw (RuntimeException) processThrowable(e);
-		} catch (IOException e) {
-			log.error("Error while executing stream close (processId: " + id + ", streamId: " + streamid + ")", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw (IOException) th;
-			}
-		} catch (Throwable e) {
-			log.error("Error while executing stream close (processId: " + id + ", streamId: " + streamid + ")", e);
-			Throwable th = processThrowable(e);
-			if (th instanceof RuntimeException) {
-				throw  (RuntimeException) th;
-			} else {
-				throw new ShellIOException(th);
-			}
-		} finally {
-			TxSupport.clearUTForThread();
-		}
-	}
-
-	public String getSessionID() {
-		return sessid;
-	}
-
-	public boolean isValid() {
-		try {
-			reinitShell();
-			shell.using();
-		} catch (Exception ex) {
-			return false;
-		}
-		return true;
-	}
-
-	/**
-	 * This method is called to replace an ErrorEOF object with such that it has properly processed IOException
-	 * which is its payload.
-	 */
-	private Object replaceThrowable(Object o) {
-		if (o instanceof org.jboss.fresh.io.ErrorEOF) {
-			o = processThrowable(((org.jboss.fresh.io.ErrorEOF) o).getIOException());
-			if (!(o instanceof IOException)) {
-				o = new org.jboss.fresh.shell.ShellIOException((Throwable) o);
-			}
-			o = new org.jboss.fresh.io.ErrorEOF((IOException) o);
-		}
-		return o;
-	}
-
-	/**
-	 * This method is called to replace each ErrorEOF object with such that it has properly processed IOException
-	 * which is its payload.
-	 */
-	private LinkedList replaceThrowables(LinkedList l) {
-		LinkedList l2 = new LinkedList();
-		while (l.size() > 0) {
-			Object o = l.removeFirst();
-			if (o instanceof org.jboss.fresh.io.ErrorEOF) {
-				o = processThrowable(((org.jboss.fresh.io.ErrorEOF) o).getIOException());
-				if (!(o instanceof IOException)) {
-					o = new org.jboss.fresh.shell.ShellIOException((Throwable) o);
-				}
-				o = new org.jboss.fresh.io.ErrorEOF((IOException) o);
-			}
-			l2.add(o);
-		}
-		return l2;
-	}
-
-	/**
-	 * This method inspects a passed throwable for any Throwables which should not be sent to the client
-	 * and if necessary copies the entire stack trace in terms of ThrowableProxy - an extension of RuntimeException.
-	 */
-	private Throwable processThrowable(Throwable t) {
-		Throwable torig = t;
-		Throwable tnu;
-		boolean needReplace = false;
-		java.util.LinkedList ls = new java.util.LinkedList();
-		while (t != null) {
-			if (log.isDebugEnabled()) {
-				log.debug("t: " + t, t);
-			}
-			if (!isPartOfClientAPI(t.getClass())) {
-				needReplace = true;
-			}
-			tnu = new org.jboss.fresh.util.ThrowableProxy(t);
-			ls.add(tnu);
-
-			t = t.getCause();
-		}
-		t = (Throwable) ls.removeLast();
-		while (ls.size() > 0) {
-			tnu = (Throwable) ls.removeLast();
-			if (tnu == null) {
-				break;
-			}
-			tnu.initCause(t);
-			t = tnu;
-		}
-
-		if (needReplace) {
-			return t;
-		}
-		return torig;
-	}
-
-	private boolean isPartOfClientAPI(Class c) {
-		final String className = c.getName();
-
-		if (className.startsWith("java.")) {
-			return true;
-		}
-		if (className.startsWith("javax.")) {
-			return true;
-		}
-		if (className.startsWith("org.jboss.fresh.parsek.cms.")) {
-			return true;
-		}
-		String pkg = "org.jboss.fresh.shell.";
-		if (className.startsWith(pkg) && className.indexOf(".", pkg.length()) == -1) {
-			return true;
-		}
-
-		// try to get the names of classes which also should not be replaced
-		String nonreplacable;
-		try {
-			reinitShell();
-			nonreplacable = shell.getEnvProperty(KEEP_EXCEPTIONS_ENV_NAME);
-		} catch (Exception e) {
-			log_treplacer.warn("Could not read environment variable " + KEEP_EXCEPTIONS_ENV_NAME);
-			nonreplacable = "";
-		}
-
-		log_treplacer.info(KEEP_EXCEPTIONS_ENV_NAME + " = " + nonreplacable);
-
-		if(nonreplacable == null)
-		    return false;
-		
-		final StringTokenizer st = new StringTokenizer(nonreplacable, "\r\n ;,:");
-		while (st.hasMoreTokens()) {
-			final String el = st.nextToken();
-			if (matches(className, el)) {
-				return true;
-			}
-		}
-
-		return false;
-	}
-
-	private boolean matches(final String value, String search) {
-		if (search == null) {
-			return false;
-		}
-
-		search = search.trim();
-
-		if ("".equals(search)) {
-			return false;
-		}
-
-		final String s = search
-			.replaceAll("\\.", "\\.")
-			.replaceAll("\\?", ".")
-			.replaceAll("\\*", ".*");
-
-		final boolean b = value.startsWith(s);  // matches(s);
-
-		log_treplacer.debug(value + " matches " + s + "? " + b + ", orig: " + search);
-
-		return b;
-
-	}
-
-}
\ No newline at end of file

Copied: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/remoteshell/ejb/impl/RemoteShellImpl.java (from rev 88010, projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/parsek/cp2/remoteshell/ejb/impl/RemoteShellImpl.java)
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/remoteshell/ejb/impl/RemoteShellImpl.java	                        (rev 0)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/remoteshell/ejb/impl/RemoteShellImpl.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -0,0 +1,751 @@
+package org.jboss.fresh.remoteshell.ejb.impl;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.List;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+import javax.transaction.UserTransaction;
+
+import org.jboss.fresh.vfs.UserCtx;
+import org.jboss.fresh.registry.RegistryContext;
+import org.jboss.fresh.shell.ProcessInfo;
+import org.jboss.fresh.shell.Shell;
+import org.jboss.fresh.shell.ShellException;
+import org.jboss.fresh.shell.ShellIOException;
+import org.jboss.fresh.shell.ShellInitializationException;
+import org.jboss.fresh.shell.SystemShell;
+import org.jboss.fresh.util.TxSupport;
+
+/**
+ * Shell session can timeout. Using a timed-out session is like having a ghost around. Even the system is not aware of it, so
+ * it can easily happen that resources are allocated and not released as long as remote object impl has a reference to shell impl
+ * The logical thing to do would be to throw an exception to notify a client of a timeout. Client can then reconnect and try to repeat the action.
+ * Automatic reinitalisation is very problematic since many sessions have their environment initialized at the beginning. And only client knows exactly
+ * what's involved.
+ *
+ * @author mare
+ * @version $Revision: 1.8 $
+ * @modified $Author: cerar $
+ */
+public class RemoteShellImpl implements SessionBean {
+	private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(RemoteShellImpl.class);
+	private static final org.apache.log4j.Logger log_cmd = org.apache.log4j.Logger.getLogger(RemoteShellImpl.class.getName() + ".commands");
+	private static final org.apache.log4j.Logger log_treplacer = org.apache.log4j.Logger.getLogger(RemoteShellImpl.class.getName() + ".throwable");
+	private static final String SYSTEM_SHELL_JNDI = "java:/SystemShell";
+	String sessid;
+	boolean interactive;
+	transient Shell shell;
+	UserCtx uctx;
+	public static final String KEEP_EXCEPTIONS_ENV_NAME = "KEEP_EXCEPTIONS";
+	private SessionContext sctx;
+
+	public void ejbCreate() throws ShellException {
+		ejbCreate(null, false, null);
+	}
+
+	public void ejbCreate(String sessid) throws ShellException {
+		ejbCreate(sessid, false, null);
+	}
+
+	public void ejbCreate(boolean interactive) throws ShellException {
+		ejbCreate(null, interactive, null);
+	}
+
+	public void ejbCreate(boolean interactive, Properties roProps) throws ShellException {
+		ejbCreate(null, interactive, roProps);
+	}
+
+	public void ejbCreate(String sessid, boolean interactive) throws ShellException {
+		ejbCreate(sessid, interactive, null);
+	}
+
+	public void ejbCreate(String sessid, boolean interactive, Properties roProps) throws ShellException {
+		this.interactive = interactive;
+		this.sessid = sessid;
+		try {
+			if (sctx != null) {
+				TxSupport.assignUTForThread(sctx.getUserTransaction());
+			}
+
+			reinitShell();
+
+			if (roProps != null) {
+				Iterator it = roProps.entrySet().iterator();
+				while (it.hasNext()) {
+					Map.Entry ent = (Map.Entry) it.next();
+					shell.setROEnvProperty((String) ent.getKey(), (String) ent.getValue());
+				}
+			}
+		} catch (Exception ex) {
+			throw new ShellInitializationException(ex);
+		} finally {
+			TxSupport.clearUTForThread();
+		}
+	}
+
+//	public void ejbPostCreate(String sessid) {
+//	}
+
+	public void ejbRemove() {
+		try {
+			if (sctx != null) {
+				TxSupport.assignUTForThread(sctx.getUserTransaction());
+			}
+
+			if (shell == null) {
+				ejbActivate();
+			}
+			if (shell != null) {
+				shell.close(); // means all processes
+			}
+			shell = null;
+			sessid = null;
+		} catch (Exception ex) {
+			if (ex instanceof org.jboss.fresh.shell.SessionTimeoutException) {
+				log.info("Shell session has timedout.");
+			} else {
+				log.error("Error while removing EJB!", ex);
+			}
+		} finally {
+			TxSupport.clearUTForThread();
+		}
+	}
+
+	public void setSessionContext(SessionContext ctx) {
+
+		sctx = ctx;
+
+		//log.debug("[RemoteShell] Session ctx set.");
+		/*
+		try {
+			 // this method never returns null
+			 Principal principal=ctx.getCallerPrincipal();
+
+			 InitialContext naming=new InitialContext();
+			 UserDirectory udir=(UserDirectory)naming.lookup("UserDirectory");
+			 uctx=udir.getUserCtx(principal);
+		} catch(Exception ex) {
+			 ex.printStackTrace();
+		}
+		*/
+	}
+
+	public void unsetSessionContext() {
+		uctx = null;
+	}
+
+	public void ejbActivate() {
+		//log.debug("ejbActivate called");
+		try {
+			if (sctx != null) {
+				TxSupport.assignUTForThread(sctx.getUserTransaction());
+			}
+			reinitShell();
+		} catch (Exception ex) {
+			if (ex instanceof org.jboss.fresh.shell.SessionTimeoutException) {
+				log.info("Shell session has timedout.");
+			} else {
+				log.error("Error while activating EJB!", ex);
+			}
+		} finally {
+			TxSupport.clearUTForThread();
+		}
+	}
+
+	public void ejbPassivate() {
+	}
+
+	private void reinitShell() throws NamingException, ShellException {
+		if (shell == null) {
+			InitialContext ctx = null;
+			SystemShell sysshell;
+			String sslookup = SYSTEM_SHELL_JNDI;
+			try {
+				ctx = new InitialContext();
+				Context env = (Context) ctx.lookup("java:comp/env");
+				sslookup = (String) env.lookup("SystemShellJNDI");
+			} catch (NameNotFoundException ex) {
+				log.info("SystemShellJNDI ENV not set. Using defaults.");
+			} finally {
+				if (ctx != null) {
+					try {
+						ctx.close();
+					} catch (Exception e) {
+						log.error("Could not close " + ctx + '!', e);
+					}
+				}
+			}
+			try {
+				sysshell = (SystemShell) new RegistryContext().lookup(sslookup);
+//			} catch(NameNotFoundException ex) {
+//				ex.printStackTrace();
+//				throw new RuntimeException(ex.getMessage());
+			} catch (NamingException ex) {
+				log.error("Error while reiniting shell!", ex);
+				throw new RuntimeException(ex);
+			}
+			if (sessid == null) {
+				shell = sysshell.startSession(uctx, interactive);
+				sessid = shell.getSessionID();
+			} else {
+				shell = sysshell.continueSession(sessid);
+			}
+			if (shell == null) {
+				throw new org.jboss.fresh.shell.SessionTimeoutException("Shell session has timed out.");
+			}
+		}
+	}
+
+	public String startNewSession() throws ShellException {
+		shell = null;
+		ejbActivate();
+		return sessid;
+	}
+
+	public ProcessInfo execute(String cmdline) throws ShellException {
+		return execute(cmdline, null);
+	}
+
+	public ProcessInfo execute(String cmdline, List input) throws ShellException {
+		try {
+			TxSupport.assignUTForThread(sctx.getUserTransaction());
+			reinitShell();
+			log_cmd.debug(cmdline);
+			return shell.execute(cmdline, input, true);
+		} catch (RuntimeException e) {
+			log.error("Error while executing " + cmdline + "!", e);
+			throw (RuntimeException) processThrowable(e);
+		} catch (org.jboss.fresh.shell.SessionTimeoutException e) {
+			log.info("Session has timed out");
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw (org.jboss.fresh.shell.SessionTimeoutException) th;
+			}
+		} catch (ShellException e) {
+			log.error("Error while executing " + cmdline + "!", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw (ShellException) th;
+			}
+		} catch (Throwable e) {
+			log.error("Error while executing " + cmdline + "!", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw new ShellException(th);
+			}
+		} finally {
+			TxSupport.clearUTForThread();
+		}
+	}
+/*
+	public String executeAsString(String cmdline) throws ShellException {
+		try {
+			reinitShell();
+			log_cmd.debug(cmdline);
+			return shell.executeAsString(cmdline, true);
+		} catch (RuntimeException e) {
+			log.error("Error while executing " + cmdline + "!", e);
+			throw (RuntimeException) processThrowable(e);
+		} catch (org.jboss.fresh.shell.SessionTimeoutException e) {
+			log.info("Session has timed out");
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw (org.jboss.fresh.shell.SessionTimeoutException) th;
+			}
+		} catch (ShellException e) {
+			log.error("Error while executing " + cmdline + "!", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw (ShellException) th;
+			}
+		} catch (Throwable e) {
+			log.error("Error while executing " + cmdline + "!", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw new ShellException(th);
+			}
+		}
+	}
+*/
+
+	public Object executeAsObject(String cmdline) throws ShellException {
+		return executeAsObject(cmdline, null);
+	}
+
+	public Object executeAsObject(String cmdline, List input) throws ShellException {
+		try {
+			UserTransaction tx = sctx.getUserTransaction();
+			TxSupport.assignUTForThread(tx);
+
+			reinitShell();
+			log_cmd.debug(cmdline);
+			return shell.executeAsObject(cmdline, input, true);
+		} catch (RuntimeException e) {
+			log.error("Error while executing " + cmdline + "!", e);
+			throw (RuntimeException) processThrowable(e);
+		} catch (org.jboss.fresh.shell.SessionTimeoutException e) {
+			log.info("Session has timed out");
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw (org.jboss.fresh.shell.SessionTimeoutException) th;
+			}
+		} catch (ShellException e) {
+			log.error("Error while executing " + cmdline + "!", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw (ShellException) th;
+			}
+		} catch (Throwable e) {
+			log.error("Error while executing " + cmdline + "!", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw new ShellException(th);
+			}
+		} finally {
+			TxSupport.clearUTForThread();
+		}
+	}
+
+	public String getEnvProperty(String propname) throws ShellException {
+		try {
+			TxSupport.assignUTForThread(sctx.getUserTransaction());
+			reinitShell();
+			return shell.getEnvProperty(propname);
+		} catch (RuntimeException e) {
+			log.error("Error while executing getEnvProperty(" + propname + ")", e);
+			throw (RuntimeException) processThrowable(e);
+		} catch (org.jboss.fresh.shell.SessionTimeoutException e) {
+			log.error("Error while executing getEnvProperties(" + propname + ")", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw (org.jboss.fresh.shell.SessionTimeoutException) th;
+			}
+		} catch (ShellException e) {
+			log.error("Error while executing getEnvProperties(" + propname + ")", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw (ShellException) th;
+			}
+		} catch (Throwable e) {
+			log.error("Error while executing getEnvProperties(" + propname + ")", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw new ShellException(th);
+			}
+		} finally {
+			TxSupport.clearUTForThread();
+		}
+	}
+
+	public Properties getEnvProperties() throws ShellException {
+		try {
+			TxSupport.assignUTForThread(sctx.getUserTransaction());
+			reinitShell();
+			return shell.getEnvProperties();
+		} catch (RuntimeException e) {
+			log.error("Error while executing getEnvProperties()", e);
+			throw (RuntimeException) processThrowable(e);
+		} catch (org.jboss.fresh.shell.SessionTimeoutException e) {
+			log.info("Session has timed out");
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw (org.jboss.fresh.shell.SessionTimeoutException) th;
+			}
+		} catch (ShellException e) {
+			log.error("Error while executing getEnvProperties()", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw (ShellException) th;
+			}
+		} catch (Throwable e) {
+			log.error("Error while executing getEnvProperties()", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw new ShellException(th);
+			}
+		} finally {
+			TxSupport.clearUTForThread();
+		}
+	}
+
+	public void setEnvProperty(String name, String value) throws ShellException {
+		try {
+			TxSupport.assignUTForThread(sctx.getUserTransaction());
+			reinitShell();
+			shell.setEnvProperty(name, value);
+		} catch (RuntimeException e) {
+			log.error("Error while executing setEnvProperty(" + name + ", " + value + ")", e);
+			throw (RuntimeException) processThrowable(e);
+		} catch (org.jboss.fresh.shell.SessionTimeoutException e) {
+			log.info("Session has timed out");
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw (org.jboss.fresh.shell.SessionTimeoutException) th;
+			}
+		} catch (ShellException e) {
+			log.error("Error while executing setEnvProperty(" + name + ", " + value + ")", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw (ShellException) th;
+			}
+		} catch (Throwable e) {
+			log.error("Error while executing setEnvProperty(" + name + ", " + value + ")", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw new ShellException(th);
+			}
+		} finally {
+			TxSupport.clearUTForThread();
+		}
+	}
+
+	public Object read(String id) throws IOException {
+		try {
+			TxSupport.assignUTForThread(sctx.getUserTransaction());
+			reinitShell();
+			Object obj = shell.read(id);
+			//log.debug("### obj: " + obj);
+			return replaceThrowable(obj);
+		} catch (RuntimeException e) {
+			log.error("Error while executing read(" + id + ")", e);
+			throw (RuntimeException) processThrowable(e);
+		} catch (IOException e) {
+			log.error("Error while executing read(" + id + ")", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw (IOException) th;
+			}
+		} catch (Throwable e) {
+			log.error("Error while executing read(" + id + ")", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw new ShellIOException(th);
+			}
+		} finally {
+			TxSupport.assignUTForThread(sctx.getUserTransaction());
+		}
+	}
+
+	public LinkedList readBuffer(String id, int maxsize) throws IOException {
+		try {
+			TxSupport.assignUTForThread(sctx.getUserTransaction());
+			reinitShell();
+			LinkedList l = shell.readBuffer(id, maxsize);
+			//log.debug("### list: (" + l.size() +") "  + l);
+			l = replaceThrowables(l);
+			return l;
+		} catch (RuntimeException e) {
+			log.error("Error while executing readBuffer(" + id + ", " + maxsize + ")", e);
+			throw (RuntimeException) processThrowable(e);
+		} catch (IOException e) {
+			log.error("Error while executing read(" + id + ")", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw (IOException) th;
+			}
+		} catch (Throwable e) {
+			log.error("Error while executing read(" + id + ")", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw new ShellIOException(th);
+			}
+		} finally {
+			TxSupport.clearUTForThread();
+		}
+	}
+
+	public void write(String id, Object obj) throws IOException {
+		try {
+			TxSupport.assignUTForThread(sctx.getUserTransaction());
+			reinitShell();
+			shell.write(id, obj);
+		} catch (RuntimeException e) {
+			log.error("Error while executing write(" + id + ", " + obj + ")", e);
+			throw (RuntimeException) processThrowable(e);
+		} catch (IOException e) {
+			log.error("Error while executing read(" + id + ")", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw (IOException) th;
+			}
+		} catch (Throwable e) {
+			log.error("Error while executing read(" + id + ")", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw new ShellIOException(th);
+			}
+		} finally {
+			TxSupport.clearUTForThread();
+		}
+	}
+
+	public void writeBuffer(String id, LinkedList obj) throws IOException {
+		try {
+			TxSupport.assignUTForThread(sctx.getUserTransaction());
+			reinitShell();
+			shell.writeBuffer(id, obj);
+		} catch (RuntimeException e) {
+			log.error("Error while executing writeBuffer(" + id + ", " + obj + ")", e);
+			throw (RuntimeException) processThrowable(e);
+		} catch (IOException e) {
+			log.error("Error while executing read(" + id + ")", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw (IOException) th;
+			}
+		} catch (Throwable e) {
+			log.error("Error while executing read(" + id + ")", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw new ShellIOException(th);
+			}
+		} finally {
+			TxSupport.clearUTForThread();
+		}
+	}
+
+	// means only the specified process
+	public void close(String id, int streamid) throws IOException {
+		try {
+			TxSupport.assignUTForThread(sctx.getUserTransaction());
+			reinitShell();
+			shell.close(id, streamid);
+		} catch (RuntimeException e) {
+			log.error("Error while executing stream close (processId: " + id + ", streamId: " + streamid + ")", e);
+			throw (RuntimeException) processThrowable(e);
+		} catch (IOException e) {
+			log.error("Error while executing stream close (processId: " + id + ", streamId: " + streamid + ")", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw (IOException) th;
+			}
+		} catch (Throwable e) {
+			log.error("Error while executing stream close (processId: " + id + ", streamId: " + streamid + ")", e);
+			Throwable th = processThrowable(e);
+			if (th instanceof RuntimeException) {
+				throw  (RuntimeException) th;
+			} else {
+				throw new ShellIOException(th);
+			}
+		} finally {
+			TxSupport.clearUTForThread();
+		}
+	}
+
+	public String getSessionID() {
+		return sessid;
+	}
+
+	public boolean isValid() {
+		try {
+			reinitShell();
+			shell.using();
+		} catch (Exception ex) {
+			return false;
+		}
+		return true;
+	}
+
+	/**
+	 * This method is called to replace an ErrorEOF object with such that it has properly processed IOException
+	 * which is its payload.
+	 */
+	private Object replaceThrowable(Object o) {
+		if (o instanceof org.jboss.fresh.io.ErrorEOF) {
+			o = processThrowable(((org.jboss.fresh.io.ErrorEOF) o).getIOException());
+			if (!(o instanceof IOException)) {
+				o = new org.jboss.fresh.shell.ShellIOException((Throwable) o);
+			}
+			o = new org.jboss.fresh.io.ErrorEOF((IOException) o);
+		}
+		return o;
+	}
+
+	/**
+	 * This method is called to replace each ErrorEOF object with such that it has properly processed IOException
+	 * which is its payload.
+	 */
+	private LinkedList replaceThrowables(LinkedList l) {
+		LinkedList l2 = new LinkedList();
+		while (l.size() > 0) {
+			Object o = l.removeFirst();
+			if (o instanceof org.jboss.fresh.io.ErrorEOF) {
+				o = processThrowable(((org.jboss.fresh.io.ErrorEOF) o).getIOException());
+				if (!(o instanceof IOException)) {
+					o = new org.jboss.fresh.shell.ShellIOException((Throwable) o);
+				}
+				o = new org.jboss.fresh.io.ErrorEOF((IOException) o);
+			}
+			l2.add(o);
+		}
+		return l2;
+	}
+
+	/**
+	 * This method inspects a passed throwable for any Throwables which should not be sent to the client
+	 * and if necessary copies the entire stack trace in terms of ThrowableProxy - an extension of RuntimeException.
+	 */
+	private Throwable processThrowable(Throwable t) {
+		Throwable torig = t;
+		Throwable tnu;
+		boolean needReplace = false;
+		java.util.LinkedList ls = new java.util.LinkedList();
+		while (t != null) {
+			if (log.isDebugEnabled()) {
+				log.debug("t: " + t, t);
+			}
+			if (!isPartOfClientAPI(t.getClass())) {
+				needReplace = true;
+			}
+			tnu = new org.jboss.fresh.util.ThrowableProxy(t);
+			ls.add(tnu);
+
+			t = t.getCause();
+		}
+		t = (Throwable) ls.removeLast();
+		while (ls.size() > 0) {
+			tnu = (Throwable) ls.removeLast();
+			if (tnu == null) {
+				break;
+			}
+			tnu.initCause(t);
+			t = tnu;
+		}
+
+		if (needReplace) {
+			return t;
+		}
+		return torig;
+	}
+
+	private boolean isPartOfClientAPI(Class c) {
+		final String className = c.getName();
+
+		if (className.startsWith("java.")) {
+			return true;
+		}
+		if (className.startsWith("javax.")) {
+			return true;
+		}
+		if (className.startsWith("org.jboss.fresh.parsek.cms.")) {
+			return true;
+		}
+		String pkg = "org.jboss.fresh.shell.";
+		if (className.startsWith(pkg) && className.indexOf(".", pkg.length()) == -1) {
+			return true;
+		}
+
+		// try to get the names of classes which also should not be replaced
+		String nonreplacable;
+		try {
+			reinitShell();
+			nonreplacable = shell.getEnvProperty(KEEP_EXCEPTIONS_ENV_NAME);
+		} catch (Exception e) {
+			log_treplacer.warn("Could not read environment variable " + KEEP_EXCEPTIONS_ENV_NAME);
+			nonreplacable = "";
+		}
+
+		log_treplacer.info(KEEP_EXCEPTIONS_ENV_NAME + " = " + nonreplacable);
+
+		if(nonreplacable == null)
+		    return false;
+		
+		final StringTokenizer st = new StringTokenizer(nonreplacable, "\r\n ;,:");
+		while (st.hasMoreTokens()) {
+			final String el = st.nextToken();
+			if (matches(className, el)) {
+				return true;
+			}
+		}
+
+		return false;
+	}
+
+	private boolean matches(final String value, String search) {
+		if (search == null) {
+			return false;
+		}
+
+		search = search.trim();
+
+		if ("".equals(search)) {
+			return false;
+		}
+
+		final String s = search
+			.replaceAll("\\.", "\\.")
+			.replaceAll("\\?", ".")
+			.replaceAll("\\*", ".*");
+
+		final boolean b = value.startsWith(s);  // matches(s);
+
+		log_treplacer.debug(value + " matches " + s + "? " + b + ", orig: " + search);
+
+		return b;
+
+	}
+
+}
\ No newline at end of file

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/Shell.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/Shell.java	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/Shell.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -2,7 +2,7 @@
 
 import org.jboss.fresh.vfs.UserCtx;
 import org.jboss.fresh.vfs.VFS;
-import org.jboss.fresh.parsek.ctx.Context;
+import org.jboss.fresh.ctx.Context;
 import org.jboss.fresh.io.Buffer;
 import org.jboss.fresh.shell.impl.Process;
 

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/ContextExe.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/ContextExe.java	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/ContextExe.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,6 +1,6 @@
 package org.jboss.fresh.shell.commands;
 
-import org.jboss.fresh.parsek.ctx.Context;
+import org.jboss.fresh.ctx.Context;
 import org.jboss.fresh.io.BufferObjectReader;
 import org.jboss.fresh.io.BufferObjectWriter;
 import org.jboss.fresh.io.BufferWriter;

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/EventCentralQueryExe.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/EventCentralQueryExe.java	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/EventCentralQueryExe.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -3,9 +3,9 @@
 import org.jboss.fresh.io.BufferWriter;
 import org.jboss.fresh.io.PrintWriter2;
 import org.jboss.fresh.shell.AbstractExecutable;
-import org.jboss.fresh.parsek.cp2.events.EventCentral;
+import org.jboss.fresh.events.EventCentral;
 import org.jboss.fresh.registry.RegistryContext;
-import org.jboss.fresh.parsek.ctx.Context;
+import org.jboss.fresh.ctx.Context;
 
 import java.util.Map;
 import java.util.Iterator;

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/EventNetAgentExe.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/EventNetAgentExe.java	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/EventNetAgentExe.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -7,14 +7,14 @@
 import org.jboss.fresh.io.BufferWriter;
 import org.jboss.fresh.io.PrintWriter2;
 import org.jboss.fresh.shell.AbstractExecutable;
-import org.jboss.fresh.parsek.cp2.events.Event;
-import org.jboss.fresh.parsek.cp2.events.EventCentral;
-import org.jboss.fresh.parsek.cp2.events.EventListener;
-import org.jboss.fresh.parsek.cp2.events.net.EventNetRouter;
-import org.jboss.fresh.parsek.cp2.events.net.EventNetConnector;
-import org.jboss.fresh.parsek.cp2.events.net.EventNetRouterImpl;
-import org.jboss.fresh.parsek.cp2.events.net.TakenOverException;
-import org.jboss.fresh.parsek.ctx.Context;
+import org.jboss.fresh.events.Event;
+import org.jboss.fresh.events.EventCentral;
+import org.jboss.fresh.events.EventListener;
+import org.jboss.fresh.events.net.EventNetRouter;
+import org.jboss.fresh.events.net.EventNetConnector;
+import org.jboss.fresh.events.net.EventNetRouterImpl;
+import org.jboss.fresh.events.net.TakenOverException;
+import org.jboss.fresh.ctx.Context;
 
 import java.io.IOException;
 import java.util.List;
@@ -235,7 +235,7 @@
 
 
 //		Thread.sleep(10000);
-//		org.jboss.fresh.parsek.cp2.events.EventBroadcaster eb = new org.jboss.fresh.parsek.cp2.events.EventBroadcaster(ec, "CMSPersistence");
+//		org.jboss.fresh.events.EventBroadcaster eb = new org.jboss.fresh.events.EventBroadcaster(ec, "CMSPersistence");
 
 //		while(true) {
 //			Event ev = new Event("CMS", "onAfterCreate");

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/EventsExe.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/EventsExe.java	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/EventsExe.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,11 +1,11 @@
 package org.jboss.fresh.shell.commands;
 
-import org.jboss.fresh.parsek.ctx.Context;
+import org.jboss.fresh.ctx.Context;
 import org.jboss.fresh.io.BufferWriter;
 import org.jboss.fresh.io.BufferObjectWriter;
 import org.jboss.fresh.shell.AbstractExecutable;
-import org.jboss.fresh.parsek.cp2.events.EventCentral;
-import org.jboss.fresh.parsek.cp2.events.EventListener;
+import org.jboss.fresh.events.EventCentral;
+import org.jboss.fresh.events.EventListener;
 
 import java.io.PrintWriter;
 import java.util.Iterator;

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/HistoryExe.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/HistoryExe.java	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/HistoryExe.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -11,7 +11,7 @@
 import java.util.Date;
 import java.util.Iterator;
 
-import org.jboss.fresh.parsek.ctx.Context;
+import org.jboss.fresh.ctx.Context;
 import org.jboss.fresh.io.BufferObjectWriter;
 import org.jboss.fresh.io.BufferWriter;
 import org.jboss.fresh.io.PrintWriter2;

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/cms/CtxDelegateExe.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/cms/CtxDelegateExe.java	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/commands/cms/CtxDelegateExe.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,6 +1,6 @@
 package org.jboss.fresh.shell.commands.cms;
 
-import org.jboss.fresh.parsek.ctx.Context;
+import org.jboss.fresh.ctx.Context;
 import org.jboss.fresh.io.BufferWriter;
 import org.jboss.fresh.shell.AbstractExecutable;
 import org.jboss.fresh.shell.Shell;
@@ -65,9 +65,9 @@
 
 			if (!(obj instanceof Context)) {
 				if (canThrowEx()) {
-					throw new Exception("Object found in JNDI for name: " + tmp + " is not org.jboss.fresh.parsek.ctx.Context type.");
+					throw new Exception("Object found in JNDI for name: " + tmp + " is not org.jboss.fresh.ctx.Context type.");
 				} else {
-					err.println("Object found in JNDI for name: " + tmp + " is not org.jboss.fresh.parsek.ctx.Context type.");
+					err.println("Object found in JNDI for name: " + tmp + " is not org.jboss.fresh.ctx.Context type.");
 					log.debug("CtxDelegateExe done.");
 					return;
 				}

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/ejb/UnremoterShell.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/ejb/UnremoterShell.java	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/ejb/UnremoterShell.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -14,7 +14,7 @@
 
 import org.jboss.fresh.vfs.UserCtx;
 import org.jboss.fresh.vfs.VFS;
-import org.jboss.fresh.parsek.ctx.Context;
+import org.jboss.fresh.ctx.Context;
 import org.jboss.fresh.io.Buffer;
 import org.jboss.fresh.shell.EnvProperties;
 import org.jboss.fresh.shell.Executable;

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/events/ShellEvent.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/events/ShellEvent.java	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/events/ShellEvent.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,6 +1,6 @@
 package org.jboss.fresh.shell.events;
 
-import org.jboss.fresh.parsek.cp2.events.Event;
+import org.jboss.fresh.events.Event;
 import org.jboss.fresh.shell.Shell;
 
 public class ShellEvent extends Event {

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/events/ShellEventBroadcaster.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/events/ShellEventBroadcaster.java	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/events/ShellEventBroadcaster.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -1,10 +1,10 @@
 package org.jboss.fresh.shell.events;
 
 import org.jboss.fresh.shell.Shell;
-import org.jboss.fresh.parsek.cp2.events.Event;
-import org.jboss.fresh.parsek.cp2.events.EventCentral;
-import org.jboss.fresh.parsek.cp2.events.EventBroadcaster;
-import org.jboss.fresh.parsek.cp2.events.InvalidFormatException;
+import org.jboss.fresh.events.Event;
+import org.jboss.fresh.events.EventCentral;
+import org.jboss.fresh.events.EventBroadcaster;
+import org.jboss.fresh.events.InvalidFormatException;
 
 public class ShellEventBroadcaster extends EventBroadcaster {
 

Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/ShellImpl.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/ShellImpl.java	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/ShellImpl.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -17,8 +17,8 @@
 import java.util.StringTokenizer;
 import java.util.Vector;
 
-import org.jboss.fresh.parsek.cp2.events.EventBroadcaster;
-import org.jboss.fresh.parsek.cp2.events.EventCentral;
+import org.jboss.fresh.events.EventBroadcaster;
+import org.jboss.fresh.events.EventCentral;
 import org.jboss.fresh.vfs.FileInfo;
 import org.jboss.fresh.vfs.FileName;
 import org.jboss.fresh.vfs.UserCtx;
@@ -26,7 +26,7 @@
 import org.jboss.fresh.vfs.impl.LazyVFSOutputStream;
 import org.jboss.fresh.vfs.impl.SecureVFS;
 import org.jboss.fresh.vfs.impl.VFSInputStream;
-import org.jboss.fresh.parsek.ctx.Context;
+import org.jboss.fresh.ctx.Context;
 import org.jboss.fresh.io.Buffer;
 import org.jboss.fresh.io.BufferImpl;
 import org.jboss.fresh.io.BufferObjectReader;

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-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/ShellRuntime.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -3,7 +3,7 @@
 import org.jboss.fresh.vfs.FileInfo;
 import org.jboss.fresh.vfs.FileName;
 import org.jboss.fresh.vfs.VFSException;
-import org.jboss.fresh.parsek.ctx.FlatContext;
+import org.jboss.fresh.ctx.FlatContext;
 import org.jboss.fresh.io.Buffer;
 import org.jboss.fresh.io.BufferWriter;
 import org.jboss.fresh.shell.Executable;

Modified: projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/io/IOUtils.java
===================================================================
--- projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/io/IOUtils.java	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/io/IOUtils.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -33,7 +33,7 @@
  */
 public class IOUtils {
 	private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(IOUtils.class);
-	public static final String VERSION = "$Header: /cvsroot/cp2/coderoot/modules/parsek-util/src/com/parsek/io/IOUtils.java,v 1.7 2004/05/05 09:00:41 rancic Exp $";
+	public static final String VERSION = "$Header: /cvsroot/cp2/coderoot/deployer/parsek-util/src/com/parsek/io/IOUtils.java,v 1.7 2004/05/05 09:00:41 rancic Exp $";
 	public static final int DEFAULT_BUFFER_SIZE = 16384; // 16K
 
 	/**

Modified: projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/io/InputStreamReader.java
===================================================================
--- projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/io/InputStreamReader.java	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/io/InputStreamReader.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -20,7 +20,7 @@
  * @modified $Author: boky $
  */
 public class InputStreamReader extends Reader {
-	public static final String VERSION = "$Header: /store/cvsroot2/java/cp2/coderoot/modules/parsek-util/src/com/parsek/io/InputStreamReader.java,v 1.1 2004/06/07 13:48:02 boky Exp $";
+	public static final String VERSION = "$Header: /store/cvsroot2/java/cp2/coderoot/deployer/parsek-util/src/com/parsek/io/InputStreamReader.java,v 1.1 2004/06/07 13:48:02 boky Exp $";
 	public static final String DEFAULT_CHARSET = "UTF-8";
 	private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(InputStreamReader.class);
 	protected final Reader reader;

Modified: projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/io/NullOutputStream.java
===================================================================
--- projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/io/NullOutputStream.java	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/io/NullOutputStream.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -14,7 +14,7 @@
  * @modified $Author: boky $
  */
 public class NullOutputStream extends OutputStream {
-	public static final String VERSION = "$Header: /store/cvsroot2/java/cp2/coderoot/modules/parsek-util/src/com/parsek/io/NullOutputStream.java,v 1.1 2004/04/09 13:14:47 boky Exp $";
+	public static final String VERSION = "$Header: /store/cvsroot2/java/cp2/coderoot/deployer/parsek-util/src/com/parsek/io/NullOutputStream.java,v 1.1 2004/04/09 13:14:47 boky Exp $";
 
 	public void write(int b) throws IOException {
 		// do nothing

Modified: projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/io/ObjectFIFO.java
===================================================================
--- projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/io/ObjectFIFO.java	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/io/ObjectFIFO.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -17,7 +17,7 @@
  * @modified $Author: boky $
  */
 public class ObjectFIFO<T> {
-	public static final String VERSION = "$Header: /store/cvsroot2/java/cp2/coderoot/modules/parsek-util/src/com/parsek/io/ObjectFIFO.java,v 1.2 2004/06/08 07:45:32 boky Exp $";
+	public static final String VERSION = "$Header: /store/cvsroot2/java/cp2/coderoot/deployer/parsek-util/src/com/parsek/io/ObjectFIFO.java,v 1.2 2004/06/08 07:45:32 boky Exp $";
 	private Object[] queue;
 	private int capacity;
 	private int size;

Modified: projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/io/URLConnectionReader.java
===================================================================
--- projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/io/URLConnectionReader.java	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/io/URLConnectionReader.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -18,7 +18,7 @@
  * @modified $Author: boky $
  */
 public class URLConnectionReader extends Reader {
-	public static final String VERSION = "$Header: /store/cvsroot2/java/cp2/coderoot/modules/parsek-util/src/com/parsek/io/URLConnectionReader.java,v 1.1 2004/06/07 13:48:02 boky Exp $";
+	public static final String VERSION = "$Header: /store/cvsroot2/java/cp2/coderoot/deployer/parsek-util/src/com/parsek/io/URLConnectionReader.java,v 1.1 2004/06/07 13:48:02 boky Exp $";
 	public static final String DEFAULT_CHARSET = "UTF-8";
 	private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(URLConnectionReader.class);
 	protected final Reader reader;

Modified: projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/util/ConfigurationChangeWatcher.java
===================================================================
--- projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/util/ConfigurationChangeWatcher.java	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/fresh-util/src/main/java/org/jboss/fresh/util/ConfigurationChangeWatcher.java	2009-04-29 16:31:09 UTC (rev 88013)
@@ -21,7 +21,7 @@
  * @modified $Author: boky $
  */
 public class ConfigurationChangeWatcher {
-	public static final String VERSION = "$Header: /store/cvsroot2/java/cp2/coderoot/modules/parsek-util/src/com/parsek/util/ConfigurationChangeWatcher.java,v 1.3 2004/08/04 10:37:27 boky Exp $";
+	public static final String VERSION = "$Header: /store/cvsroot2/java/cp2/coderoot/deployer/parsek-util/src/com/parsek/util/ConfigurationChangeWatcher.java,v 1.3 2004/08/04 10:37:27 boky Exp $";
 	public static final long DEFAULT_CHECK_RATE = 30 * 1000; // check at most every 30 seconds;
 	private static final java.text.DateFormat ISO_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
 	private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(ConfigurationChangeWatcher.class);

Modified: projects/fresh/trunk/pom.xml
===================================================================
--- projects/fresh/trunk/pom.xml	2009-04-29 16:14:25 UTC (rev 88012)
+++ projects/fresh/trunk/pom.xml	2009-04-29 16:31:09 UTC (rev 88013)
@@ -143,7 +143,7 @@
   </repositories>
   
   <dependencyManagement>
-    <!-- The parent pom manages the inter-dependencies of the modules. -->
+    <!-- The parent pom manages the inter-dependencies of the deployer. -->
     <dependencies>
 
       <dependency>




More information about the jboss-cvs-commits mailing list