You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2008/09/21 10:18:35 UTC

svn commit: r697457 - in /geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell: CommandLineBuilderImpl.java CommandLineExecutorImpl.java

Author: jdillon
Date: Sun Sep 21 01:18:35 2008
New Revision: 697457

URL: http://svn.apache.org/viewvc?rev=697457&view=rev
Log:
Isolate where IO and Variables come from

Modified:
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineBuilderImpl.java
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineBuilderImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineBuilderImpl.java?rev=697457&r1=697456&r2=697457&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineBuilderImpl.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineBuilderImpl.java Sun Sep 21 01:18:35 2008
@@ -77,6 +77,11 @@
         return cl;
     }
 
+    protected Variables getVariables() {
+        assert applicationManager != null;
+        return applicationManager.getApplication().getVariables();
+    }
+
     public CommandLine create(final String commandLine) throws ParseException {
         assert commandLine != null;
 
@@ -85,8 +90,7 @@
         }
 
         try {
-            assert applicationManager != null;
-            final Variables vars = applicationManager.getApplication().getVariables();
+            final Variables vars = getVariables();
             final ASTCommandLine root = parse(commandLine);
 
             return new CommandLine() {

Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java?rev=697457&r1=697456&r2=697457&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/CommandLineExecutorImpl.java Sun Sep 21 01:18:35 2008
@@ -95,13 +95,23 @@
         }
     }
 
+    protected IO getIo() {
+        assert applicationManager != null;
+        return applicationManager.getApplication().getIo();
+    }
+
+    protected Variables getVariables() {
+        assert applicationManager != null;
+        return applicationManager.getApplication().getVariables();
+    }
+
     public Object execute(final Object... args) throws Exception {
         assert args != null;
         assert args.length > 1;
 
         log.info("Executing (Object...): [{}]", Arguments.asString(args));
 
-        return execute(String.valueOf(args[0]), Arguments.shift(args), applicationManager.getApplication().getIo());
+        return execute(String.valueOf(args[0]), Arguments.shift(args), getIo());
     }
 
     public Object execute(final String path, final Object[] args) throws Exception {
@@ -110,7 +120,7 @@
 
         log.info("Executing ({}): [{}]", path, Arguments.asString(args));
 
-        return execute(path, args, applicationManager.getApplication().getIo());
+        return execute(path, args, getIo());
     }
 
     public Object execute(final Object[][] commands) throws Exception {
@@ -120,7 +130,7 @@
         final IO[] ios = new IO[commands.length];
         PipedOutputStream pos = null;
 
-        IO io = applicationManager.getApplication().getIo();
+        IO io = getIo();
 
         for (int i = 0; i < ios.length; i++) {
             InputStream is = (i == 0) ? io.inputStream : new PipedInputStream(pos);
@@ -188,14 +198,14 @@
         return ref.get();
     }
 
-    protected Thread createThread(Runnable run) {
-        return new Thread(run);
+    protected Thread createThread(final Runnable task) {
+        return new Thread(task);
     }
 
     protected Object execute(final String path, final Object[] args, final IO io) throws Exception {
         log.debug("Executing");
 
-        Variables variables = applicationManager.getApplication().getVariables();
+        Variables variables = getVariables();
 
         Command command = commandResolver.resolve(variables, path);