[jboss-svn-commits] JBL Code SVN: r31122 - in labs/jbossesb/branches/JBESB_4_7_CP/product: rosetta/src/org/jboss/soa/esb/http/configurators and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Jan 18 08:30:21 EST 2010
Author: dward
Date: 2010-01-18 08:30:21 -0500 (Mon, 18 Jan 2010)
New Revision: 31122
Modified:
labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpMethodFactory.java
labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/http/configurators/HttpProtocol.java
labs/jbossesb/branches/JBESB_4_7_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/RemoteWsdlLoader.java
Log:
Fix for JBESB-3092 ( https://jira.jboss.org/jira/browse/JBESB-3092 ).
Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpMethodFactory.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpMethodFactory.java 2010-01-18 11:45:07 UTC (rev 31121)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpMethodFactory.java 2010-01-18 13:30:21 UTC (rev 31122)
@@ -19,17 +19,17 @@
*/
package org.jboss.soa.esb.actions.routing.http;
+import java.io.IOException;
+import java.net.URL;
+
+import org.apache.commons.httpclient.HttpMethodBase;
import org.jboss.internal.soa.esb.assertion.AssertArgument;
import org.jboss.soa.esb.Configurable;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.util.ClassUtil;
-import org.apache.commons.httpclient.HttpMethodBase;
-import java.io.IOException;
-import java.net.URL;
-
/**
* Http method executor.
*
@@ -48,7 +48,6 @@
public static HttpMethodFactory getInstance(String method, ConfigTree config, URL endpointUrl) throws ConfigurationException {
AssertArgument.isNotNullAndNotEmpty(method, "method");
- AssertArgument.isNotNull(config, "config");
AssertArgument.isNotNull(endpointUrl, "endpointUrl");
String className = HttpMethodFactory.class.getPackage().getName() + "." + method + HttpMethodFactory.class.getSimpleName();
Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/http/configurators/HttpProtocol.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/http/configurators/HttpProtocol.java 2010-01-18 11:45:07 UTC (rev 31121)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/http/configurators/HttpProtocol.java 2010-01-18 13:30:21 UTC (rev 31122)
@@ -63,6 +63,7 @@
* SSL. To authenticate with a self-signed certificate, use the
* {@link org.jboss.soa.esb.http.protocol.SelfSignedSSLProtocolSocketFactoryBuilder} (test/demo only) and to perform
* full authentication (2way) with CA Signed certs, use the {@link org.jboss.soa.esb.http.protocol.AuthSSLProtocolSocketFactoryBuilder}.</li>
+ * <li><b>protocol-default-port</b>: (Optional). See {@link Protocol}. Defaults to <code>targetURI.getPort()</code>.</li>
* </ul>
* <p/>
* See <a href="http://jakarta.apache.org/commons/httpclient/sslguide.html">HttpClient HttpProtocol Guide</a>.
@@ -102,9 +103,12 @@
}
assertPropertySetAndNotBlank(factory, "protocol-socket-factory");
socketFactory = createFactoryClass(factory, keyMaterial, properties);
+
+ // JBESB-3092
+ int defaultPort = Integer.valueOf(properties.getProperty("protocol-default-port", String.valueOf(port))).intValue();
// And finally... configure the host with the protocol....
- protocol = new Protocol(scheme, socketFactory, port);
+ protocol = new Protocol(scheme, socketFactory, defaultPort);
Protocol.registerProtocol(scheme, protocol);
// these lines have to happen after registerProtocol, otherwise they pick up the wrong static value
if (secure) {
Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/RemoteWsdlLoader.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/RemoteWsdlLoader.java 2010-01-18 11:45:07 UTC (rev 31121)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/RemoteWsdlLoader.java 2010-01-18 13:30:21 UTC (rev 31122)
@@ -19,19 +19,21 @@
*/
package org.jboss.soa.esb.actions.soap;
-import java.io.InputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.net.URL;
import java.util.Properties;
+import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpMethodBase;
import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.routing.http.HttpMethodFactory;
import org.jboss.soa.esb.http.HttpClientFactory;
-import org.jboss.soa.esb.ConfigurationException;
/**
* {@link HttpClientFactory} based WSLD loader.
@@ -45,25 +47,39 @@
private static Logger logger = Logger.getLogger(RemoteWsdlLoader.class);
private HttpClient httpClient;
+ private HostConfiguration hostConfig;
public RemoteWsdlLoader(Properties httpClientProps) throws ConfigurationException {
- this.httpClient = HttpClientFactory.createHttpClient(httpClientProps);
+ // JBESB-3092
+ if (!httpClientProps.containsKey("protocol-default-port")) {
+ httpClientProps.setProperty("protocol-default-port", "9999");
+ }
+ httpClient = HttpClientFactory.createHttpClient(httpClientProps);
+ hostConfig = httpClient.getHostConfiguration();
+ httpClient.setHostConfiguration(new HostConfiguration());
}
public InputStream load(String url) throws IOException {
- GetMethod httpGetMethod;
+ HttpMethodBase httpMethod;
if(url.startsWith("file")) {
return new URL(url).openStream();
}
+
+ try {
+ HttpMethodFactory methodFactory = HttpMethodFactory.Factory.getInstance("GET", null, new URL(url));
+ httpMethod = methodFactory.getInstance(null);
+ } catch (ConfigurationException ce) {
+ // should never happen with "GET" method since ConfigTree isn't used with GET - only POST
+ throw (IOException)(new IOException(ce.getMessage()).initCause(ce));
+ }
// Authentication is not being overridden on the method. It needs
// to be present on the supplied HttpClient instance!
- httpGetMethod = new GetMethod(url);
- httpGetMethod.setDoAuthentication(true);
+ httpMethod.setDoAuthentication(true);
try {
- int result = httpClient.executeMethod(httpGetMethod);
+ int result = httpClient.executeMethod(hostConfig, httpMethod);
if(result != HttpStatus.SC_OK) {
if(result < 200 || result > 299) {
@@ -73,9 +89,10 @@
}
}
- return new ByteArrayInputStream(httpGetMethod.getResponseBody());
+ return new ByteArrayInputStream(httpMethod.getResponseBody());
} finally {
- httpGetMethod.releaseConnection();
+ httpMethod.releaseConnection();
}
}
-}
\ No newline at end of file
+}
+
More information about the jboss-svn-commits
mailing list