[jboss-svn-commits] JBL Code SVN: r13642 - in labs/jbossesb/trunk/product: install and 21 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Jul 19 14:59:35 EDT 2007
Author: tfennelly
Date: 2007-07-19 14:59:35 -0400 (Thu, 19 Jul 2007)
New Revision: 13642
Added:
labs/jbossesb/trunk/product/lib/ext/commons-ssl-0.3.4.jar
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/ESBProperties.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/LRUCache.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/Configurator.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/HttpClientFactory.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/configurators/
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/configurators/AuthBASIC.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/configurators/HttpProtocol.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/ESBPropertiesUnitTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/LRUCacheUnitTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/StreamUtilsUnitTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/testprops.properties
labs/jbossesb/trunk/product/samples/quickstarts/webservice_bpel/bpel/localhost-https-18443.properties
labs/jbossesb/trunk/product/services/soap/lib/ext/commons-ssl-0.3.4.jar
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SoapUIInvoker.java
labs/jbossesb/trunk/product/services/soapui-client/src/lib/commons-ssl-0.3.4.jar
labs/jbossesb/trunk/product/services/soapui-client/src/lib/soapui-1.7.1.jar
labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/EsbWsdlLoader.java
labs/jbossesb/trunk/product/services/soapui-client/src/main/resources/META-INF/smooks-creators.xml
labs/jbossesb/trunk/product/services/soapui-client/src/main/resources/soapui-client.sar.properties
labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/expected_04.xml
labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/sendNotificationTransform.xml
Removed:
labs/jbossesb/trunk/product/services/soapui-client/src/lib/milyn-commons-0.9-SNAPSHOT.jar
labs/jbossesb/trunk/product/services/soapui-client/src/lib/soapui-1.7.jar
Modified:
labs/jbossesb/trunk/product/build-distr.xml
labs/jbossesb/trunk/product/build.xml
labs/jbossesb/trunk/product/install/build.xml
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/StreamUtils.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/ActionMapper.java
labs/jbossesb/trunk/product/samples/quickstarts/webservice_bpel/build.xml
labs/jbossesb/trunk/product/samples/quickstarts/webservice_bpel/jboss-esb.xml
labs/jbossesb/trunk/product/services/build.xml
labs/jbossesb/trunk/product/services/smooks/lib/ext/milyn-smooks-core-0.9-SNAPSHOT.jar
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPClientUnitTest.java
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/soapclient-config-01.xml
labs/jbossesb/trunk/product/services/soapui-client/build.xml
labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientService.java
labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBean.java
labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBeanUnitTest.java
labs/jbossesb/trunk/product/services/soapui-client/src/test/resources/log4j.xml
Log:
Fixes for the following issues:
- http://jira.jboss.com/jira/browse/JBESB-727
- http://jira.jboss.com/jira/browse/JBESB-650
Modified: labs/jbossesb/trunk/product/build-distr.xml
===================================================================
--- labs/jbossesb/trunk/product/build-distr.xml 2007-07-19 18:54:41 UTC (rev 13641)
+++ labs/jbossesb/trunk/product/build-distr.xml 2007-07-19 18:59:35 UTC (rev 13642)
@@ -86,7 +86,7 @@
<fileset dir="${services.dir}/spring/build" includes="spring.esb/**/*"/>
<fileset dir="${services.dir}/spring/build" includes="spring.esb/**/*"/>
<fileset dir="${services.dir}/soap/build" includes="soap.esb/**/*"/>
- <fileset dir="${services.dir}/soapui-client/target" includes="*.sar"/>
+ <fileset dir="build/jbossesb/lib" includes="soapui-client.sar/**/*"/>
</copy>
</target>
Modified: labs/jbossesb/trunk/product/build.xml
===================================================================
--- labs/jbossesb/trunk/product/build.xml 2007-07-19 18:54:41 UTC (rev 13641)
+++ labs/jbossesb/trunk/product/build.xml 2007-07-19 18:59:35 UTC (rev 13642)
@@ -423,8 +423,11 @@
<delete dir="${org.jboss.esb.internal.javadocs.dest}"/>
<delete>
<fileset dir="." includes="scout.log unittest.log"/>
- </delete>
- </target>
+ </delete>
+ <delete>
+ <fileset dir="." includes="**/build/**/*,**/target/**/*"/>
+ </delete>
+ </target>
<!-- Short target names -->
<target name="compile" description="will compile all classes">
Modified: labs/jbossesb/trunk/product/install/build.xml
===================================================================
--- labs/jbossesb/trunk/product/install/build.xml 2007-07-19 18:54:41 UTC (rev 13641)
+++ labs/jbossesb/trunk/product/install/build.xml 2007-07-19 18:59:35 UTC (rev 13642)
@@ -137,9 +137,22 @@
</copy>
<!-- soapui-client.sar -->
- <copy file="${org.jboss.esb.dist.lib}/soapui-client.sar" todir="${deploy.dir}" />
+ <copy todir="${deploy.dir}/soapui-client.sar">
+ <fileset dir="${org.jboss.esb.dist.lib}/soapui-client.sar" excludes="${messaging.excludes}"/>
+ </copy>
</target>
+ <target name="undeploy" depends="check.deploy.props" description="Undeploy ESB components.">
+ <delete dir="${deploy.dir}/jbossesb.sar" />
+ <delete dir="${deploy.dir}/jbossesb.esb" />
+ <delete dir="${deploy.dir}/jbpm.esb" />
+ <delete dir="${deploy.dir}/jbrules.esb" />
+ <delete dir="${deploy.dir}/smooks.esb" />
+ <delete dir="${deploy.dir}/spring.esb" />
+ <delete dir="${deploy.dir}/soap.esb" />
+ <delete dir="${deploy.dir}/soapui-client.sar" />
+ </target>
+
<property name="org.jboss.esb.tomcat.55lib"
location="${org.jboss.esb.tomcat.home}/common/lib"/>
<property name="org.jboss.esb.tomcat.60lib"
Added: labs/jbossesb/trunk/product/lib/ext/commons-ssl-0.3.4.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/trunk/product/lib/ext/commons-ssl-0.3.4.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/ESBProperties.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/ESBProperties.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/ESBProperties.java 2007-07-19 18:59:35 UTC (rev 13642)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+
+/**
+ * ESB Properties.
+ * <p/>
+ * Loads the properties resource from either of filesystem, URL or classpath.
+ * See {@link StreamUtils#getResource(String)}.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class ESBProperties extends Properties {
+
+ private static final long serialVersionUID = 1L;
+ private static Logger logger = Logger.getLogger(ESBProperties.class);
+
+ public ESBProperties(String propertiesResource) throws ConfigurationException {
+ InputStream config = StreamUtils.getResource(propertiesResource);
+
+ try {
+ load(config);
+ } catch (IOException e) {
+ throw new ConfigurationException("Error reading '" + propertiesResource + "'.", e);
+ } finally {
+ try {
+ config.close();
+ } catch (IOException e) {
+ logger.warn("Failed to close stream to '" + propertiesResource + "'.");
+ }
+ }
+ }
+
+ public int getIntProperty(String key, int defaultVal) {
+ String value = getProperty(key);
+
+ if(value == null) {
+ return defaultVal;
+ }
+
+ try {
+ return Integer.parseInt(value.trim());
+ } catch(NumberFormatException e) {
+ logger.error("Invalid property value format for property '" + key + "'. Integer value expected. Actual value '" + value + "'.");
+ return defaultVal;
+ }
+ }
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/ESBProperties.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/LRUCache.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/LRUCache.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/LRUCache.java 2007-07-19 18:59:35 UTC (rev 13642)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.util;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Simple LRU cache.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class LRUCache<K, V> extends LinkedHashMap<K, V> {
+
+ private int cacheSize;
+
+ /**
+ * Public constructor.
+ * @param size Cache size.
+ */
+ public LRUCache(int size) {
+ super(size, 0.75f, true); // 0.75 comes from HashMap.DEFAULT_LOAD_FACTOR, but it's package private.
+ this.cacheSize = size;
+ }
+
+ protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
+ return (size() > cacheSize);
+ }
+}
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/LRUCache.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/StreamUtils.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/StreamUtils.java 2007-07-19 18:54:41 UTC (rev 13641)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/StreamUtils.java 2007-07-19 18:59:35 UTC (rev 13642)
@@ -21,17 +21,25 @@
*/
package org.jboss.internal.soa.esb.util;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
+import org.jboss.soa.esb.util.ClassUtil;
+import org.jboss.soa.esb.ConfigurationException;
+import org.apache.commons.ssl.KeyMaterial;
+import org.apache.log4j.Logger;
+import java.io.*;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.security.GeneralSecurityException;
+
/**
* Stream handling utilities.
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
*/
public class StreamUtils {
- /**
+ private static Logger logger = Logger.getLogger(StreamUtils.class);
+
+ /**
* Read the supplied InputStream and return as an array of bytes.
* @param stream The stream to read.
* @return The stream contents in an array of bytes.
@@ -55,4 +63,59 @@
return outBuffer.toByteArray();
}
+
+ public static String readStreamString(InputStream stream, String charset) throws UnsupportedEncodingException {
+ return new String(StreamUtils.readStream(stream), charset);
+ }
+
+ public static String getResourceAsString(String resource, String charset) throws ConfigurationException, UnsupportedEncodingException {
+ InputStream stream = getResource(resource);
+
+ try {
+ return readStreamString(stream, charset);
+ } finally {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ logger.error("Error closing resource stream '" + resource + "'.", e);
+ }
+ }
+ }
+
+ /**
+ * Load a stream resource.
+ * @param resource Resource classpath/filesystem/URL location.
+ * @return The resource stream.
+ * @throws ConfigurationException Failed to load the resource.
+ */
+ public static InputStream getResource(String resource) throws ConfigurationException {
+ try {
+ // Try it as a File resource...
+ File file = new File(resource);
+
+ if(file.exists() && !file.isDirectory()) {
+ return new FileInputStream(file);
+ }
+
+ // Try it as a classpath resource ...
+ InputStream stream = ClassUtil.getResourceAsStream(resource, StreamUtils.class);
+ if(stream != null) {
+ return stream;
+ }
+
+ // Try it as a URI resource...
+ try {
+ URI fileURI = new URI(resource);
+ if(fileURI.isAbsolute()) {
+ return fileURI.toURL().openStream();
+ }
+ } catch (URISyntaxException e) {
+ throw new ConfigurationException("Failed to load resource '" + resource + "'.");
+ }
+ } catch (IOException e) {
+ throw new ConfigurationException("Failed to load resource '" + resource + "'.", e);
+ }
+
+ throw new ConfigurationException("Failed to locate resource '" + resource + "'.");
+ }
}
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/Configurator.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/Configurator.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/Configurator.java 2007-07-19 18:59:35 UTC (rev 13642)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.http;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.http.HttpClientFactory;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.log4j.Logger;
+
+import java.util.Properties;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.io.FileWriter;
+import java.io.IOException;
+
+/**
+ * HttpClient Configurator.
+ * <p/>
+ * Configure some aspect of a HttpClient instance.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public abstract class Configurator {
+
+ public abstract void configure(HttpClient httpClient, Properties properties) throws ConfigurationException;
+
+ /**
+ * Gets a {@link URI} for the {@link HttpClientFactory#TARGET_HOST_URL} property,
+ * if set.
+ * @param properties Properties.
+ * @param required If the {@link HttpClientFactory#TARGET_HOST_URL} property is required. An
+ * exception is thrown if this is true and the property is not present.
+ * @return URI for the {@link HttpClientFactory#TARGET_HOST_URL} property, otherwise null
+ * if not set.
+ * @throws ConfigurationException {@link HttpClientFactory#TARGET_HOST_URL} property is not set
+ * an required is true, or the configured URI is invalid.
+ */
+ protected URI getTargetURI(Properties properties, boolean required) throws ConfigurationException {
+ String targetURLString = properties.getProperty(HttpClientFactory.TARGET_HOST_URL);
+
+ if(required) {
+ assertPropertySetAndNotBlank(targetURLString, HttpClientFactory.TARGET_HOST_URL);
+ }
+ if(targetURLString != null) {
+ try {
+ return new URI(targetURLString);
+ } catch (URISyntaxException e) {
+ throw new ConfigurationException("'url' property is not a valid URI.");
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Assert that the property value is not null and not blank.
+ * @param propertyValue The value of the property.
+ * @param propertyName The name of the property.
+ */
+ protected void assertPropertySetAndNotBlank(String propertyValue, String propertyName) throws ConfigurationException {
+ if(propertyValue == null || propertyValue.trim().equals("")) {
+ throw new ConfigurationException(getClass().getSimpleName() + " must be configured with a non-blank value for the '" + propertyName + "' property.");
+ }
+ }
+
+ /**
+ * Assert that the property value is an Integer.
+ * @param propertyValue The value of the property.
+ * @param propertyName The name of the property.
+ */
+ protected void assertPropertyIsInteger(String propertyValue, String propertyName) throws ConfigurationException {
+ assertPropertySetAndNotBlank(propertyValue, propertyName);
+ try {
+ Integer.parseInt(propertyValue);
+ } catch(NumberFormatException e) {
+ throw new ConfigurationException(getClass().getSimpleName() + " must be configured with an Integer value for the '" + propertyName + "' property.");
+ }
+ }
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/Configurator.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/HttpClientFactory.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/HttpClientFactory.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/HttpClientFactory.java 2007-07-19 18:59:35 UTC (rev 13642)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.http;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.http.configurators.HttpProtocol;
+import org.jboss.soa.esb.util.ClassUtil;
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.internal.soa.esb.util.StreamUtils;
+import org.apache.commons.httpclient.HttpClient;
+
+import java.util.Properties;
+import java.io.IOException;
+
+/**
+ * {@link org.apache.commons.httpclient.HttpClient} factory class.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public abstract class HttpClientFactory {
+
+ /**
+ * Target host url.
+ */
+ public static final String TARGET_HOST_URL = "target-host-url";
+
+ /**
+ * Factory method for creating the {@link org.apache.commons.httpclient.HttpClient}
+ * instance.
+ *
+ * @param properties {@link org.apache.commons.httpclient.HttpClient} creation properties.
+ * @return The {@link org.apache.commons.httpclient.HttpClient} instance.
+ * @throws ConfigurationException Invalid configuration properties set.
+ */
+ public static HttpClient createHttpClient(Properties properties) throws ConfigurationException {
+ AssertArgument.isNotNull(properties, "properties");
+
+ HttpClient httpClient = new HttpClient();
+ String fileConfig = (String) properties.remove("file");
+ String[] configurators;
+
+ if(fileConfig != null) {
+ try {
+ properties.load(StreamUtils.getResource(fileConfig));
+ } catch (IOException e) {
+ throw new ConfigurationException("Failed to load HttpClient config '" + fileConfig + "'.");
+ }
+ }
+
+ configurators = properties.getProperty("configurators", HttpProtocol.class.getName()).split(",");
+ for(String configuratorClass : configurators) {
+ Configurator configurator = createConfigurator(configuratorClass.trim());
+ configurator.configure(httpClient, properties);
+ }
+
+ return httpClient;
+ }
+
+ private static Configurator createConfigurator(String configuratorClass) throws ConfigurationException {
+ try {
+ return (Configurator) ClassUtil.forName(configuratorClass, HttpClientFactory.class).newInstance();
+ } catch (ClassCastException e) {
+ throw new ConfigurationException("Class [" + configuratorClass + "] must extend [" + Configurator.class.getName() + "].", e);
+ } catch (ClassNotFoundException e) {
+ if(!configuratorClass.startsWith(HttpProtocol.class.getPackage().getName())) {
+ return createConfigurator(HttpProtocol.class.getPackage().getName() + "." + configuratorClass);
+ }
+ throw new ConfigurationException("Configurator implementation class [" + configuratorClass + "] not found in classpath.", e);
+ } catch (InstantiationException e) {
+ throw new ConfigurationException("Failed to instantiate Configurator implementation class [" + configuratorClass + "].", e);
+ } catch (IllegalAccessException e) {
+ throw new ConfigurationException("Failed to instantiate Configurator implementation class [" + configuratorClass + "].", e);
+ }
+ }
+
+
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/HttpClientFactory.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/configurators/AuthBASIC.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/configurators/AuthBASIC.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/configurators/AuthBASIC.java 2007-07-19 18:59:35 UTC (rev 13642)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.http.configurators;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.auth.AuthScope;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.http.Configurator;
+
+import java.util.Properties;
+import java.net.URI;
+
+/**
+ * HTTP BASIC Authentication Configurator.
+ * <p/>
+ * Properties:
+ * <ul>
+ * <li><b>username</b>: See {@link UsernamePasswordCredentials}. (Required)</li>
+ * <li><b>password</b>: See {@link UsernamePasswordCredentials}. (Required)</li>
+ * <li><b>authscope-host</b>: See {@link AuthScope}. (Required)</li>
+ * <li><b>authscope-port</b>: See {@link AuthScope}. (Required)</li>
+ * <li><b>authscope-realm</b>: See {@link AuthScope}. (Optional)</li>
+ * </ul>
+ * <p/>
+ * See <a href="http://jakarta.apache.org/commons/httpclient/authentication.html">HttpClient Authentication Guide</a>.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class AuthBASIC extends Configurator {
+
+ public void configure(HttpClient httpClient, Properties properties) throws ConfigurationException {
+ URI targetURI = getTargetURI(properties, false);
+ String username = properties.getProperty("auth-username");
+ String password = properties.getProperty("auth-password");
+ String authScopeHost;
+ String authScopePort;
+ String authScopeRealm = properties.getProperty("authscope-realm");
+
+ if(targetURI != null) {
+ authScopeHost = properties.getProperty("authscope-host", targetURI.getHost());
+ authScopePort = properties.getProperty("authscope-port", Integer.toString(targetURI.getPort()));
+ } else {
+ authScopeHost = properties.getProperty("authscope-host");
+ authScopePort = properties.getProperty("authscope-port");
+ }
+
+ assertPropertySetAndNotBlank(username, "auth-username");
+ assertPropertySetAndNotBlank(password, "auth-password");
+ assertPropertySetAndNotBlank(authScopeHost, "authscope-host");
+ assertPropertyIsInteger(authScopePort, "authscope-port");
+
+ Credentials creds = new UsernamePasswordCredentials(username, password);
+ AuthScope authScope;
+
+ if(authScopeRealm != null && !authScopeRealm.trim().equals("")) {
+ authScope = new AuthScope(authScopeHost, Integer.parseInt(authScopePort), authScopeRealm);
+ } else {
+ authScope = new AuthScope(authScopeHost, Integer.parseInt(authScopePort));
+ }
+
+ httpClient.getState().setCredentials(authScope, creds);
+ }
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/configurators/AuthBASIC.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/configurators/HttpProtocol.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/configurators/HttpProtocol.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/configurators/HttpProtocol.java 2007-07-19 18:59:35 UTC (rev 13642)
@@ -0,0 +1,179 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.http.configurators;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.contrib.ssl.StrictSSLProtocolSocketFactory;
+import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
+import org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory;
+import org.apache.commons.httpclient.protocol.Protocol;
+import org.apache.commons.ssl.KeyMaterial;
+import org.apache.commons.ssl.SSLClient;
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.http.Configurator;
+import org.jboss.soa.esb.util.ClassUtil;
+
+import java.util.Properties;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.io.*;
+import java.security.GeneralSecurityException;
+import java.security.NoSuchAlgorithmException;
+import java.security.KeyStoreException;
+import java.security.KeyManagementException;
+import java.security.cert.CertificateException;
+
+/**
+ * HTTP Protocol configurator.
+ * <p/>
+ * Supports both HTTP and HTTPS, including configuring the socket factory and SSL keystore. It
+ * supports the SSL keystore being on the classpath, filesystem or based on a {@link URI}.
+ * <p/>
+ * Properties:
+ * <ul>
+ * <li><b>target-host-url</b>: (Required)</li>
+ * <li><b>keystore</b>: (Optional). See {@link KeyMaterial}. Defaults to "/keystore".</li>
+ * <li><b>keystore-passwd</b>: (Optional). See {@link KeyMaterial}. Defaults to "changeit".</li>
+ * <li><b>protocol-socket-factory</b>: See {@link Protocol}. (Optional).
+ * Defaults to {@link StrictSSLProtocolSocketFactory} for HTTPS, otherwise defaults to {@link DefaultProtocolSocketFactory}.
+ * Configure with {@link org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory} if you wish
+ * to allow the target server to authenticate with a self-signed certificate</li>
+ * </ul>
+ * <p/>
+ * See <a href="http://jakarta.apache.org/commons/httpclient/sslguide.html">HttpClient HttpProtocol Guide</a>.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class HttpProtocol extends Configurator {
+
+ private static Logger logger = Logger.getLogger(HttpProtocol.class);
+
+ public void configure(HttpClient httpClient, Properties properties) throws ConfigurationException {
+ URI targetURI = getTargetURI(properties, true);
+ String factory;
+ String scheme = targetURI.getScheme();
+ int port = targetURI.getPort();
+ org.apache.commons.httpclient.protocol.Protocol protocol;
+ KeyMaterial keyMaterial = null;
+ ProtocolSocketFactory socketFactory;
+
+ if(!scheme.startsWith("http")) {
+ // We're only interested in HTTP for this...
+ return;
+ }
+
+ if(scheme.equals("https")) {
+ factory = properties.getProperty("protocol-socket-factory", StrictSSLProtocolSocketFactory.class.getName());
+ keyMaterial = getKeyMaterial(properties);
+
+ if(port == -1) {
+ port = 443;
+ }
+ } else {
+ factory = properties.getProperty("protocol-socket-factory", DefaultProtocolSocketFactory.class.getName());
+ if(port == -1) {
+ port = 80;
+ }
+ }
+ assertPropertySetAndNotBlank(factory, "protocol-socket-factory");
+ socketFactory = createFactoryClass(factory, keyMaterial);
+
+ // And finally... configure the host with the protocol....
+ protocol = new Protocol(scheme, socketFactory, port);
+ Protocol.registerProtocol(scheme, protocol);
+ //httpClient.getHostConfiguration().setHost(targetURI.getHost(), port, protocol);
+ }
+
+ private KeyMaterial getKeyMaterial(Properties properties) throws ConfigurationException {
+ String keyStore = properties.getProperty("keystore", "/keystore");
+ String keyStorePassword = properties.getProperty("keystore-passw", "changeit");
+
+ // Try it as a classpath resource ...
+ InputStream keyStoreStream = ClassUtil.getResourceAsStream(keyStore, HttpProtocol.class);
+
+ try {
+ // Try it as a File resource...
+ if(keyStoreStream == null) {
+ File keyStoreFile = new File(keyStore);
+
+ if(keyStoreFile.exists() && !keyStoreFile.isDirectory()) {
+ return new KeyMaterial(new FileInputStream(keyStoreFile), keyStorePassword.toCharArray());
+ }
+ } else {
+ return new KeyMaterial(keyStoreStream, keyStorePassword.toCharArray());
+ }
+
+ // Try it as a URI resource...
+ if(keyStoreStream == null) {
+ try {
+ URI fileURI = new URI(keyStore);
+ if(fileURI.isAbsolute()) {
+ return new KeyMaterial(fileURI.toURL().openStream(), keyStorePassword.toCharArray());
+ }
+ } catch (URISyntaxException e) {
+ throw new ConfigurationException("Failed to load keystore '" + keyStore + "'.");
+ }
+ }
+ } catch (IOException e) {
+ throw new ConfigurationException("Failed to load keystore '" + keyStore + "'.", e);
+ } catch (GeneralSecurityException e) {
+ throw new ConfigurationException("Failed to load keystore '" + keyStore + "'.", e);
+ }
+
+ throw new ConfigurationException("Failed to locate keystore '" + keyStore + "'.");
+ }
+
+ private ProtocolSocketFactory createFactoryClass(String factory, KeyMaterial keyMaterial) throws ConfigurationException {
+ ProtocolSocketFactory socketFactory = null;
+
+ try {
+ socketFactory = (ProtocolSocketFactory) ClassUtil.forName(factory, HttpProtocol.class).newInstance();
+ } catch (ClassCastException e) {
+ throw new ConfigurationException("Class [" + factory + "] must implement [" + ProtocolSocketFactory.class.getName() + "].", e);
+ } catch (ClassNotFoundException e) {
+ throw new ConfigurationException("ProtocolSocketFactory implementation class [" + factory + "] not found in classpath.", e);
+ } catch (InstantiationException e) {
+ throw new ConfigurationException("Failed to instantiate ProtocolSocketFactory implementation class [" + factory + "].", e);
+ } catch (IllegalAccessException e) {
+ throw new ConfigurationException("Failed to instantiate ProtocolSocketFactory implementation class [" + factory + "].", e);
+ }
+
+ if(socketFactory instanceof SSLClient && keyMaterial != null) {
+ try {
+ ((SSLClient)socketFactory).setKeyMaterial(keyMaterial);
+ } catch (NoSuchAlgorithmException e) {
+ throw new ConfigurationException("Failed to configure SSL Keystore on SSLClient.", e);
+ } catch (KeyStoreException e) {
+ throw new ConfigurationException("Failed to configure SSL Keystore on SSLClient.", e);
+ } catch (KeyManagementException e) {
+ throw new ConfigurationException("Failed to configure SSL Keystore on SSLClient.", e);
+ } catch (IOException e) {
+ throw new ConfigurationException("Failed to configure SSL Keystore on SSLClient.", e);
+ } catch (CertificateException e) {
+ throw new ConfigurationException("Failed to configure SSL Keystore on SSLClient.", e);
+ }
+ }
+
+ return socketFactory;
+ }
+
+
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/http/configurators/HttpProtocol.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/ActionMapper.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/ActionMapper.java 2007-07-19 18:54:41 UTC (rev 13641)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/ActionMapper.java 2007-07-19 18:59:35 UTC (rev 13642)
@@ -75,12 +75,13 @@
MapperUtil.serialize(property, propertyElement);
- // If the property has child content, add that directy to the action. Of course it only really
+ if(property.getValue() != null) {
+ actionConfigTree.setAttribute(property.getName(), property.getValue());
+ }
+ // If the property has child content, add that directy to the action. Of course it only really
// makes sense to do this with one property!
if(propertyElement.hasChildNodes()) {
YADOMUtil.copyChildNodes(propertyElement, actionConfigTree);
- } else {
- actionConfigTree.setAttribute(property.getName(), property.getValue());
}
}
Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/ESBPropertiesUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/ESBPropertiesUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/ESBPropertiesUnitTest.java 2007-07-19 18:59:35 UTC (rev 13642)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.util;
+
+import junit.framework.TestCase;
+
+import java.util.Properties;
+
+import org.jboss.soa.esb.ConfigurationException;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class ESBPropertiesUnitTest extends TestCase {
+
+ public void test() throws ConfigurationException {
+ Properties props = new ESBProperties("testprops.properties");
+
+ assertEquals("xyz", props.getProperty("myprop"));
+ }
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/ESBPropertiesUnitTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/LRUCacheUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/LRUCacheUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/LRUCacheUnitTest.java 2007-07-19 18:59:35 UTC (rev 13642)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.util;
+
+import junit.framework.TestCase;
+
+/**
+ * LRUCache tests.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class LRUCacheUnitTest extends TestCase {
+
+ public void test() {
+ LRUCache<String, String> cache = new LRUCache<String, String>(4);
+
+ cache.put("1", "one");
+ cache.put("2", "two");
+ cache.put("3", "three");
+ cache.put("4", "four");
+
+ cache.put("5", "five"); // should cause "1" to be removed
+ assertEquals(4, cache.size());
+ assertNull(cache.get("1"));
+
+ cache.get("2"); // should cause "2" to become the MRU and "3" to become the LRU
+ cache.put("6", "six"); // should cause "3" to be removed
+ assertEquals(4, cache.size());
+ assertNull(cache.get("3"));
+ }
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/LRUCacheUnitTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/StreamUtilsUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/StreamUtilsUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/StreamUtilsUnitTest.java 2007-07-19 18:59:35 UTC (rev 13642)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.util;
+
+import org.jboss.soa.esb.ConfigurationException;
+
+import java.io.File;
+import java.io.UnsupportedEncodingException;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class StreamUtilsUnitTest extends TestCase {
+
+ private String filename = "rosetta/tests/src/org/jboss/internal/soa/esb/util/testprops.properties";
+ private File file = new File(filename);
+
+ public void test_getResource() throws ConfigurationException {
+
+ if(!file.exists()) {
+ fail("Test fixture error - file " + file.getAbsolutePath() + " not found.");
+ }
+
+ // Test the filesystem based lookup...
+ assertNotNull(StreamUtils.getResource(filename));
+
+ // Test the classpath based lookup...
+ assertNotNull(StreamUtils.getResource("testprops.properties"));
+
+ // Test the URI based lookup...
+ assertNotNull(StreamUtils.getResource(file.toURI().toString()));
+ }
+
+ public void test_getResourceAsString() throws ConfigurationException, UnsupportedEncodingException {
+
+ // No need to test everything - they're tested with the above
+ assertEquals("myprop=xyz", StreamUtils.getResourceAsString(filename, "UTF-8"));
+
+ try {
+ StreamUtils.getResourceAsString("/x/d/f/s.m", "UTF-8");
+ fail("Expected ConfigurationException.");
+ } catch(ConfigurationException e) {
+ assertEquals("Failed to locate resource '/x/d/f/s.m'.", e.getMessage());
+ }
+ }
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/StreamUtilsUnitTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/testprops.properties
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/testprops.properties (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/testprops.properties 2007-07-19 18:59:35 UTC (rev 13642)
@@ -0,0 +1 @@
+myprop=xyz
\ No newline at end of file
Added: labs/jbossesb/trunk/product/samples/quickstarts/webservice_bpel/bpel/localhost-https-18443.properties
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_bpel/bpel/localhost-https-18443.properties (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_bpel/bpel/localhost-https-18443.properties 2007-07-19 18:59:35 UTC (rev 13642)
@@ -0,0 +1,14 @@
+# Configurators
+configurators=HttpProtocol,AuthBASIC
+
+# HttpProtocol config...
+protocol-socket-factory=org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory
+keystore=@CATALINA_HOME@/conf/activebpel.keystore
+keystore-passw=activebpel
+
+# AuthBASIC config...
+auth-username=tomcat
+auth-password=tomcat
+authscope-host=localhost
+authscope-port=18443
+authscope-realm=ActiveBPEL security realm
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/samples/quickstarts/webservice_bpel/bpel/localhost-https-18443.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_bpel/build.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_bpel/build.xml 2007-07-19 18:54:41 UTC (rev 13641)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_bpel/build.xml 2007-07-19 18:59:35 UTC (rev 13642)
@@ -2,7 +2,7 @@
<property environment="env" />
- <property name="additional.deploys" value="smooks-res.xml,jaxb-intros-*.xml" />
+ <property name="additional.deploys" value="smooks-res.xml,jaxb-intros-*.xml,localhost-https-18443.properties" />
<!-- Import the base Ant build script... -->
<import file="../conf/base-build.xml"/>
@@ -106,4 +106,29 @@
</jar>
</target>
+ <target name="config-security" depends="assert-CATALINA_HOME-set, assert-ACTIVEBPEL_ENGINE-installed">
+ <delete file="${env.CATALINA_HOME}/conf/activebpel.keystore" failonerror="false"/>
+ <genkey keystore="${env.CATALINA_HOME}/conf/activebpel.keystore" storepass="activebpel" keypass="activebpel" keyalg="RSA" alias="activebpel">
+ <dname>
+ <param name="CN" value="localhost"/>
+ <param name="OU" value="Acme"/>
+ <param name="O" value="Acme"/>
+ <param name="C" value="IE"/>
+ </dname>
+ </genkey>
+
+ <pathconvert targetos="unix" property="tomcat.dir">
+ <path><pathelement location="${env.CATALINA_HOME}"/></path>
+ </pathconvert>
+ <copy file="bpel/localhost-https-18443.properties" todir="./" overwrite="true">
+ <filterset>
+ <filter token="CATALINA_HOME" value="${tomcat.dir}"/>
+ </filterset>
+ </copy>
+ </target>
+
+ <target name="quickstart-specific-clean">
+ <delete file="localhost-https-18443.properties" failonerror="false" />
+ </target>
+
</project>
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_bpel/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_bpel/jboss-esb.xml 2007-07-19 18:54:41 UTC (rev 13641)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_bpel/jboss-esb.xml 2007-07-19 18:59:35 UTC (rev 13642)
@@ -125,9 +125,9 @@
into the SOAPClient. SOAPClient will use SOAPUI to construct a soap request
template and will then use OGNL to populate the values (from the Smooks
EXTRACTED_BEANS_HASH) into the soap message. -->
- <action name="soapui-client" class="org.jboss.soa.esb.actions.soap.SOAPClient">
+ <action name="SendSalesOrderNotification" class="org.jboss.soa.esb.actions.soap.SOAPClient">
<property name="wsdl" value="http://localhost:18080/active-bpel/services/RetailerCallback?wsdl"/>
- <property name="operation" value="SendSalesOrderNotification"/>
+ <property name="SOAPAction" value="http://org.jboss.esb/quickstarts/bpel/ABI_OrderManager/SendSalesOrderNotification"/>
<property name="paramsLocation" value="EXTRACTED_BEANS_HASH"/>
<property name="responseXStreamConfig">
<alias name="salesOrderNotificationAck" class="java.lang.Boolean" namespace="http://org.jboss.esb/quickstarts/bpel/ABI_OrderManager" />
Modified: labs/jbossesb/trunk/product/services/build.xml
===================================================================
--- labs/jbossesb/trunk/product/services/build.xml 2007-07-19 18:54:41 UTC (rev 13641)
+++ labs/jbossesb/trunk/product/services/build.xml 2007-07-19 18:59:35 UTC (rev 13642)
@@ -7,8 +7,8 @@
<ant dir="jbpm" target="dist"/>
<ant dir="jbrules" target="dist"/>
<ant dir="smooks" target="dist"/>
+ <ant dir="soapui-client" target="sar"/>
<ant dir="soap" target="dist"/>
- <ant dir="soapui-client" target="sar"/>
<ant dir="spring" target="dist"/>
</target>
@@ -17,8 +17,8 @@
<ant dir="jbpm" target="clean"/>
<ant dir="jbrules" target="clean"/>
<ant dir="smooks" target="clean"/>
+ <ant dir="soapui-client" target="clean"/>
<ant dir="soap" target="clean"/>
- <ant dir="soapui-client" target="clean"/>
<ant dir="spring" target="clean"/>
</target>
@@ -27,8 +27,8 @@
<ant dir="jbpm" target="test"/>
<ant dir="jbrules" target="test"/>
<ant dir="smooks" target="test"/>
+ <ant dir="soapui-client" target="test"/>
<ant dir="soap" target="test"/>
- <ant dir="soapui-client" target="test"/>
<ant dir="spring" target="test"/>
</target>
Modified: labs/jbossesb/trunk/product/services/smooks/lib/ext/milyn-smooks-core-0.9-SNAPSHOT.jar
===================================================================
(Binary files differ)
Added: labs/jbossesb/trunk/product/services/soap/lib/ext/commons-ssl-0.3.4.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/trunk/product/services/soap/lib/ext/commons-ssl-0.3.4.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java 2007-07-19 18:54:41 UTC (rev 13641)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java 2007-07-19 18:59:35 UTC (rev 13642)
@@ -1,16 +1,12 @@
package org.jboss.soa.esb.actions.soap;
-import java.io.IOException;
-import java.io.StringReader;
+import java.io.*;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Properties;
+import java.net.URI;
+import java.net.URISyntaxException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -21,12 +17,13 @@
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.log4j.Logger;
import org.jboss.internal.soa.esb.soap.OGNLUtils;
-import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.internal.soa.esb.util.StreamUtils;
import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.http.HttpClientFactory;
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.actions.ActionUtils;
+import org.jboss.soa.esb.actions.ActionLifecycleException;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.util.ClassUtil;
@@ -211,48 +208,75 @@
private Logger logger = Logger.getLogger(SOAPClient.class);
private String wsdl;
- private String operation;
+ private String soapAction;
private String paramsLocation;
private String responseLocation;
private boolean responseAsOgnlMap;
- private MBeanServer mbeanServer;
- private ObjectName serviceName;
- private String[] buildRequestSig = new String[] {String.class.getName(), String.class.getName(), Map.class.getName()};
- private String[] getEndpointSig = new String[] {String.class.getName()};
+ private String smooksTransform;
+ private SoapUIInvoker soapUIInvoker;
private static DocumentBuilderFactory docBuilderFactory = createDocumentBuilderFactory();
private XStream responseXStreamDeserialzer;
private QNameMap responseXStreamQNameMap = new QNameMap();
+ private Properties httpClientProps = new Properties();
+ private HttpClient httpclient;
public SOAPClient(ConfigTree config) throws ConfigurationException {
wsdl = config.getRequiredAttribute("wsdl");
- operation = config.getRequiredAttribute("operation");
+ soapAction = config.getRequiredAttribute("SOAPAction");
paramsLocation = config.getAttribute("paramsLocation");
responseLocation = config.getAttribute("responseLocation");
responseAsOgnlMap = "true".equalsIgnoreCase(config.getAttribute("responseAsOgnlMap"));
+ smooksTransform = config.getAttribute("smooksTransform");
+ if(smooksTransform != null) {
+ try {
+ smooksTransform = StreamUtils.getResourceAsString(smooksTransform, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ logger.error("Unable to read Smooks resource '" + smooksTransform + "'. Must be UTF-8 encoded.");
+ }
+ }
ConfigTree[] xstreamAliases = config.getChildren("alias");
if(xstreamAliases != null && xstreamAliases.length != 0) {
configureXStreamDeserializer(xstreamAliases);
}
- try {
- serviceName = new ObjectName("jboss.esb:service=SoapUIClientService");
- } catch (MalformedObjectNameException e) {
- throw new IllegalStateException("Unexpected exception.", e);
- }
+ // Extract the HttpClient creation properties from the ConfigTree. Thesee are passed
+ // to the HttpClientFacatory...
+ extractHttpClientProps(config);
+ httpclient = HttpClientFactory.createHttpClient(httpClientProps);
}
+
public void initialise() throws ActionLifecycleException {
super.initialise();
- mbeanServer = MBeanServerLocator.locate();
+ // Create the SoapUIInvoker instance for this SOAPClient...
+ soapUIInvoker = new SoapUIInvoker();
}
+ private void extractHttpClientProps(ConfigTree config) {
+ ConfigTree[] httpClientConfigTrees = config.getChildren("http-client-property");
+
+ httpClientProps.setProperty(HttpClientFactory.TARGET_HOST_URL, wsdl);
+
+ // The HttpClient properties are attached under the factory class/impl property as <http-client-property name="x" value="y" /> nodes
+ for(ConfigTree httpClientProp : httpClientConfigTrees) {
+ String propName = httpClientProp.getAttribute("name");
+ String propValue = httpClientProp.getAttribute("value");
+
+ if(propName != null && propValue != null) {
+ httpClientProps.setProperty(propName, propValue);
+ }
+ }
+ }
+
public Message process(final Message message) throws ActionProcessingException {
- Map params;
+ Map params = null;
if(paramsLocation != null) {
params = (Map) message.getBody().get(paramsLocation);
} else {
- params = (Map) message.getBody().get();
+ try {
+ params = (Map) message.getBody().get();
+ } catch(ClassCastException e) {/* ignore */}
if(params == null) {
params = (Map) ActionUtils.getTaskObject(message);
}
@@ -263,7 +287,14 @@
logger.warn("Params Map found in message, but the map is empty.");
}
- String request = buildRequestMessage(params);
+ String request;
+ try {
+ request = soapUIInvoker.buildRequest(wsdl, getEndpointOperation(), params, httpClientProps, smooksTransform);
+ } catch (IOException e) {
+ throw new ActionProcessingException("soapUI Client Service invocation failed.", e);
+ } catch (SAXException e) {
+ throw new ActionProcessingException("soapUI Client Service invocation failed.", e);
+ }
String response = invokeEndpoint(request);
// And process the response into the message...
@@ -272,37 +303,29 @@
return message;
}
- private String buildRequestMessage(Map params) throws ActionProcessingException {
+ protected String getEndpointOperation() {
+ URI soapActionURI;
+
try {
- return (String) mbeanServer.invoke(serviceName, "buildRequest", new Object[] {wsdl, operation, params}, buildRequestSig);
- } catch (InstanceNotFoundException e) {
- throw new ActionProcessingException("SOAP UI Client Service not found under name '" + serviceName.getCanonicalName() + "'. This service must be deployed before this action can be used.", e);
- } catch (MBeanException e) {
- throw new ActionProcessingException(e);
- } catch (ReflectionException e) {
- throw new ActionProcessingException(e);
+ soapActionURI = new URI(soapAction);
+ return new File(soapActionURI.getPath()).getName();
+ } catch (URISyntaxException e) {
+ return soapAction;
}
}
- private String getEndpoint() throws ActionProcessingException {
+ protected String invokeEndpoint(String request) throws ActionProcessingException {
+ String endpoint;
try {
- return (String) mbeanServer.invoke(serviceName, "getEndpoint", new Object[] {wsdl}, getEndpointSig);
- } catch (InstanceNotFoundException e) {
- throw new ActionProcessingException("SOAP UI Client Service not found under name '" + serviceName.getCanonicalName() + "'. This service must be deployed before this action can be used.", e);
- } catch (MBeanException e) {
- throw new ActionProcessingException(e);
- } catch (ReflectionException e) {
- throw new ActionProcessingException(e);
+ endpoint = soapUIInvoker.getEndpoint(wsdl, httpClientProps);
+ } catch (IOException e) {
+ throw new ActionProcessingException("soapUI Client Service invocation failed.", e);
}
- }
-
- protected String invokeEndpoint(String request) throws ActionProcessingException {
- String endpoint = getEndpoint();
PostMethod post = new PostMethod(endpoint);
- post.setRequestHeader("SOAPAction", operation);
+ post.setRequestHeader("Content-Type", "text/xml;charset=UTF-8");
+ post.setRequestHeader("SOAPAction", soapAction);
post.setRequestBody(request);
- HttpClient httpclient = new HttpClient();
try {
int result = httpclient.executeMethod(post);
if(result != HttpStatus.SC_OK) {
@@ -311,7 +334,7 @@
}
return post.getResponseBodyAsString();
} catch (IOException e) {
- throw new ActionProcessingException("Failed to invoke SOAP Endpoint: '" + getEndpoint() + " ' - '" + operation + "'.", e);
+ throw new ActionProcessingException("Failed to invoke SOAP Endpoint: '" + endpoint + " ' - '" + soapAction + "'.", e);
} finally {
post.releaseConnection();
}
Added: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SoapUIInvoker.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SoapUIInvoker.java (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SoapUIInvoker.java 2007-07-19 18:59:35 UTC (rev 13642)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.soap;
+
+import org.jboss.mx.util.MBeanServerLocator;
+import org.xml.sax.SAXException;
+
+import javax.management.*;
+import java.util.Map;
+import java.util.Properties;
+import java.io.IOException;
+
+/**
+ * Invoker the soapui-client Service.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class SoapUIInvoker {
+
+ private static final String[] buildRequestSig = new String[] {String.class.getName(), String.class.getName(), Map.class.getName(), Properties.class.getName(), String.class.getName()};
+ private static final String[] getEndpointSig = new String[] {String.class.getName(), Properties.class.getName()};
+ private MBeanServer mbeanServer;
+ private ObjectName serviceName;
+
+ public SoapUIInvoker() {
+ // Lookup the MBean ObjectName for the soapUI service (in soapui-client.sar)...
+ try {
+ mbeanServer = MBeanServerLocator.locate();
+ serviceName = new ObjectName("jboss.esb:service=SoapUIClientService");
+ } catch (MalformedObjectNameException e) {
+ throw new IllegalStateException("Unexpected exception.", e);
+ }
+ }
+
+ /**
+ * Build a SOAP request for the specified operation on the specified WSDL.
+ *
+ * @param wsdl WSDL URL.
+ * @param operation Operation name.
+ * @param params Message parameter map.
+ * @param httpClientProps {@link org.apache.commons.httpclient.HttpClient} creation properties.
+ * @param smooksResource {@link org.milyn.Smooks} transformation configuration resource file.
+ * Null if no transformations are to be performed on the SOAP message before serializing it
+ * for return.
+ * @return The SOAP Message.
+ * @throws java.io.IOException Failed to load WSDL.
+ * @throws UnsupportedOperationException Operation not supported on specified WSDL.
+ * @throws org.xml.sax.SAXException Failed to parse the SOAP UI generated request message.
+ */
+ public String buildRequest(String wsdl, String operation, Map params, Properties httpClientProps, String smooksResource) throws IOException, UnsupportedOperationException, SAXException {
+ try {
+ return (String) mbeanServer.invoke(serviceName, "buildRequest", new Object[] {wsdl, operation, params, httpClientProps, smooksResource}, buildRequestSig);
+ } catch (InstanceNotFoundException e) {
+ throw new UnsupportedOperationException("SOAP UI Client Service not found under name '" + serviceName.getCanonicalName() + "'. This service must be deployed before this action can be used.", e);
+ } catch (MBeanException e) {
+ rethrowException(e);
+ } catch (ReflectionException e) {
+ rethrowException(e);
+ }
+
+ throw new RuntimeException("Unexpected code exit point reached!");
+ }
+
+ /**
+ * Get the 1st endpoint from the specified WSDL.
+ *
+ * @param wsdl WSDL URL.
+ * @param httpClientProps {@link org.apache.commons.httpclient.HttpClient} creation properties.
+ * @return The operation endpoint URL.
+ * @throws IOException Failed to load WSDL.
+ */
+ public String getEndpoint(String wsdl, Properties httpClientProps) throws IOException {
+ try {
+ return (String) mbeanServer.invoke(serviceName, "getEndpoint", new Object[] {wsdl, httpClientProps}, getEndpointSig);
+ } catch (InstanceNotFoundException e) {
+ throw new UnsupportedOperationException("SOAP UI Client Service not found under name '" + serviceName.getCanonicalName() + "'. This service must be deployed before this action can be used.", e);
+ } catch (MBeanException e) {
+ if(e.getCause() instanceof IOException) {
+ throw (IOException)e.getCause();
+ }
+ throw new RuntimeException(e);
+ } catch (ReflectionException e) {
+ if(e.getCause() instanceof IOException) {
+ throw (IOException)e.getCause();
+ }
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void rethrowException(Throwable e) throws IOException, UnsupportedOperationException, SAXException {
+ Throwable cause = e.getCause();
+
+ if(cause instanceof IOException) {
+ throw (IOException)cause;
+ } else if(cause instanceof UnsupportedOperationException) {
+ throw (UnsupportedOperationException)cause;
+ } else if(cause instanceof SAXException) {
+ throw (SAXException)cause;
+ } else {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
Property changes on: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SoapUIInvoker.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPClientUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPClientUnitTest.java 2007-07-19 18:54:41 UTC (rev 13641)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPClientUnitTest.java 2007-07-19 18:59:35 UTC (rev 13642)
@@ -56,7 +56,6 @@
soapClient.processResponse(message, responseString);
Order order = (Order) message.getBody().get();
//assertEquals();
- System.out.println("sss " + order);
}
@SuppressWarnings("unchecked")
@@ -90,6 +89,13 @@
assertEquals(response_01, message.getBody().get("myTestLocation"));
}
+ public void test_getEndpointOperation() throws ConfigurationException, ActionProcessingException {
+ ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-07");
+ SOAPClient soapClient = new SOAPClient(actionConfig);
+ assertEquals("SendSalesOrderNotification", soapClient.getEndpointOperation());
+ }
+
+
private static String response_01 =
"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
"\t<soapenv:Header/>\n" +
Modified: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/soapclient-config-01.xml
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/soapclient-config-01.xml 2007-07-19 18:54:41 UTC (rev 13641)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/soapclient-config-01.xml 2007-07-19 18:59:35 UTC (rev 13642)
@@ -24,28 +24,28 @@
<actions>
<action name="soapui-client-action-01" class="org.jboss.soa.esb.actions.soap.SOAPClient">
<property name="wsdl" value="http://localhost:18080/active-bpel/services/RetailerCallback?wsdl"/>
- <property name="operation" value="ZZZ"/>
+ <property name="SOAPAction" value="ZZZ"/>
<property name="responseXStreamConfig">
<alias name="customerOrderAck" class="java.lang.Boolean" namespace="http://schemas.active-endpoints.com/sample/customerorder/2006/04/CustomerOrder.xsd" />
</property>
</action>
<action name="soapui-client-action-02" class="org.jboss.soa.esb.actions.soap.SOAPClient">
<property name="wsdl" value="http://localhost:18080/active-bpel/services/RetailerCallback?wsdl"/>
- <property name="operation" value="ZZZ"/>
+ <property name="SOAPAction" value="ZZZ"/>
<property name="responseAsOgnlMap" value="true" />
</action>
<action name="soapui-client-action-03" class="org.jboss.soa.esb.actions.soap.SOAPClient">
<property name="wsdl" value="http://localhost:18080/active-bpel/services/RetailerCallback?wsdl"/>
- <property name="operation" value="ZZZ"/>
+ <property name="SOAPAction" value="ZZZ"/>
</action>
<action name="soapui-client-action-04" class="org.jboss.soa.esb.actions.soap.SOAPClient">
<property name="wsdl" value="http://localhost:18080/active-bpel/services/RetailerCallback?wsdl"/>
- <property name="operation" value="ZZZ"/>
+ <property name="SOAPAction" value="ZZZ"/>
<property name="responseLocation" value="myTestLocation"/>
</action>
<action name="soapui-client-action-05" class="org.jboss.soa.esb.actions.soap.SOAPClient">
<property name="wsdl" value="http://localhost:18080/active-bpel/services/RetailerCallback?wsdl"/>
- <property name="operation" value="ZZZ"/>
+ <property name="SOAPAction" value="ZZZ"/>
<property name="responseXStreamConfig">
<alias name="customerOrder" class="org.jboss.soa.esb.actions.soap.beans.Order" namespace="http://schemas.active-endpoints.com/sample/customerorder/2006/04/CustomerOrder.xsd" />
<alias name="customerName" class="java.lang.String" namespace="http://schemas.active-endpoints.com/sample/customerorder/2006/04/CustomerOrder.xsd" />
@@ -53,6 +53,14 @@
<alias name="item" class="org.jboss.soa.esb.actions.soap.beans.OrderItem" namespace="http://schemas.active-endpoints.com/sample/customerorder/2006/04/CustomerOrder.xsd" />
</property>
</action>
+ <action name="soapui-client-action-06" class="org.jboss.soa.esb.actions.soap.SOAPClient">
+ <property name="wsdl" value="http://localhost:18080/active-bpel/services/RetailerCallback?wsdl"/>
+ <property name="SOAPAction" value="http://org.jboss.esb/quickstarts/bpel/ABI_OrderManager/SendSalesOrderNotification"/>
+ </action>
+ <action name="soapui-client-action-07" class="org.jboss.soa.esb.actions.soap.SOAPClient">
+ <property name="wsdl" value="http://localhost:18080/active-bpel/services/RetailerCallback?wsdl"/>
+ <property name="SOAPAction" value="http://org.jboss.esb/quickstarts/bpel/ABI_OrderManager/SendSalesOrderNotification/"/>
+ </action>
</actions>
</service>
Modified: labs/jbossesb/trunk/product/services/soapui-client/build.xml
===================================================================
--- labs/jbossesb/trunk/product/services/soapui-client/build.xml 2007-07-19 18:54:41 UTC (rev 13641)
+++ labs/jbossesb/trunk/product/services/soapui-client/build.xml 2007-07-19 18:59:35 UTC (rev 13642)
@@ -9,13 +9,16 @@
<property name="maven.test.reports" value="${maven.build.directory}/test-reports"/>
<property name="maven.test.output" value="target/test-classes"/>
- <fileset id="jboss-esb-dependencies" dir="../../build/jbossesb/lib" includes="jbossesb-rosetta.jar" />
+ <path id="jboss-esb-dependencies">
+ <fileset dir="../../build/jbossesb/lib" includes="jbossesb-rosetta.jar" />
+ <fileset dir="../../build/jbossesb/lib/smooks.esb" includes="*.jar" />
+ </path>
<path id="build.classpath">
<path location="${basedir}/src/test/resources"/>
<fileset dir="src/lib" includes="*.jar" />
<fileset dir="../../lib/ext" includes="*.jar" />
- <fileset refid="jboss-esb-dependencies" />
+ <path refid="jboss-esb-dependencies" />
</path>
@@ -45,20 +48,20 @@
excludes="**/package.html"/>
</target>
<target name="sar" depends="clean,jar" description="SAR">
- <delete dir="${maven.build.directory}/sar" />
- <mkdir dir="${maven.build.directory}/sar" />
- <copy todir="${maven.build.directory}/sar">
+ <property name="sar.dir" location="../../build/jbossesb/lib/${ant.project.name}.sar" />
+
+ <delete dir="${sar.dir}" />
+ <mkdir dir="${sar.dir}" />
+ <copy todir="${sar.dir}">
<fileset dir="src" includes="lib/*.jar" excludes="lib/jboss-*.jar" />
<fileset dir="src/main/resources" />
- <fileset refid="jboss-esb-dependencies" />
+ <fileset dir="../../build/jbossesb/lib" includes="jbossesb-rosetta.jar" />
+ <fileset dir="../../build/jbossesb/lib/smooks.esb" includes="milyn-*.jar" />
</copy>
- <copy todir="${maven.build.directory}/sar">
+ <copy todir="${sar.dir}">
<!-- fileset dir="${maven.build.directory}" includes="${maven.build.final.name}.jar" / -->
<fileset dir="${maven.build.directory}/classes" />
</copy>
-
- <jar jarfile="${maven.build.directory}/${maven.build.final.name}.sar" basedir="${maven.build.directory}/sar" />
- <copy file="${maven.build.directory}/${maven.build.final.name}.sar" todir="../../build/jbossesb/lib" />
</target>
<target name="compile-tests" depends="junit-present, compile" description="Compile the test code"
if="junit.present">
@@ -84,7 +87,7 @@
</target>
<target name="test" depends="junit-present, compile-tests" if="junit.present" description="Run the test cases">
<mkdir dir="${maven.test.reports}"/>
- <junit printSummary="yes" haltonerror="true" haltonfailure="true" fork="true" dir=".">
+ <junit printSummary="yes" haltonerror="true" showoutput="true" haltonfailure="true" fork="true" dir=".">
<sysproperty key="basedir" value="."/>
<sysproperty key="java.awt.headless" value="true"/>
<sysproperty key="log4j.configuration" value="log4j.xml"/>
Added: labs/jbossesb/trunk/product/services/soapui-client/src/lib/commons-ssl-0.3.4.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/trunk/product/services/soapui-client/src/lib/commons-ssl-0.3.4.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: labs/jbossesb/trunk/product/services/soapui-client/src/lib/milyn-commons-0.9-SNAPSHOT.jar
===================================================================
(Binary files differ)
Added: labs/jbossesb/trunk/product/services/soapui-client/src/lib/soapui-1.7.1.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/trunk/product/services/soapui-client/src/lib/soapui-1.7.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: labs/jbossesb/trunk/product/services/soapui-client/src/lib/soapui-1.7.jar
===================================================================
(Binary files differ)
Added: labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/EsbWsdlLoader.java
===================================================================
--- labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/EsbWsdlLoader.java (rev 0)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/EsbWsdlLoader.java 2007-07-19 18:59:35 UTC (rev 13642)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.services.soapui;
+
+import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlLoader;
+
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+import java.net.URI;
+import java.net.URL;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.log4j.Logger;
+
+/**
+ * {@link WsdlLoader} implementation that gets injected into soapUI.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+class EsbWsdlLoader extends WsdlLoader {
+
+ private static Logger logger = Logger.getLogger(EsbWsdlLoader.class);
+
+ private boolean isAborted = false;
+ private HttpClient httpClient;
+
+ public EsbWsdlLoader(String url, HttpClient httpClient) {
+ super(url);
+ this.httpClient = httpClient;
+ }
+
+ public InputStream load(String url) throws Exception {
+ GetMethod httpGetMethod;
+
+ if(url.startsWith("file")) {
+ return new URL(url) .openStream();
+ }
+
+ // 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);
+
+ try {
+ int result = httpClient.executeMethod(httpGetMethod);
+
+ if(result != HttpStatus.SC_OK) {
+ if(result < 200 || result > 299) {
+ throw new HttpException("Received status code '" + result + "' on WSDL HTTP (GET) request: '" + url + "'.");
+ } else {
+ logger.warn("Received status code '" + result + "' on WSDL HTTP (GET) request: '" + url + "'.");
+ }
+ }
+
+ return new ByteArrayInputStream(httpGetMethod.getResponseBody());
+ } finally {
+ httpGetMethod.releaseConnection();
+ }
+ }
+
+ public boolean abort() {
+ isAborted = true;
+ return true;
+ }
+
+ public boolean isAborted() {
+ return isAborted;
+ }
+
+ public void close() {
+
+ }
+}
Property changes on: labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/EsbWsdlLoader.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientService.java
===================================================================
--- labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientService.java 2007-07-19 18:54:41 UTC (rev 13641)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientService.java 2007-07-19 18:59:35 UTC (rev 13642)
@@ -21,20 +21,27 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.dom.DOMResult;
import org.apache.log4j.Logger;
+import org.apache.commons.httpclient.HttpClient;
import org.jboss.internal.soa.esb.soap.OGNLUtils;
+import org.jboss.internal.soa.esb.util.LRUCache;
+import org.jboss.internal.soa.esb.util.ESBProperties;
import org.jboss.soa.esb.dom.YADOMUtil;
+import org.jboss.soa.esb.http.HttpClientFactory;
+import org.jboss.soa.esb.ConfigurationException;
import org.jboss.system.ServiceMBeanSupport;
import org.milyn.xml.XmlUtil;
+import org.milyn.Smooks;
+import org.milyn.SmooksUtil;
+import org.milyn.resource.URIResourceLocator;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -43,6 +50,7 @@
import com.eviware.soapui.impl.wsdl.WsdlInterface;
import com.eviware.soapui.impl.wsdl.WsdlProject;
+import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlLoader;
import com.eviware.soapui.model.iface.Operation;
/**
@@ -56,11 +64,15 @@
private static Logger logger = Logger.getLogger(SoapUIClientService.class);
private Map<String, WsdlInterface[]> wsdls = new HashMap<String, WsdlInterface[]>();
private DocumentBuilder docBuilder;
+ private Map<String, Smooks> smooksCache;
+ private ESBProperties properties;
/**
* Public default constructor.
*/
- public SoapUIClientService() {
+ public SoapUIClientService() throws ConfigurationException {
+ properties = new ESBProperties("/soapui-client.sar.properties");
+
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setNamespaceAware(true);
try {
@@ -68,43 +80,51 @@
} catch (ParserConfigurationException e) {
throw new RuntimeException("Failed to construct DocumentBuilder instance.", e);
}
+ int smooksLRUCacheSize = properties.getIntProperty("smooks.lru.cache.size", 30);
+ smooksCache = new LRUCache<String, Smooks>(smooksLRUCacheSize);
}
/**
* Build a SOAP request for the specified operation on the specified WSDL.
*
- * @param wsdl WSDL URL.
- * @param operation Operation name.
- * @param params Message parameter map.
+ * @param wsdl WSDL URL.
+ * @param operation Operation name.
+ * @param params Message parameter map.
+ * @param httpClientProps {@link org.apache.commons.httpclient.HttpClient} creation properties.
+ * @param smooksResource {@link org.milyn.Smooks} transformation configuration resource. This is the actual
+ * Smooks resource configuration XML, not a file name.
+ * Null if no transformations are to be performed on the SOAP message before serializing it
+ * for return.
* @return The SOAP Message.
* @throws IOException Failed to load WSDL.
*/
- public String buildRequest(String wsdl, String operation, Map params) throws IOException, UnsupportedOperationException, SAXException {
- Operation operationInst = getOperation(wsdl, operation);
+ public String buildRequest(String wsdl, String operation, Map params, Properties httpClientProps, String smooksResource) throws IOException, UnsupportedOperationException, SAXException {
+ Operation operationInst = getOperation(wsdl, operation, httpClientProps);
String requestTemplate = operationInst.getRequestAt(0).getRequestContent();
- return injectParameters(requestTemplate, params);
+ return buildRequest(requestTemplate, params, smooksResource);
}
/**
* Get the 1st endpoint from the specified WSDL.
*
- * @param wsdl WSDL URL.
+ * @param wsdl WSDL URL.
+ * @param httpClientProps {@link org.apache.commons.httpclient.HttpClient} creation properties.
* @return The operation endpoint URL.
* @throws IOException Failed to load WSDL.
*/
- public String getEndpoint(String wsdl) throws IOException {
- WsdlInterface[] wsdlInterfaces = getWsdlInterfaces(wsdl);
+ public String getEndpoint(String wsdl, Properties httpClientProps) throws IOException {
+ WsdlInterface[] wsdlInterfaces = getWsdlInterfaces(wsdl, httpClientProps);
return wsdlInterfaces[0].getEndpoints()[0];
}
- private WsdlInterface[] getWsdlInterfaces(String wsdl) throws IOException {
+ private WsdlInterface[] getWsdlInterfaces(String wsdl, Properties httpClientProps) throws IOException {
try {
WsdlInterface[] wsdlInterfaces = wsdls.get(wsdl);
if (wsdlInterfaces == null) {
WsdlProject wsdlProject = new WsdlProject();
- wsdlInterfaces = wsdlProject.importWsdl(wsdl, true);
+ wsdlInterfaces = wsdlProject.importWsdl(wsdl, true, createWsdlLoader(wsdl, httpClientProps));
wsdls.put(wsdl, wsdlInterfaces);
}
return wsdlInterfaces;
@@ -115,8 +135,8 @@
}
}
- private Operation getOperation(String wsdl, String operation) throws IOException, UnsupportedOperationException {
- WsdlInterface[] wsdlInterfaces = getWsdlInterfaces(wsdl);
+ private Operation getOperation(String wsdl, String operation, Properties httpClientProps) throws IOException, UnsupportedOperationException {
+ WsdlInterface[] wsdlInterfaces = getWsdlInterfaces(wsdl, httpClientProps);
for (WsdlInterface wsdlInterface : wsdlInterfaces) {
Operation operationInst = wsdlInterface.getOperationByName(operation);
@@ -128,47 +148,70 @@
throw new UnsupportedOperationException("Operation '" + operation + "' not supported by WSDL '" + wsdl + "'.");
}
- private String injectParameters(String soapMessage, Map params) throws IOException, SAXException {
+ private WsdlLoader createWsdlLoader(String wsdl, Properties httpClientProps) throws ConfigurationException {
+ HttpClient httpClient = HttpClientFactory.createHttpClient(httpClientProps);
+
+ return new EsbWsdlLoader(wsdl, httpClient);
+ }
+
+ private String buildRequest(String soapMessage, Map params, String smooksResource) throws IOException, SAXException {
Document messageDoc = docBuilder.parse(new ByteArrayInputStream(soapMessage.getBytes()));
Element docRoot = messageDoc.getDocumentElement();
expandMessage(docRoot, params);
injectParameters(docRoot, params);
+ if(smooksResource != null) {
+ applySmooksTransform(smooksResource, messageDoc);
+ }
return XmlUtil.serialize(messageDoc.getChildNodes());
}
+ private void applySmooksTransform(String smooksResource, Document messageDoc) throws IOException, SAXException {
+ if(smooksResource != null) {
+ Smooks smooks = smooksCache.get(smooksResource);
+
+ if(smooks == null) {
+ smooks = new Smooks(new ByteArrayInputStream(smooksResource.getBytes("UTF-8")));
+ SmooksUtil.registerResources("cdu-creators", new URIResourceLocator().getResource("/META-INF/smooks-creators.xml"), smooks);
+ smooksCache.put(smooksResource, smooks);
+ }
+
+ smooks.filter(new DOMSource(messageDoc), new DOMResult(), smooks.createExecutionContext());
+ }
+ }
+
/**
* Expand the message to accommodate data collections.
* <p/>
* It basically just clones the message where appropriate.
*
* @param element The element to be processed.
- * @param params The message params. Uses the message params to
- * decide whether or not cloning is required.
+ * @param params The message params. Uses the message params to
+ * decide whether or not cloning is required.
*/
private void expandMessage(Element element, Map params) {
// If this element is not a cloned element, check does it need to be cloned...
- if(!element.hasAttributeNS(OGNLUtils.JBOSSESB_SOAP_NS, IS_CLONE_ATTRIB)) {
+ if (!element.hasAttributeNS(OGNLUtils.JBOSSESB_SOAP_NS, IS_CLONE_ATTRIB)) {
String ognl = OGNLUtils.getOGNLExpression(element);
Object param;
param = OGNLUtils.getParameter(ognl, params);
- if(param != null) {
+ if (param != null) {
Class paramRuntime = param.getClass();
- if(paramRuntime.isArray()) {
+ if (paramRuntime.isArray()) {
Element item = getCollectionItemElement(element);
// It's an "array" containing node. Grab the first/only
// Element in it and clone it the required number of times.
- cloneCollectionTemplateElement(item, ((Object[])param).length - 1, ognl);
- } else if(Collection.class.isAssignableFrom(paramRuntime)) {
+ cloneCollectionTemplateElement(item, ((Object[]) param).length - 1, ognl);
+ } else if (Collection.class.isAssignableFrom(paramRuntime)) {
Element item = getCollectionItemElement(element);
// It's a "collection" containing node. Grab the first/only
// Element in it and clone it the required number of times.
- cloneCollectionTemplateElement(item, ((Collection)param).size() - 1, ognl);
+ cloneCollectionTemplateElement(item, ((Collection) param).size() - 1, ognl);
}
}
}
@@ -187,15 +230,15 @@
Element firstElement = null;
// Basicall, find the first Element child...
- if(firstNode != null) {
- if(firstNode.getNodeType() == Node.ELEMENT_NODE) {
- firstElement = (Element)firstNode;
+ if (firstNode != null) {
+ if (firstNode.getNodeType() == Node.ELEMENT_NODE) {
+ firstElement = (Element) firstNode;
} else {
firstElement = YADOMUtil.getNextSiblingElement(firstNode);
}
}
- if(firstElement == null) {
+ if (firstElement == null) {
logger.warn("Message template not in sync with parameter map. Map contains a collection at a point at which the WSDL doesn't support this collection. Element: " + element.getLocalName());
}
@@ -209,14 +252,14 @@
* collection entry is represented by [0], [1] etc in the OGNL expression, not the actual
* element name on the DOM e.g. collection node "order/items/item" (where "item" is the
* actual collection entry) maps to the OGNL expression "order.items[0]" etc.
- *
- * @param element The collection/array "entry" sub-branch.
+ *
+ * @param element The collection/array "entry" sub-branch.
* @param cloneCount The number of times it needs to be cloned.
- * @param ognl The OGNL expression for the collection/array. Not including the
- * indexing part.
+ * @param ognl The OGNL expression for the collection/array. Not including the
+ * indexing part.
*/
private void cloneCollectionTemplateElement(Element element, int cloneCount, String ognl) {
- if(element == null) {
+ if (element == null) {
return;
}
@@ -224,12 +267,12 @@
Node parent = element.getParentNode();
element.setAttributeNS(OGNLUtils.JBOSSESB_SOAP_NS, OGNLUtils.JBOSSESB_SOAP_NS_PREFIX + OGNLUtils.OGNL_ATTRIB, ognl + "[0]");
- for(int i = 0; i < cloneCount; i++) {
+ for (int i = 0; i < cloneCount; i++) {
Element clone = (Element) element.cloneNode(true);
clone.setAttributeNS(OGNLUtils.JBOSSESB_SOAP_NS, OGNLUtils.JBOSSESB_SOAP_NS_PREFIX + IS_CLONE_ATTRIB, "true");
clone.setAttributeNS(OGNLUtils.JBOSSESB_SOAP_NS, OGNLUtils.JBOSSESB_SOAP_NS_PREFIX + OGNLUtils.OGNL_ATTRIB, ognl + "[" + Integer.toString(i + 1) + "]");
- if(nextSibling == null) {
+ if (nextSibling == null) {
parent.appendChild(clone);
} else {
parent.insertBefore(clone, nextSibling);
Modified: labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBean.java
===================================================================
--- labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBean.java 2007-07-19 18:54:41 UTC (rev 13641)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBean.java 2007-07-19 18:59:35 UTC (rev 13642)
@@ -21,6 +21,7 @@
import java.io.IOException;
import java.util.Map;
+import java.util.Properties;
import org.jboss.system.ServiceMBean;
import org.xml.sax.SAXException;
@@ -31,7 +32,6 @@
* Embeds the <a href="http://www.soapui.org/">soapui</a> tool, using it to generate
* a valid soap requests, as well as unmarshal response data from a valid soap response.
*
- *
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
*/
public interface SoapUIClientServiceMBean extends ServiceMBean {
@@ -39,22 +39,27 @@
/**
* Build a SOAP request for the specified operation on the specified WSDL.
*
- * @param wsdl WSDL URL.
- * @param operation Operation name.
- * @param params Message parameter map.
+ * @param wsdl WSDL URL.
+ * @param operation Operation name.
+ * @param params Message parameter map.
+ * @param httpClientProps {@link org.apache.commons.httpclient.HttpClient} creation properties.
+ * @param smooksResource {@link org.milyn.Smooks} transformation configuration resource file.
+ * Null if no transformations are to be performed on the SOAP message before serializing it
+ * for return.
* @return The SOAP Message.
- * @throws IOException Failed to load WSDL.
+ * @throws IOException Failed to load WSDL.
* @throws UnsupportedOperationException Operation not supported on specified WSDL.
- * @throws SAXException Failed to parse the SOAP UI generated request message.
+ * @throws SAXException Failed to parse the SOAP UI generated request message.
*/
- public abstract String buildRequest(String wsdl, String operation, Map params) throws IOException, UnsupportedOperationException, SAXException;
+ public abstract String buildRequest(String wsdl, String operation, Map params, Properties httpClientProps, String smooksResource) throws IOException, UnsupportedOperationException, SAXException;
/**
* Get the 1st endpoint from the specified WSDL.
*
- * @param wsdl WSDL URL.
+ * @param wsdl WSDL URL.
+ * @param httpClientProps {@link org.apache.commons.httpclient.HttpClient} creation properties.
* @return The operation endpoint URL.
* @throws IOException Failed to load WSDL.
*/
- public abstract String getEndpoint(String wsdl) throws IOException;
+ public abstract String getEndpoint(String wsdl, Properties httpClientProps) throws IOException;
}
Added: labs/jbossesb/trunk/product/services/soapui-client/src/main/resources/META-INF/smooks-creators.xml
===================================================================
--- labs/jbossesb/trunk/product/services/soapui-client/src/main/resources/META-INF/smooks-creators.xml (rev 0)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/main/resources/META-INF/smooks-creators.xml 2007-07-19 18:59:35 UTC (rev 13642)
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd" default-selector="cdu-creator">
+
+ <!--
+ All .st (*.st) resources will be treated as StringTemplate templates and
+ will be handled by the StringTemplateContentDeliveryUnitCreator.
+ -->
+ <resource-config>
+ <resource type="class">org.milyn.templating.stringtemplate.StringTemplateContentDeliveryUnitCreator</resource>
+ <param name="restype">st</param>
+ </resource-config>
+
+ <!--
+ All .xsl (*.xsl) resources will be treated as XSL templates and
+ will be handled by the XslContentDeliveryUnitCreator.
+ -->
+ <resource-config>
+ <resource type="class">org.milyn.templating.xslt.XslContentDeliveryUnitCreator</resource>
+ <param name="restype">xsl</param>
+ </resource-config>
+
+ <!--
+ Groovy Scripting Support.
+ -->
+ <resource-config>
+ <resource type="class">org.milyn.smooks.scripting.GroovyContentDeliveryUnitCreator</resource>
+ <param name="restype">groovy</param>
+ </resource-config>
+
+</smooks-resource-list>
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/services/soapui-client/src/main/resources/META-INF/smooks-creators.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/services/soapui-client/src/main/resources/soapui-client.sar.properties
===================================================================
--- labs/jbossesb/trunk/product/services/soapui-client/src/main/resources/soapui-client.sar.properties (rev 0)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/main/resources/soapui-client.sar.properties 2007-07-19 18:59:35 UTC (rev 13642)
@@ -0,0 +1,4 @@
+#####################################################################################
+# Smooks instances are cached in an LRU cache.
+#####################################################################################
+smooks.lru.cache.size=30
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/services/soapui-client/src/main/resources/soapui-client.sar.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBeanUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBeanUnitTest.java 2007-07-19 18:54:41 UTC (rev 13641)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBeanUnitTest.java 2007-07-19 18:59:35 UTC (rev 13642)
@@ -27,17 +27,16 @@
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import javax.xml.transform.stream.StreamResult;
import junit.framework.TestCase;
import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.http.HttpClientFactory;
import org.jboss.soa.esb.dom.YADOMUtil;
+import org.jboss.internal.soa.esb.util.StreamUtils;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
@@ -47,19 +46,25 @@
public class SoapUIClientServiceMBeanUnitTest extends TestCase {
private static final String WSDL_LOCATAION = "src/test/java/org/jboss/soa/esb/services/soapui";
+ private Properties properties;
- public void test_no_collections() throws IOException, SAXException {
+ protected void setUp() throws Exception {
+ properties = new Properties();
+ }
+
+ public void test_no_collections() throws IOException, SAXException, ConfigurationException {
File wsdlFile = new File(WSDL_LOCATAION + "/RetailerCallback.wsdl");
SoapUIClientService mbean = new SoapUIClientService();
Map params = new HashMap();
+ properties.setProperty(HttpClientFactory.TARGET_HOST_URL, wsdlFile.toURI().toString());
params.put("salesOrderNotification", new OrderNotification());
- String message = mbean.buildRequest(wsdlFile.toURI().toString(), "SendSalesOrderNotification", params);
+ String message = mbean.buildRequest(wsdlFile.toURI().toString(), "SendSalesOrderNotification", params, properties, null);
assertTrue("Generated SOAP message not as expected. See expected_01.xml. Generated message: \n" + message, compareCharStreams(getClass().getResourceAsStream("expected_01.xml"), new ByteArrayInputStream(message.getBytes())));
- assertEquals("http://localhost:18080/active-bpel/services/RetailerCallback", mbean.getEndpoint(wsdlFile.toURI().toString()));
+ assertEquals("http://localhost:18080/active-bpel/services/RetailerCallback", mbean.getEndpoint(wsdlFile.toURI().toString(), properties));
}
- public void test_has_collections() throws IOException, SAXException {
+ public void test_has_collections() throws IOException, SAXException, ConfigurationException {
File wsdlFile = new File(WSDL_LOCATAION + "/BPELRetailer.wsdl");
SoapUIClientService mbean = new SoapUIClientService();
Map params = new HashMap();
@@ -68,30 +73,44 @@
List<OrderItem> items1 = new ArrayList<OrderItem>();
OrderItem[] items2 = new OrderItem[4];
+ properties.setProperty(HttpClientFactory.TARGET_HOST_URL, wsdlFile.toURI().toString());
+
addOrderItems(items1);
order1.items = items1;
items1.toArray(items2);
order2.items = items2;
params.put("customerOrder", order1);
- String message = mbean.buildRequest(wsdlFile.toURI().toString(), "SubmitOrder", params);
+ String message = mbean.buildRequest(wsdlFile.toURI().toString(), "SubmitOrder", params, properties, null);
assertTrue("Generated SOAP message not as expected. See expected_02.xml. Generated message: \n" + message, compareCharStreams(getClass().getResourceAsStream("expected_02.xml"), new ByteArrayInputStream(message.getBytes())));
items1.remove(0);items1.remove(0);items1.remove(0);
- message = mbean.buildRequest(wsdlFile.toURI().toString(), "SubmitOrder", params);
+ message = mbean.buildRequest(wsdlFile.toURI().toString(), "SubmitOrder", params, properties, null);
assertTrue("Generated SOAP message not as expected. See expected_03.xml. Generated message: \n" + message, compareCharStreams(getClass().getResourceAsStream("expected_03.xml"), new ByteArrayInputStream(message.getBytes())));
params.put("customerOrder", order2);
- message = mbean.buildRequest(wsdlFile.toURI().toString(), "SubmitOrder", params);
+ message = mbean.buildRequest(wsdlFile.toURI().toString(), "SubmitOrder", params, properties, null);
assertTrue("Generated SOAP message not as expected. See expected_02.xml. Generated message: \n" + message, compareCharStreams(getClass().getResourceAsStream("expected_02.xml"), new ByteArrayInputStream(message.getBytes())));
items2 = new OrderItem[] {new OrderItem(4, "item4", 4, new BigDecimal(4.00), 4)};
order2.items = items2;
params.put("customerOrder", order2);
- message = mbean.buildRequest(wsdlFile.toURI().toString(), "SubmitOrder", params);
+ message = mbean.buildRequest(wsdlFile.toURI().toString(), "SubmitOrder", params, properties, null);
assertTrue("Generated SOAP message not as expected. See expected_03.xml. Generated message: \n" + message, compareCharStreams(getClass().getResourceAsStream("expected_03.xml"), new ByteArrayInputStream(message.getBytes())));
}
+ public void test_smooks_transform() throws IOException, SAXException, ConfigurationException {
+ File wsdlFile = new File(WSDL_LOCATAION + "/RetailerCallback.wsdl");
+ SoapUIClientService mbean = new SoapUIClientService();
+ Map params = new HashMap();
+
+ properties.setProperty(HttpClientFactory.TARGET_HOST_URL, wsdlFile.toURI().toString());
+ params.put("salesOrderNotification", new OrderNotification());
+ String message = mbean.buildRequest(wsdlFile.toURI().toString(), "SendSalesOrderNotification", params, properties, StreamUtils.readStreamString(getClass().getResourceAsStream("sendNotificationTransform.xml"), "UTF-8"));
+ assertTrue("Generated SOAP message not as expected. See expected_04.xml. Generated message: \n" + message, compareCharStreams(getClass().getResourceAsStream("expected_04.xml"), new ByteArrayInputStream(message.getBytes())));
+ assertEquals("http://localhost:18080/active-bpel/services/RetailerCallback", mbean.getEndpoint(wsdlFile.toURI().toString(), properties));
+ }
+
private void addOrderItems(List<OrderItem> items) {
items.add(new OrderItem(1, "item1", 1, new BigDecimal(1.00), 1));
items.add(new OrderItem(2, "item2", 2, new BigDecimal(2.00), 2));
Added: labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/expected_04.xml
===================================================================
--- labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/expected_04.xml (rev 0)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/expected_04.xml 2007-07-19 18:59:35 UTC (rev 13642)
@@ -0,0 +1,8 @@
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:abi="http://org.jboss.esb/quickstarts/bpel/ABI_OrderManager">
+ <soapenv:Header><something addedto="header"/></soapenv:Header>
+ <soapenv:Body>
+ <abi:salesOrderNotification>
+ <abi:orderNumber>12345</abi:orderNumber>
+ </abi:salesOrderNotification>
+ </soapenv:Body>
+</soapenv:Envelope>
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/expected_04.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/sendNotificationTransform.xml
===================================================================
--- labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/sendNotificationTransform.xml (rev 0)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/sendNotificationTransform.xml 2007-07-19 18:59:35 UTC (rev 13642)
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd">
+
+ <resource-config selector="header">
+ <resource type="xsl">
+ <!--
+ <something addedto="header" />
+ -->
+ </resource>
+ <param name="action">addto</param>
+ </resource-config>
+
+</smooks-resource-list>
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/sendNotificationTransform.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/services/soapui-client/src/test/resources/log4j.xml
===================================================================
--- labs/jbossesb/trunk/product/services/soapui-client/src/test/resources/log4j.xml 2007-07-19 18:54:41 UTC (rev 13641)
+++ labs/jbossesb/trunk/product/services/soapui-client/src/test/resources/log4j.xml 2007-07-19 18:59:35 UTC (rev 13642)
@@ -21,8 +21,8 @@
<!-- ============================== -->
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
- <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="Target" value="System.out"/>
+ <param name="Threshold" value="DEBUG"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
@@ -41,13 +41,13 @@
<priority value="ERROR"/>
</category>
<category name="org.jboss">
- <priority value="WARN"/>
+ <priority value="INFO"/>
</category>
<category name="org.jboss.soa.esb">
- <priority value="ERROR"/>
+ <priority value="INFO"/>
</category>
<category name="org.jboss.internal.soa.esb">
- <priority value="ERROR"/>
+ <priority value="INFO"/>
</category>
<category name="org.apache">
<priority value="ERROR"/>
More information about the jboss-svn-commits
mailing list