提交 feaeb6e5 编写于 作者: K kohsuke

moving the code from Computer to EnvVars.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@6777 71c3de6d-444a-0410-be80-ed276b4c234a
上级 d861fd19
package hudson;
import hudson.remoting.VirtualChannel;
import hudson.remoting.Callable;
import java.io.File;
import java.io.Serializable;
import java.io.IOException;
import java.util.Map;
import java.util.TreeMap;
import java.util.Comparator;
import java.util.Collections;
/**
* Environment variables.
......@@ -61,6 +66,26 @@ public class EnvVars extends TreeMap<String,String> {
}
}
/**
* Obtains the environment variables of a remote peer.
*
* @param channel
* Can be null, in which case the map indicating "N/A" will be returned.
*/
public static Map<String,String> getRemote(VirtualChannel channel) throws IOException, InterruptedException {
if(channel==null)
return Collections.singletonMap("N/A","N/A");
return new EnvVars(channel.call(new GetEnvVars()));
}
private static final class GetEnvVars implements Callable<Map<String,String>,RuntimeException> {
public Map<String,String> call() {
return new TreeMap<String,String>(EnvVars.masterEnvVars);
}
private static final long serialVersionUID = 1L;
}
/**
* Compares strings case insensitively.
*/
......
......@@ -272,17 +272,7 @@ public abstract class Computer extends AbstractModelObject {
* If this is the master, it returns the system property of the master computer.
*/
public Map<String,String> getEnvVars() throws IOException, InterruptedException {
VirtualChannel channel = getChannel();
if(channel==null)
return Collections.singletonMap("N/A","N/A");
return channel.call(new GetEnvVars());
}
private static final class GetEnvVars implements Callable<Map<String,String>,RuntimeException> {
public Map<String,String> call() {
return new TreeMap<String,String>(EnvVars.masterEnvVars);
}
private static final long serialVersionUID = 1L;
return EnvVars.getRemote(getChannel());
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册