Search |
||
We deserve a better proxy support!Posted by kohsuke on August 10, 2005 at 1:16 PM PDT
Nowadays many Java tools need to access HTTP resources. For example, Ant has a <get> task, Maven needs to download jar files, javadoc needs to locate package-list from a remote site, JAX-WS's WsImport reads WSDL from a remote website, and JAXB's schema compiler does the same for schema files. The list could go on forever. So first let's look at how these tools support proxies?
The problem here is that every tool invents its own way of configuring proxies. So whenever I bring my laptop between home (no proxy) and office (need proxy), I have to dilligently change the settings in so many places. First, you change the IE connection, then you change Firefox connection, then ~/build.properties. Am I done now? No, I still have to modify ~/.svn/servers! It would be much better if the configuration location is consolidated, so that I can only change it once and be done with it. So, that's why I'm going to talk about this feature I recently discovered in Java SE 5, where you can tell the VM to use the platform proxy configuration (meaning IE's connection setting in Windows, or Gnome's if you are on it.) To activate this, you need to put the following lines in the beginning of your tool:
try {
System.setProperty("java.net.useSystemProxies","true");
} catch (SecurityException e) {
; // failing to set this property isn't fatal
}
This has to be done before your tool starts accessing URL class and so on, because this system property is checked only once at the start-up time. This works even with pre-Java 5 JVMs. It just doesn't take any effect, which is a reasonable fallback behavior. I've already finished changing XJC, so it now works without the explicit -proxy option, as long as your Internet Expolorer / Gnome is configured correctly. Now if only Maven, Ant, javadoc, and million other tools could do the same... »
Related Topics >>
Java Web Services and XML Comments
Comments are listed in date ascending order (oldest first)
|
||
|
|