...
Code Block |
---|
|
private static void configureHttpClient2Proxy(HttpClient httpClient, HttpMethod method) {
String proxyHost = System.getProperty("http.proxyHost");
if (proxyHost == null || "".equals(proxyHost)) {
return;
}
try {
org.apache.commons.httpclient.URI apacheUri = method.getURI();
java.net.URI javaUri = null;
if (apacheUri.isAbsoluteURI()==false) {
javaUri = new
java.net.URI(httpClient.getHostConfiguration().getHostURL());
} else {
javaUri = new java.net.URI(apacheUri.toString());
}
// ProxySelector
List<Proxy> selectedProxy =
ProxySelector.getDefault().select(javaUri);
if (selectedProxy.size()==0 ||
selectedProxy.get(0).type()==Proxy.Type.DIRECT) {
// No proxy needed.
return;
}
HostConfiguration hc = httpClient.getHostConfiguration();
hc.setHost(javaUri.getHost(), javaUri.getPort(),
Protocol.getProtocol(javaUri.getScheme()));
Proxy proxy = selectedProxy.get(0);
InetSocketAddress proxyAddress = (InetSocketAddress) proxy.address();
hc.setProxy(proxyAddress.getHostName(),proxyAddress.getPort());
if (System.getProperty("http.proxyUserName") != null) {
httpClient.getState().setProxyCredentials(null, null,
new UsernamePasswordCredentials(System.getProperty("http.proxyUserName"), System.getProperty("http.proxyPassword")));
httpClient.getState().setAuthenticationPreemptive(true);
}
} catch (URISyntaxException ex) {
LOG.log(Level.WARNING, null, ex);
} catch (URIException ex) {
lOG.log(Level.WARNING, null, ex);
}
}
|
Back to Top
...
Anchor |
---|
| adding_custom_indicators_to_the_performance_dashboard |
---|
| adding_custom_indicators_to_the_performance_dashboard |
---|
|
Adding Custom Indicators to the Performance Dashboard
...