return;
}
}
public final static XmlRpcClient getXmlRpcClient(Global glob, XmlRpcUrl xmlRpcUrl, AddressBase address, boolean useCDATA) throws MalformedURLException, XmlBlasterException {
XmlRpcClient xmlRpcClient = new XmlRpcClient();
useCDATA = address.getEnv("useCDATA", useCDATA).getValue();
String transportFactoryName = address.getEnv("transportFactory", "").getValue();
if (transportFactoryName.trim().length() > 1) {
log.info("Going to initialize with transport factory " + transportFactoryName);
try {
Class<XmlRpcTransportFactory>
forName = (Class<XmlRpcTransportFactory>) Class.forName(transportFactoryName.trim());
Constructor<XmlRpcTransportFactory> constr = forName.getConstructor(XmlRpcClient.class);
XmlRpcTransportFactory
transportFactory = constr.newInstance(xmlRpcClient);
xmlRpcClient.setTransportFactory(transportFactory);
}
catch (ClassNotFoundException e) {
log.severe("Exception " + e.getClass().getName() + ": " + e.getMessage());
e.printStackTrace();
}
catch (NoSuchMethodException e) {
log.severe("Exception " + e.getClass().getName() + ": " + e.getMessage());
e.printStackTrace();
}
catch (InstantiationException e) {
log.severe("Exception " + e.getClass().getName() + ": " + e.getMessage());
e.printStackTrace();
}
catch (InvocationTargetException e) {
log.severe("Exception " + e.getClass().getName() + ": " + e.getMessage());
e.printStackTrace();
}
catch (IllegalAccessException e) {
log.severe("Exception " + e.getClass().getName() + ": " + e.getMessage());
e.printStackTrace();
}
}
XblWriterFactory writerFactory = new XblWriterFactory(useCDATA);
xmlRpcClient.setXmlWriterFactory(writerFactory);
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
int val = address.getEnv("responseTimeout", 0).getValue();
if (val > 0)
config.setReplyTimeout(val);
val = address.getEnv("SoTimeout", 0).getValue();
if (val > 0)
config.setConnectionTimeout(val);
String compressType = address.getEnv("compress/type", "").getValue();
if (Constants.COMPRESS_ZLIB.equals(compressType) || Constants.COMPRESS_ZLIB_STREAM.equals(compressType))
config.setGzipCompressing(true);
else
config.setGzipCompressing(false);
String proxyHost = address.getEnv("proxyHost", (String)null).getValue();
String proxyPort = address.getEnv("proxyPort", (String)null).getValue();
if (proxyPort != null && proxyPort.length() > 0 && proxyHost == null)
proxyHost = "localhost";
String proxyHostSSL = address.getEnv("proxyHostSSL", proxyHost).getValue();
String proxyPortSSL = address.getEnv("proxyPortSSL", proxyPort).getValue();
Properties props = System.getProperties();
synchronized(props) {
if (proxyHost != null)
props.setProperty("http.proxySet", "true");
if (proxyHostSSL != null)
props.setProperty("https.proxySet", "true");
setProp(props, "http.proxyHost", proxyHost);
setProp(props, "http.proxyPort", proxyPort);
setProp(props, "https.proxyHost", proxyHostSSL);
setProp(props, "https.proxyPort", proxyPortSSL);
}
String basicUserName = address.getEnv("basicUserName", null).getValue();
String basicPassword = address.getEnv("basicPassword", null).getValue();
String basicEncoding = address.getEnv("basicEncoding", null).getValue();
String userAgent = address.getEnv("userAgent", null).getValue();
if (basicUserName != null)
config.setBasicUserName(basicUserName);
if (basicPassword != null)
config.setBasicPassword(basicPassword);
if (basicEncoding != null)
config.setBasicEncoding(basicEncoding);
if (userAgent != null)
config.setUserAgent(userAgent);
config.setEnabledForExceptions(true);
config.setEnabledForExtensions(true);
String url = null;
if (xmlRpcUrl == null) {
url = address.getRawAddress();
xmlRpcUrl = new XmlRpcUrl(glob, url);
}
else
url = xmlRpcUrl.getUrl();
boolean isSSL = url.indexOf("https://") == 0;
config.setServerURL(new URL(url));
xmlRpcClient.setConfig(config);
XmlRpcTransportFactory transportFactory = xmlRpcClient.getTransportFactory();
if (transportFactory instanceof XmlRpcSun15HttpTransportFactory) {
log.info("Going to set proxy for transport factory for " + transportFactory.getClass().getName());
XmlRpcSun15HttpTransportFactory trFact = (XmlRpcSun15HttpTransportFactory)transportFactory;
if (proxyHost != null) {