[FIXED HUDSON-1841] proxy setting shouldn't be global to JVM.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@10078 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2008-06-13 17:54:16 +00:00
1 parent 1a5d0d13ef
commit 0543909074
5 files changed
+88 -14

No files matched your search

@@ -0,0 +1,51 @@
package hudson;
import com.thoughtworks.xstream.XStream;
import hudson.model.Hudson;
import hudson.util.XStream2;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Proxy;
/**
* HTTP proxy configuration.
*
* @see Hudson#proxy
*/
public final class ProxyConfiguration {
public final String name;
public final int port;
public ProxyConfiguration(String name, int port) {
this.name = name;
this.port = port;
}
public Proxy createProxy() {
return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(name,port));
}
public void save() throws IOException {
getXmlFile().write(this);
}
public static XmlFile getXmlFile() {
return new XmlFile(XSTREAM, new File(Hudson.getInstance().getRootDir(), "proxy.xml"));
}
public static ProxyConfiguration load() throws IOException {
XmlFile f = getXmlFile();
if(f.exists())
return (ProxyConfiguration) f.read();
else
return null;
}
private static final XStream XSTREAM = new XStream2();
static {
XSTREAM.alias("proxy", ProxyConfiguration.class);
}
}