You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ba...@apache.org on 2015/01/31 04:34:12 UTC
svn commit: r1656160 -
/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/DefaultShellCommandHelper.java
Author: batkinson
Date: Sat Jan 31 03:34:11 2015
New Revision: 1656160
URL: http://svn.apache.org/r1656160
Log:
Rearranged methods so they are grouped a little more logically.
Modified:
continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/DefaultShellCommandHelper.java
Modified: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/DefaultShellCommandHelper.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/DefaultShellCommandHelper.java?rev=1656160&r1=1656159&r2=1656160&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/DefaultShellCommandHelper.java (original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/DefaultShellCommandHelper.java Sat Jan 31 03:34:11 2015
@@ -70,58 +70,6 @@ public class DefaultShellCommandHelper
return new Properties();
}
- public ExecutionResult executeShellCommand( File workingDirectory, String executable, String arguments, File output,
- long idCommand, Map<String, String> environments )
- throws Exception
- {
- Commandline cl = new Commandline();
-
- Arg argument = cl.createArg();
-
- argument.setLine( arguments );
-
- return executeShellCommand( workingDirectory, executable, argument.getParts(), output, idCommand,
- environments );
- }
-
- private static class IOConsumerWrapper
- implements StreamConsumer
- {
- private OutputConsumer userConsumer;
-
- public IOConsumerWrapper( OutputConsumer userConsumer )
- {
- this.userConsumer = userConsumer;
- }
-
- public void consumeLine( String line )
- {
- if ( userConsumer != null )
- {
- userConsumer.consume( line );
- }
- }
- }
-
- public ExecutionResult executeShellCommand( File workingDirectory, String executable, String[] arguments,
- OutputConsumer io, long idCommand,
- Map<String, String> environments )
- throws Exception
- {
- Commandline cl = createCommandline( workingDirectory, executable, arguments, idCommand, environments );
-
- log.info( "Executing: " + cl );
- File clWorkDir = cl.getWorkingDirectory();
- log.info( "Working directory: " + ( clWorkDir != null ? clWorkDir.getAbsolutePath() : "default" ) );
- log.debug( "EnvironmentVariables " + Arrays.asList( cl.getEnvironmentVariables() ) );
-
- StreamConsumer consumer = new IOConsumerWrapper( io );
-
- int exitCode = runCommand( cl, consumer, consumer );
-
- return new ExecutionResult( exitCode );
- }
-
/**
* Make the command line
*
@@ -172,6 +120,20 @@ public class DefaultShellCommandHelper
return cl;
}
+ public ExecutionResult executeShellCommand( File workingDirectory, String executable, String arguments, File output,
+ long idCommand, Map<String, String> environments )
+ throws Exception
+ {
+ Commandline cl = new Commandline();
+
+ Arg argument = cl.createArg();
+
+ argument.setLine( arguments );
+
+ return executeShellCommand( workingDirectory, executable, argument.getParts(), output, idCommand,
+ environments );
+ }
+
public ExecutionResult executeShellCommand( File workingDirectory, String executable, String[] arguments,
File output, long idCommand, Map<String, String> environments )
throws Exception
@@ -189,16 +151,42 @@ public class DefaultShellCommandHelper
}
}
- public boolean isRunning( long idCommand )
+ private static class IOConsumerWrapper
+ implements StreamConsumer
{
- boolean isIdRunning = running.contains( idCommand );
- log.debug( "process running for id {}? {}", idCommand, isIdRunning );
- return isIdRunning;
+ private OutputConsumer userConsumer;
+
+ public IOConsumerWrapper( OutputConsumer userConsumer )
+ {
+ this.userConsumer = userConsumer;
+ }
+
+ public void consumeLine( String line )
+ {
+ if ( userConsumer != null )
+ {
+ userConsumer.consume( line );
+ }
+ }
}
- public void killProcess( long idCommand )
+ public ExecutionResult executeShellCommand( File workingDirectory, String executable, String[] arguments,
+ OutputConsumer io, long idCommand,
+ Map<String, String> environments )
+ throws Exception
{
- log.warn( "unsupported attempt to kill process for id {}", idCommand );
+ Commandline cl = createCommandline( workingDirectory, executable, arguments, idCommand, environments );
+
+ log.info( "Executing: " + cl );
+ File clWorkDir = cl.getWorkingDirectory();
+ log.info( "Working directory: " + ( clWorkDir != null ? clWorkDir.getAbsolutePath() : "default" ) );
+ log.debug( "EnvironmentVariables " + Arrays.asList( cl.getEnvironmentVariables() ) );
+
+ StreamConsumer consumer = new IOConsumerWrapper( io );
+
+ int exitCode = runCommand( cl, consumer, consumer );
+
+ return new ExecutionResult( exitCode );
}
public void executeGoals( File workingDirectory, String executable, String goals, boolean interactive,
@@ -270,6 +258,18 @@ public class DefaultShellCommandHelper
}
}
+ public boolean isRunning( long idCommand )
+ {
+ boolean isIdRunning = running.contains( idCommand );
+ log.debug( "process running for id {}? {}", idCommand, isIdRunning );
+ return isIdRunning;
+ }
+
+ public void killProcess( long idCommand )
+ {
+ log.warn( "unsupported attempt to kill process for id {}", idCommand );
+ }
+
/**
* Handles all command executions for the helper, allowing it to track which commands are running.
* The process tracking functionality done here attempts to mimick functionality lost with the move to