[jboss-svn-commits] JBL Code SVN: r34799 - in labs/jbossesb/branches/JBESB_4_7_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap: proxy and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Aug 19 13:09:31 EDT 2010
Author: kevin.conner at jboss.com
Date: 2010-08-19 13:09:31 -0400 (Thu, 19 Aug 2010)
New Revision: 34799
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/proxy/SOAPProxy.java
labs/jbossesb/branches/JBESB_4_7_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxyWsdlContractPublisher.java
labs/jbossesb/branches/JBESB_4_7_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxyWsdlLoader.java
Log:
Handle propagation of action configuration to SOAPProxyWsdlLoader: JBESB-3467
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-08-19 16:50:41 UTC (rev 34798)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/RemoteWsdlLoader.java 2010-08-19 17:09:31 UTC (rev 34799)
@@ -23,7 +23,9 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.util.Map.Entry;
import java.util.Properties;
+import java.util.Set;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
@@ -51,11 +53,13 @@
private static Logger logger = Logger.getLogger(RemoteWsdlLoader.class);
private HttpClient httpClient;
private HostConfiguration hostConfig;
+ private ConfigTree config;
public RemoteWsdlLoader(Properties httpClientProps) throws ConfigurationException {
httpClient = HttpClientFactory.createHttpClient(httpClientProps);
hostConfig = httpClient.getHostConfiguration();
httpClient.setHostConfiguration(new HostConfiguration());
+ this.config = generateConfig(httpClientProps);
}
public InputStream load(String url, String charsetNameOverride) throws IOException {
@@ -75,7 +79,7 @@
HttpMethodBase httpMethod;
try {
- HttpMethodFactory methodFactory = HttpMethodFactory.Factory.getInstance("GET", new ConfigTree("RemoteWsdlLoader"), new URL(url));
+ HttpMethodFactory methodFactory = HttpMethodFactory.Factory.getInstance("GET", config, new URL(url));
httpMethod = methodFactory.getInstance(null);
} catch (ConfigurationException ce) {
throw (IOException)(new IOException(ce.getMessage()).initCause(ce));
@@ -135,5 +139,18 @@
HttpClientFactory.shutdown(httpClient);
httpClient = null ;
}
+
+ private static ConfigTree generateConfig(final Properties properties) {
+ final ConfigTree config = new ConfigTree("RemoteWsdlLoader");
+ final Set<Entry<Object, Object>> entrySet = properties.entrySet();
+ for (Entry<Object, Object> entry: entrySet) {
+ final Object key = entry.getKey();
+ final Object value = entry.getValue();
+ if ((key != null) && (value!=null)) {
+ config.setAttribute(key.toString(), value.toString());
+ }
+ }
+ return config;
+ }
}
Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxy.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxy.java 2010-08-19 16:50:41 UTC (rev 34798)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxy.java 2010-08-19 17:09:31 UTC (rev 34799)
@@ -30,13 +30,18 @@
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.publish.ContractProvider;
+import org.jboss.internal.soa.esb.publish.ContractProviderLifecycleResource;
import org.jboss.internal.soa.esb.publish.Publish;
+import org.jboss.soa.esb.Configurable;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
import org.jboss.soa.esb.actions.ActionLifecycleException;
import org.jboss.soa.esb.actions.ActionProcessingException;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.http.HttpRequest;
+import org.jboss.soa.esb.lifecycle.LifecycleResourceException;
+import org.jboss.soa.esb.listeners.ListenerTagNames;
import org.jboss.soa.esb.listeners.message.MessageDeliverException;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.MessagePayloadProxy;
@@ -129,6 +134,7 @@
* <li><b>file</b> (optional): Apache Commons HTTPClient properties file, useful when proxying to a web service via SSL</li>
* <li><b>clientCredentialsRequired</b> (optional; default is "true"): Whether the Basic Auth credentials are required to come from the end
* client, or if the credentials specified inside <b>file</b> can be used instead.</li>
+ * <li><b>wsdlUseHttpClientProperties</b> (optional): if true then WSDL retrieval will use the same http-client-property as main webservice, otherwise will use wsdl-http-client-property entries.
* </ul>
* <b>*</b> For other possible configuration properties, see the specific {@link SOAPProxyTransport} implementations themselves.<p/>
*
@@ -165,6 +171,7 @@
public SOAPProxy(ConfigTree config) throws ConfigurationException
{
payloadProxy = new MessagePayloadProxy(config);
+ initialiseContractPublisher(config);
SOAPProxyWsdlLoader wsdl_loader = SOAPProxyWsdlLoader.newLoader(config);
WSDLDefinitions wsdl_def;
try
@@ -252,6 +259,35 @@
}
}
+ private void initialiseContractPublisher(final ConfigTree config)
+ throws ConfigurationException
+ {
+ final ConfigTree parent = config.getParent();
+ if (parent != null)
+ {
+ final String category = parent.getAttribute(ListenerTagNames.SERVICE_CATEGORY_NAME_TAG);
+ final String name = parent.getAttribute(ListenerTagNames.SERVICE_NAME_TAG);
+ if ((category != null) && (name != null))
+ {
+ final ContractProvider provider ;
+ try
+ {
+ provider = ContractProviderLifecycleResource.getContractProvider(category, name);
+ }
+ catch (final LifecycleResourceException lre)
+ {
+ throw new ConfigurationException("Unexpected exception querying contract provider", lre);
+ }
+
+ if ((provider != null) && (provider instanceof Configurable))
+ {
+ final Configurable configurable = Configurable.class.cast(provider) ;
+ configurable.setConfiguration(config);
+ }
+ }
+ }
+ }
+
public void initialise() throws ActionLifecycleException
{
for ( SOAPProxyTransport transport : binding_to_transport.values() )
Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxyWsdlContractPublisher.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxyWsdlContractPublisher.java 2010-08-19 16:50:41 UTC (rev 34798)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxyWsdlContractPublisher.java 2010-08-19 17:09:31 UTC (rev 34799)
@@ -25,6 +25,7 @@
import org.jboss.internal.soa.esb.publish.ContractInfo;
import org.jboss.internal.soa.esb.publish.ContractProvider;
+import org.jboss.soa.esb.Configurable;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.Service;
import org.jboss.soa.esb.actions.soap.AuthBASICWsdlContractPublisher;
@@ -37,31 +38,39 @@
*
* @author dward at jboss.org
*/
-public class SOAPProxyWsdlContractPublisher extends AuthBASICWsdlContractPublisher implements ContractProvider
+public class SOAPProxyWsdlContractPublisher extends AuthBASICWsdlContractPublisher implements ContractProvider, Configurable
{
+ private ConfigTree actionConfig;
@Override
public ContractInfo getContractInfo(Service service, String wsdlAddress) throws IOException
{
- Properties properties = getActionProperties();
- ConfigTree config;
- if (service != null)
+ final ConfigTree config;
+ if ((wsdlAddress != null) && wsdlAddress.startsWith("http"))
{
- ConfigTree parent_config = new ConfigTree("parent_config");
- parent_config.setAttribute( ListenerTagNames.SERVICE_CATEGORY_NAME_TAG, service.getCategory() );
- parent_config.setAttribute( ListenerTagNames.SERVICE_NAME_TAG, service.getName() );
- config = new ConfigTree("config", parent_config);
+ config = actionConfig ;
}
else
{
- config = new ConfigTree("config");
+ Properties properties = getActionProperties();
+ if (service != null)
+ {
+ ConfigTree parent_config = new ConfigTree("parent_config");
+ parent_config.setAttribute( ListenerTagNames.SERVICE_CATEGORY_NAME_TAG, service.getCategory() );
+ parent_config.setAttribute( ListenerTagNames.SERVICE_NAME_TAG, service.getName() );
+ config = new ConfigTree("config", parent_config);
+ }
+ else
+ {
+ config = new ConfigTree("config");
+ }
+ for ( Object key : properties.keySet() )
+ {
+ String name = (String)key;
+ String value = properties.getProperty(name);
+ config.setAttribute(name, value);
+ }
}
- for ( Object key : properties.keySet() )
- {
- String name = (String)key;
- String value = properties.getProperty(name);
- config.setAttribute(name, value);
- }
SOAPProxyWsdlLoader wsdl_loader;
try
{
@@ -114,5 +123,11 @@
}
return contract;
}
+
+ public void setConfiguration(final ConfigTree config) throws ConfigurationException {
+ if (actionConfig == null) {
+ actionConfig = config;
+ }
+ }
}
Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxyWsdlLoader.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxyWsdlLoader.java 2010-08-19 16:50:41 UTC (rev 34798)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/proxy/SOAPProxyWsdlLoader.java 2010-08-19 17:09:31 UTC (rev 34799)
@@ -41,6 +41,7 @@
import java.util.Map;
import java.util.Properties;
import java.util.Map.Entry;
+import java.util.Set;
import javax.management.JMException;
import javax.management.MBeanServer;
@@ -52,6 +53,8 @@
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.actions.soap.AuthBASICWsdlContractPublisher;
import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.http.HttpClientFactory;
+import org.jboss.soa.esb.http.configurators.Connection;
import org.jboss.soa.esb.listeners.ListenerTagNames;
import org.jboss.util.xml.DOMUtils;
import org.jboss.util.xml.DOMWriter;
@@ -382,7 +385,8 @@
String address = config.getRequiredAttribute("wsdl");
if ( address.startsWith("http://") || address.startsWith("https://") )
{
- loader = new DefaultSOAPProxyWsdlLoader(config, address, true);
+ final ConfigTree httpClientProps = extractHttpClientConfig(config, address) ;
+ loader = new DefaultSOAPProxyWsdlLoader(httpClientProps, address, true);
}
else if ( address.startsWith("file://") || address.startsWith("classpath://") )
{
@@ -399,6 +403,56 @@
return loader;
}
+ private static ConfigTree extractHttpClientConfig(final ConfigTree config, final String address)
+ {
+ final ConfigTree newParent = new ConfigTree("http-client-parent");
+ final ConfigTree newConfig = new ConfigTree("http-client-config", newParent);
+
+ if (config.getBooleanAttribute("wsdlUseHttpClientProperties", false)) {
+ extractHttpClientAttributes(newConfig, config.getChildren("http-client-property"));
+ }
+ final ConfigTree[] wsdlHttpClientConfigTrees = config.getChildren("wsdl-http-client-property");
+ if (wsdlHttpClientConfigTrees.length > 0) {
+ extractHttpClientAttributes(newConfig, wsdlHttpClientConfigTrees);
+ }
+
+ final Set<String> attributeNames = config.getAttributeNames();
+ for(String name: attributeNames) {
+ final String value = config.getAttribute(name);
+ if (value != null) {
+ newConfig.setAttribute(name, value);
+ }
+ }
+ newConfig.setAttribute(HttpClientFactory.TARGET_HOST_URL, address);
+ newConfig.setAttribute(Connection.MAX_TOTAL_CONNECTIONS, "1");
+ newConfig.setAttribute(Connection.MAX_CONNECTIONS_PER_HOST, "1");
+
+ final ConfigTree parent = config.getParent();
+ if (parent != null) {
+ final String serviceCat = parent.getAttribute(ListenerTagNames.SERVICE_CATEGORY_NAME_TAG);
+ if (serviceCat != null) {
+ newParent.setAttribute(ListenerTagNames.SERVICE_CATEGORY_NAME_TAG, serviceCat) ;
+ }
+ final String serviceName = parent.getAttribute(ListenerTagNames.SERVICE_NAME_TAG);
+ if (serviceName != null) {
+ newParent.setAttribute(ListenerTagNames.SERVICE_NAME_TAG, serviceName) ;
+ }
+ }
+
+ return newConfig;
+ }
+
+ private static void extractHttpClientAttributes(final ConfigTree configTree, final ConfigTree[] httpClientChildren)
+ {
+ for(ConfigTree httpClientChild : httpClientChildren) {
+ final String name = httpClientChild.getAttribute("name");
+ final String value = httpClientChild.getAttribute("value");
+ if ((name != null) && (value != null)) {
+ configTree.setAttribute(name, value);
+ }
+ }
+ }
+
static class DefaultSOAPProxyWsdlLoader extends SOAPProxyWsdlLoader
{
More information about the jboss-svn-commits
mailing list