mirror of https://github.com/apache/activemq.git
[AMQ-6556] Support system property proxy settings for HTTP(S) client
This commit is contained in:
parent
6e7f622456
commit
746a839809
|
@ -417,4 +417,10 @@ public class HttpClientTransport extends HttpTransportSupport {
|
|||
public WireFormat getWireFormat() {
|
||||
return getTextWireFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSystemPropertyPrefix() {
|
||||
return "http.";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,10 +27,16 @@ import org.apache.activemq.transport.util.TextWireFormat;
|
|||
*
|
||||
*/
|
||||
public abstract class HttpTransportSupport extends TransportThreadSupport {
|
||||
private static final int DEFAULT_PROXY_PORT = 8080;
|
||||
private static final String PROPERTY_PROXY_HOST = "proxyHost";
|
||||
private static final String PROPERTY_PROXY_PORT = "proxyPort";
|
||||
private static final String PROPERTY_PROXY_USER = "proxyUser";
|
||||
private static final String PROPERTY_PROXY_PASSWORD = "proxyPassword";
|
||||
|
||||
private TextWireFormat textWireFormat;
|
||||
private URI remoteUrl;
|
||||
private String proxyHost;
|
||||
private int proxyPort = 8080;
|
||||
private Integer proxyPort;
|
||||
private String proxyUser;
|
||||
private String proxyPassword;
|
||||
|
||||
|
@ -62,7 +68,7 @@ public abstract class HttpTransportSupport extends TransportThreadSupport {
|
|||
}
|
||||
|
||||
public String getProxyHost() {
|
||||
return proxyHost;
|
||||
return proxyHost != null ? proxyHost : getSystemProperty(PROPERTY_PROXY_HOST);
|
||||
}
|
||||
|
||||
public void setProxyHost(String proxyHost) {
|
||||
|
@ -70,7 +76,9 @@ public abstract class HttpTransportSupport extends TransportThreadSupport {
|
|||
}
|
||||
|
||||
public int getProxyPort() {
|
||||
return proxyPort;
|
||||
return proxyPort != null ? proxyPort
|
||||
: (getSystemProperty(PROPERTY_PROXY_PORT) != null
|
||||
? Integer.parseInt(getSystemProperty(PROPERTY_PROXY_PORT)) : DEFAULT_PROXY_PORT);
|
||||
}
|
||||
|
||||
public void setProxyPort(int proxyPort) {
|
||||
|
@ -78,7 +86,7 @@ public abstract class HttpTransportSupport extends TransportThreadSupport {
|
|||
}
|
||||
|
||||
public String getProxyUser() {
|
||||
return proxyUser;
|
||||
return proxyUser != null ? proxyUser : getSystemProperty(PROPERTY_PROXY_USER);
|
||||
}
|
||||
|
||||
public void setProxyUser(String proxyUser) {
|
||||
|
@ -86,10 +94,17 @@ public abstract class HttpTransportSupport extends TransportThreadSupport {
|
|||
}
|
||||
|
||||
public String getProxyPassword() {
|
||||
return proxyPassword;
|
||||
return proxyPassword != null ? proxyPassword : getSystemProperty(PROPERTY_PROXY_PASSWORD);
|
||||
}
|
||||
|
||||
public void setProxyPassword(String proxyPassword) {
|
||||
this.proxyPassword = proxyPassword;
|
||||
}
|
||||
|
||||
protected abstract String getSystemPropertyPrefix();
|
||||
|
||||
private String getSystemProperty(String propertyName) {
|
||||
return System.getProperty(getSystemPropertyPrefix() + propertyName);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -75,4 +75,10 @@ public class HttpsClientTransport extends HttpClientTransport {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSystemPropertyPrefix() {
|
||||
return "https.";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue