[jboss-svn-commits] JBL Code SVN: r20682 - in labs/jbossesb/trunk/product: rosetta/src/org/jboss/internal/soa/esb/couriers/helpers and 8 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Jun 21 10:10:23 EDT 2008
Author: tfennelly
Date: 2008-06-21 10:10:23 -0400 (Sat, 21 Jun 2008)
New Revision: 20682
Added:
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/AbstractTestRunner.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/jbossesb-properties.xml
labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/smooks/ProfilingUnitTest.java
labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/smooks/profiling-esb.xml
labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/smooks/profiling-smooks-01.xml
Modified:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/JmsComposer.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/Properties.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/InVMListenerUnitTest.java
labs/jbossesb/trunk/product/samples/quickstarts/native_client/jboss-esb.xml
labs/jbossesb/trunk/product/samples/quickstarts/native_client/src/org/jboss/soa/esb/samples/quickstart/nativeclient/MyAction.java
labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/smooks/SmooksAction.java
Log:
http://jira.jboss.com/jira/browse/JBESB-1835
http://jira.jboss.com/jira/browse/JBESB-1840
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java 2008-06-21 13:20:10 UTC (rev 20681)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java 2008-06-21 14:10:23 UTC (rev 20682)
@@ -296,14 +296,6 @@
else
handler.renameFile(work, done);
- /*
- * If this is fault message, then throw an exception with the contents. With the
- * exception of user-defined exceptions, faults will have nothing in the body, properties etc.
- */
-
- if (Type.isFaultMessage(result))
- Factory.createExceptionFromFault(result);
-
return result;
}
try
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java 2008-06-21 13:20:10 UTC (rev 20681)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java 2008-06-21 14:10:23 UTC (rev 20682)
@@ -207,15 +207,7 @@
}
if (result != null) {
- /*
- * If this is fault message, then throw an exception with the contents. With the
- * exception of user-defined exceptions, faults will have nothing in the body, properties etc.
- */
- if (Type.isFaultMessage(result)) {
- Factory.createExceptionFromFault(result);
- } else {
- return result;
- }
+ return result;
}
}
} finally {
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java 2008-06-21 13:20:10 UTC (rev 20681)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java 2008-06-21 14:10:23 UTC (rev 20682)
@@ -32,6 +32,8 @@
import org.jboss.soa.esb.couriers.*;
import org.jboss.soa.esb.filter.FilterManager;
import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.util.Type;
+import org.jboss.soa.esb.listeners.message.errors.Factory;
import java.net.URI;
import java.net.URISyntaxException;
@@ -211,9 +213,15 @@
public Message pickup(long waitTime) throws CourierException,
CourierTimeoutException
{
- return pickup(waitTime, _pickupCourier);
- }
+ Message message = pickup(waitTime, _pickupCourier);
+ if (message != null && Type.isFaultMessage(message)) {
+ Factory.createExceptionFromFault(message) ;
+ }
+
+ return message;
+ }
+
/**
* @see org.jboss.soa.esb.couriers.TwoWayCourier#pickup(long waitTime, EPR
* epr).
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/JmsComposer.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/JmsComposer.java 2008-06-21 13:20:10 UTC (rev 20681)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/JmsComposer.java 2008-06-21 14:10:23 UTC (rev 20682)
@@ -78,8 +78,9 @@
* exception of user-defined exceptions, faults will have nothing in the body, properties etc.
*/
- if (Type.isFaultMessage(composedMessage))
+ if (Type.isFaultMessage(composedMessage)) {
Factory.createExceptionFromFault(composedMessage) ;
+ }
return composedMessage ;
}
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java 2008-06-21 13:20:10 UTC (rev 20681)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java 2008-06-21 14:10:23 UTC (rev 20682)
@@ -49,7 +49,9 @@
import org.jboss.soa.esb.listeners.ha.ServiceClusterInfo;
import org.jboss.soa.esb.listeners.ha.ServiceClusterInfoImpl;
import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.listeners.message.errors.Factory;
import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.util.Type;
import org.jboss.soa.esb.services.persistence.MessageStore;
import org.jboss.soa.esb.services.persistence.RedeliverStore;
import org.jboss.soa.esb.services.registry.RegistryException;
@@ -315,7 +317,10 @@
{
replyMessage = eprInvoker.attemptDelivery(message, epr);
if (replyMessage != null) {
- // We've delivered it, we're done!
+ if (Type.isFaultMessage(replyMessage)) {
+ Factory.createExceptionFromFault(replyMessage) ;
+ }
+ // We've delivered it, we're done!
return replyMessage;
} else {
logger.info("Unresponsive EPR: " + epr+" for message: "+message.getHeader());
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/Properties.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/Properties.java 2008-06-21 13:20:10 UTC (rev 20681)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/message/Properties.java 2008-06-21 14:10:23 UTC (rev 20682)
@@ -29,6 +29,11 @@
public interface Properties
{
+ /**
+ * Message Profile property key.
+ */
+ public static final String MESSAGE_PROFILE = "messageProfile";
+
/**
* getProperty(name)
*
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/InVMListenerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/InVMListenerUnitTest.java 2008-06-21 13:20:10 UTC (rev 20681)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/InVMListenerUnitTest.java 2008-06-21 14:10:23 UTC (rev 20682)
@@ -21,11 +21,11 @@
import junit.framework.TestCase;
import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.ActionProcessingException;
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.addressing.eprs.InVMEpr;
import org.jboss.soa.esb.client.ServiceInvoker;
import org.jboss.soa.esb.common.Environment;
-import org.jboss.soa.esb.couriers.CourierFactory;
import org.jboss.soa.esb.couriers.FaultMessageException;
import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
import org.jboss.soa.esb.listeners.message.MessageDeliverException;
@@ -33,10 +33,8 @@
import org.jboss.soa.esb.message.format.MessageFactory;
import org.jboss.soa.esb.mock.MockAction;
import org.jboss.soa.esb.parameters.ParamRepositoryException;
-import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.services.registry.ServiceNotFoundException;
+import org.jboss.soa.esb.testutils.AbstractTestRunner;
import org.jboss.soa.esb.testutils.ESBConfigUtil;
-import org.jboss.internal.soa.esb.couriers.InVMCourier;
import org.xml.sax.SAXException;
import java.io.IOException;
@@ -49,21 +47,17 @@
protected void setUp() throws Exception {
System.setProperty(Environment.DEFAULT_INVM_SCOPE, "GLOBAL");
+ MockAction.exception = null;
}
protected void tearDown() throws Exception {
System.setProperty(Environment.DEFAULT_INVM_SCOPE, "NONE");
+ MockAction.exception = null;
}
- public void test_async() throws IOException, SAXException, ConfigurationException, ManagedLifecycleException, ParamRepositoryException, MessageDeliverException {
- ESBConfigUtil esbConfig = new ESBConfigUtil(getClass().getResourceAsStream("in-listener-config-01.xml"));
-
- esbConfig.setESBProperties(getClass().getResourceAsStream("jbossesb-properties-01.xml"));
- try {
- esbConfig.installRegistry();
- try {
- esbConfig.startController();
-
+ public void test_async() throws Exception {
+ AbstractTestRunner testRunner = new AbstractTestRunner() {
+ public void test() throws Exception {
ServiceInvoker invoker = new ServiceInvoker("ServiceCat", "ServiceName");
Message message = MessageFactory.getInstance().getMessage();
@@ -72,25 +66,15 @@
sleep(50);
assertTrue(message == MockAction.message);
-
- esbConfig.stopController();
- } finally {
- esbConfig.uninstallRegistry();
}
- } finally {
- esbConfig.resetESBProperties();
- }
+ }.setServiceConfig("in-listener-config-01.xml");
+
+ testRunner.run();
}
- public void test_async_lockstep() throws IOException, SAXException, ConfigurationException, ManagedLifecycleException, ParamRepositoryException, MessageDeliverException, ServiceNotFoundException, RegistryException {
- ESBConfigUtil esbConfig = new ESBConfigUtil(getClass().getResourceAsStream("in-listener-config-04.xml"));
-
- esbConfig.setESBProperties(getClass().getResourceAsStream("jbossesb-properties-01.xml"));
- try {
- esbConfig.installRegistry();
- try {
- esbConfig.startController();
-
+ public void test_async_lockstep() throws Exception {
+ AbstractTestRunner testRunner = new AbstractTestRunner() {
+ public void test() throws Exception {
// Test that we can invoke them....
invokeService("ServiceCat", "Service1");
invokeService("ServiceCat", "Service2");
@@ -105,37 +89,15 @@
assertEquals(1, eprs.size());
assertEquals(true, ((InVMEpr)eprs.get(0)).getLockstep());
assertEquals(4000, ((InVMEpr)eprs.get(0)).getLockstepWaitTime());
-
- esbConfig.stopController();
- } finally {
- esbConfig.uninstallRegistry();
}
- } finally {
- esbConfig.resetESBProperties();
- }
- }
+ }.setServiceConfig("in-listener-config-04.xml");
- private void invokeService(String cat, String name) throws MessageDeliverException {
- ServiceInvoker invoker = new ServiceInvoker(cat, name);
-
- Message message = MessageFactory.getInstance().getMessage();
-
- message.getBody().add("Hi there!");
- invoker.deliverAsync(message);
-
- sleep(50);
- assertTrue(message == MockAction.message);
+ testRunner.run();
}
- public void test_sync() throws IOException, SAXException, ConfigurationException, ManagedLifecycleException, ParamRepositoryException, MessageDeliverException, RegistryException, FaultMessageException {
- ESBConfigUtil esbConfig = new ESBConfigUtil(getClass().getResourceAsStream("in-listener-config-01.xml"));
-
- esbConfig.setESBProperties(getClass().getResourceAsStream("jbossesb-properties-01.xml"));
- try {
- esbConfig.installRegistry();
- try {
- esbConfig.startController();
-
+ public void test_sync_noerror() throws Exception {
+ AbstractTestRunner testRunner = new AbstractTestRunner() {
+ public void test() throws Exception {
ServiceInvoker invoker = new ServiceInvoker("ServiceCat", "ServiceName");
Message message = MessageFactory.getInstance().getMessage();
@@ -144,31 +106,41 @@
assertTrue(message == MockAction.message);
assertTrue(message == response);
-
- esbConfig.stopController();
- } finally {
- esbConfig.uninstallRegistry();
}
- } finally {
- esbConfig.resetESBProperties();
- }
+ }.setServiceConfig("in-listener-config-01.xml");
+
+ testRunner.run();
}
- public void test_sync_multithreaded() throws IOException, SAXException, ConfigurationException, ManagedLifecycleException, ParamRepositoryException, MessageDeliverException, RegistryException, FaultMessageException {
- ESBConfigUtil esbConfig = new ESBConfigUtil(getClass().getResourceAsStream("in-listener-config-03.xml"));
+ public void test_sync_error() throws Exception {
+ AbstractTestRunner testRunner = new AbstractTestRunner() {
+ public void test() throws Exception {
+ ServiceInvoker invoker = new ServiceInvoker("ServiceCat", "ServiceName");
+ Message message = MessageFactory.getInstance().getMessage();
- esbConfig.setESBProperties(getClass().getResourceAsStream("jbossesb-properties-01.xml"));
- try {
- esbConfig.installRegistry();
- try {
- esbConfig.startController();
+ message.getBody().add("Hi there!");
+ MockAction.exception = new ActionProcessingException("invm_sync_error");
+ try {
+ invoker.deliverSync(message, 2000);
+ fail("Expected FaultMessageException.");
+ } catch(FaultMessageException e) {
+ assertEquals("org.jboss.soa.esb.actions.ActionProcessingException: invm_sync_error", e.getMessage());
+ }
+ }
+ }.setServiceConfig("in-listener-config-01.xml");
+ testRunner.run();
+ }
+
+ public void test_sync_multithreaded() throws Exception {
+ AbstractTestRunner testRunner = new AbstractTestRunner() {
+ public void test() throws Exception {
ServiceInvoker invoker = new ServiceInvoker("ServiceCat", "ServiceName");
ClientInvokerThread[] clients = new ClientInvokerThread[10];
// Create the clients...
for (int i = 0; i < clients.length; i++) {
- clients[i] = new ClientInvokerThread(invoker);
+ clients[i] = new ClientInvokerThread(invoker);
}
// Start the clients...
@@ -195,20 +167,27 @@
fail("Thread " + i + " was in error: " + clients[i].thrown.getMessage());
}
}
-
- esbConfig.stopController();
- } finally {
- esbConfig.uninstallRegistry();
}
- } finally {
- esbConfig.resetESBProperties();
+ }.setServiceConfig("in-listener-config-03.xml");
+
+ testRunner.run();
+ }
+
+ public void test_none_scoped() throws ManagedLifecycleException, SAXException, ParamRepositoryException, MessageDeliverException, IOException {
+ try {
+ new ESBConfigUtil(getClass().getResourceAsStream("in-listener-config-02.xml"));
+ fail("Expected ConfigurationException");
+ } catch (ConfigurationException e) {
+ assertEquals("Service configuration for Service 'ServiceCat:ServiceName' doesn't define a Message-Aware Listener (i.e. is-gateway='false').", e.getMessage());
}
}
private class ClientInvokerThread extends Thread {
private ServiceInvoker invoker = null;
+
private boolean done = false;
+
private Throwable thrown;
private ClientInvokerThread(ServiceInvoker invoker) {
@@ -237,15 +216,19 @@
done = true;
}
}
+
}
- public void test_none_scoped() throws ManagedLifecycleException, SAXException, ParamRepositoryException, MessageDeliverException, IOException {
- try {
- new ESBConfigUtil(getClass().getResourceAsStream("in-listener-config-02.xml"));
- fail("Expected ConfigurationException");
- } catch (ConfigurationException e) {
- assertEquals("Service configuration for Service 'ServiceCat:ServiceName' doesn't define a Message-Aware Listener (i.e. is-gateway='false').", e.getMessage());
- }
+ private void invokeService(String cat, String name) throws MessageDeliverException {
+ ServiceInvoker invoker = new ServiceInvoker(cat, name);
+
+ Message message = MessageFactory.getInstance().getMessage();
+
+ message.getBody().add("Hi there!");
+ invoker.deliverAsync(message);
+
+ sleep(50);
+ assertTrue(message == MockAction.message);
}
private static void sleep(long millis) {
Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/AbstractTestRunner.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/AbstractTestRunner.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/AbstractTestRunner.java 2008-06-21 14:10:23 UTC (rev 20682)
@@ -0,0 +1,92 @@
+/*
+ * 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.testutils;
+
+import junit.framework.TestCase;
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+
+import java.io.InputStream;
+
+/**
+ * Abstract Test Runner class.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public abstract class AbstractTestRunner {
+
+ private InputStream serviceConfig;
+ private InputStream esbProperties;
+
+ public AbstractTestRunner setServiceConfig(InputStream serviceConfig) {
+ AssertArgument.isNotNull(serviceConfig, "serviceConfig");
+ this.serviceConfig = serviceConfig;
+ return this;
+ }
+
+ public AbstractTestRunner setServiceConfig(String serviceConfig) {
+ AssertArgument.isNotNull(serviceConfig, "serviceConfig");
+ setServiceConfig(getClass().getResourceAsStream(serviceConfig));
+ return this;
+ }
+
+ public AbstractTestRunner setEsbProperties(InputStream esbProperties) {
+ AssertArgument.isNotNull(esbProperties, "esbProperties");
+ this.esbProperties = esbProperties;
+ return this;
+ }
+
+ public AbstractTestRunner setEsbProperties(String esbProperties) {
+ AssertArgument.isNotNull(esbProperties, "esbProperties");
+ setEsbProperties(getClass().getResourceAsStream(esbProperties));
+ return this;
+ }
+
+ public abstract void test() throws Exception;
+
+ public void run() throws Exception {
+ if(serviceConfig == null) {
+ TestCase.fail("'serviceConfig' not configured. Must call setServiceConfig().");
+ }
+
+ ESBConfigUtil esbConfig = new ESBConfigUtil(serviceConfig);
+
+ if(esbProperties != null) {
+ esbConfig.setESBProperties(esbProperties);
+ } else {
+ esbConfig.setESBProperties(AbstractTestRunner.class.getResourceAsStream("jbossesb-properties.xml"));
+ }
+
+ try {
+ esbConfig.installRegistry();
+ try {
+ esbConfig.startController();
+ try {
+ test();
+ } finally {
+ esbConfig.stopController();
+ }
+ } finally {
+ esbConfig.uninstallRegistry();
+ }
+ } finally {
+ esbConfig.resetESBProperties();
+ }
+ }
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/AbstractTestRunner.java
___________________________________________________________________
Name: svn:eol-style
+ native
Copied: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/jbossesb-properties.xml (from rev 20650, labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/jbossesb-properties-01.xml)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/jbossesb-properties.xml (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/jbossesb-properties.xml 2008-06-21 14:10:23 UTC (rev 20682)
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ 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,
+ @author JBoss Inc.
+-->
+<!-- $Id: jbossesb-unittest-properties.xml $ -->
+<!--
+ These options are described in the JBossESB manual.
+ Defaults are provided here for convenience only.
+
+ Please read through this file prior to using the system, and consider
+ updating the specified entries.
+-->
+<esb
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="jbossesb-1_0.xsd">
+ <properties name="core">
+ <property name="org.jboss.soa.esb.jndi.server.url" value="localhost"/>
+ <property name="org.jboss.soa.esb.jndi.server.context.factory" value="org.jnp.interfaces.NamingContextFactory"/>
+ <property name="org.jboss.soa.esb.jndi.server.pkg.prefix" value=""/>
+ <property name="org.jboss.soa.esb.persistence.connection.factory" value="org.jboss.internal.soa.esb.persistence.format.MessageStoreFactoryImpl"/>
+ <property name="jboss.esb.invm.scope.default" value="NONE"/>
+ </properties>
+ <properties name="registry">
+ <property name="org.jboss.soa.esb.registry.queryManagerURI" value="org.apache.juddi.registry.local.InquiryService#inquire"/>
+ <property name="org.jboss.soa.esb.registry.lifeCycleManagerURI" value="org.apache.juddi.registry.local.PublishService#publish"/>
+ <property name="org.jboss.soa.esb.registry.implementationClass" value="org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl"/>
+ <property name="org.jboss.soa.esb.registry.factoryClass" value="org.apache.ws.scout.registry.ConnectionFactoryImpl"/>
+ <property name="org.jboss.soa.esb.registry.user" value="jbossesb"/>
+ <property name="org.jboss.soa.esb.registry.password" value="password"/>
+ <!-- the following parameter is scout specific to set the type of communication between scout and the UDDI (embedded, rmi, soap) -->
+ <property name="org.jboss.soa.esb.scout.proxy.transportClass" value="org.apache.ws.scout.transport.LocalTransport"/>
+ </properties>
+ <properties name="transports" depends="core">
+ <property name="org.jboss.soa.esb.mail.smtp.host" value="localhost"/>
+ <property name="org.jboss.soa.esb.mail.smtp.user" value="jbossesb"/>
+ <property name="org.jboss.soa.esb.mail.smtp.password" value=""/>
+ <property name="org.jboss.soa.esb.mail.smtp.port" value="25"/>
+ </properties>
+ <properties name="connection">
+ <property name="min-pool-size" value="5"/>
+ <property name="max-pool=size" value="10"/>
+ <property name="blocking-timeout-millis" value="5000"/>
+ <property name="abandoned-connection-timeout" value="10000"/>
+ <property name="abandoned-connection-time-interval" value="30000"/>
+ </properties>
+ <properties name="dbstore">
+ <!-- connection manager type -->
+ <property name="org.jboss.soa.esb.persistence.db.conn.manager" value="org.jboss.internal.soa.esb.persistence.manager.StandaloneConnectionManager"/>
+ <!-- property name="org.jboss.soa.esb.persistence.db.conn.manager" value="org.jboss.internal.soa.esb.persistence.manager.J2eeConnectionManager"/ -->
+
+ <!-- this property is only used if using the j2ee connection manager -->
+ <property name="org.jboss.soa.esb.persistence.db.datasource.name" value="java:/JBossesbDS"/>
+
+ <!-- standalone connection pooling settings -->
+ <property name="org.jboss.soa.esb.persistence.db.connection.url" value="jdbc:hsqldb:hsql://localhost:9001/juddi"/>
+ <property name="org.jboss.soa.esb.persistence.db.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
+ <property name="org.jboss.soa.esb.persistence.db.user" value="sa"/>
+ <property name="org.jboss.soa.esb.persistence.db.pwd" value=""/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.initial.size" value="2"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.min.size" value="2"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.max.size" value="5"/>
+ <!--table managed by pool to test for valid connections - created by pool automatically -->
+ <property name="org.jboss.soa.esb.persistence.db.pool.test.table" value="pooltest"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.timeout.millis" value="5000"/>
+ </properties>
+ <properties name="messagerouting">
+ <property name="org.jboss.soa.esb.routing.cbrClass" value="org.jboss.internal.soa.esb.services.routing.cbr.JBossRulesRouter"/>
+ </properties>
+</esb>
Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/jbossesb-properties.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/samples/quickstarts/native_client/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/native_client/jboss-esb.xml 2008-06-21 13:20:10 UTC (rev 20681)
+++ labs/jbossesb/trunk/product/samples/quickstarts/native_client/jboss-esb.xml 2008-06-21 14:10:23 UTC (rev 20682)
@@ -20,7 +20,7 @@
<service category="MyServiceCategory"
name="MyNativeClientService"
- description="A WS Frontend speaks natively to the ESB" >
+ description="A WS Frontend speaks natively to the ESB" invmScope="GLOBAL">
<listeners>
<jms-listener name="JMS-ESBListener"
busidref="quickstartEsbChannel"
Modified: labs/jbossesb/trunk/product/samples/quickstarts/native_client/src/org/jboss/soa/esb/samples/quickstart/nativeclient/MyAction.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/native_client/src/org/jboss/soa/esb/samples/quickstart/nativeclient/MyAction.java 2008-06-21 13:20:10 UTC (rev 20681)
+++ labs/jbossesb/trunk/product/samples/quickstarts/native_client/src/org/jboss/soa/esb/samples/quickstart/nativeclient/MyAction.java 2008-06-21 14:10:23 UTC (rev 20682)
@@ -24,6 +24,7 @@
import org.jboss.soa.esb.message.Body;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.actions.AbstractActionLifecycle;
+import org.jboss.soa.esb.actions.ActionProcessingException;
public class MyAction extends AbstractActionLifecycle {
@@ -51,7 +52,9 @@
// Reset the message body contents with the response...
msgBody.add(("Hello From ESB MyAction: " + contents));
- return message;
+ throw new ActionProcessingException("Break!!!!");
+
+ //return message;
}
public void exceptionHandler(Message message, Throwable exception) {
Modified: labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/smooks/SmooksAction.java
===================================================================
--- labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/smooks/SmooksAction.java 2008-06-21 13:20:10 UTC (rev 20681)
+++ labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/smooks/SmooksAction.java 2008-06-21 14:10:23 UTC (rev 20682)
@@ -27,14 +27,16 @@
import org.jboss.soa.esb.listeners.message.MessageDeliverException;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.MessagePayloadProxy;
+import org.jboss.soa.esb.message.Properties;
import org.milyn.Smooks;
-import org.milyn.event.report.HtmlReportGenerator;
+import org.milyn.profile.Profile;
import org.milyn.container.ExecutionContext;
import org.milyn.container.plugin.PayloadProcessor;
import org.milyn.container.plugin.ResultType;
+import org.milyn.event.report.HtmlReportGenerator;
-import java.io.Serializable;
import java.io.IOException;
+import java.io.Serializable;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@@ -57,19 +59,22 @@
* <property name="excludeNonSerializables" value="false" />
* <property name="resultType" value="STRING" />
* <property name="reportPath" value="/tmp/smooks-report.html" />
+ * <property name="messageProfile" value="fromServiceA" />
* </pre>
*
* Description of configuration properties:
* <ul>
* <li><i>smooksConfig</i> - the Smooks configuration file. Can be a path on the file system or on the classpath.
- * <li><i>get-payload-location</i> - the body location which contains the object to be transformed.
- * <li><i>set-payload-location</i> - the body location where the transformed object will be placed.
+ * <li><i>get-payload-location</i> - the body location which contains the object to be transformed. See {@link MessagePayloadProxy}.
+ * <li><i>set-payload-location</i> - the body location where the transformed object will be placed. See {@link MessagePayloadProxy}.
* <li><i>excludeNonSerializables</i> - if true, non serializable attributes from the Smooks ExecutionContext will no be included. Default is true.
* <li><i>resultType</i> - type of result expected from Smooks ("STRING", "BYTES", "JAVA", "NORESULT"). Default is "STRING". For more
* on specifying and controlling the Smooks filtering result, see <a href="#specify-result">Specifying the Source and Result Types</a>.
* <li><i>javaResultBeanId</i> - specifies the Smooks bean context beanId to be mapped as the result when the resultType is "JAVA". If not specified,
* the whole bean context bean Map is mapped as the result.
* <li><i>reportPath</i> - specifies the path and file name for generating a Smooks Execution Report. This is a development tool.
+ * <li><i>messageProfile</i> - specifies the default message "profile" name to be used in {@link Smooks#createExecutionContext(String) creation of the Smooks ExecutionContext}.
+ * See <a href="#profiling">Message Profiling</a>.
* </ul>
*
* <h3>Exposing the Smooks {@link ExecutionContext} to other ESB Actions</h3>
@@ -92,6 +97,17 @@
* types, which is of particular interest with respect to the Result type e.g. for streaming
* the Result to a file etc.
*
+ * <h3 id="profiling">Message Profiling</h3>
+ * Smooks Profiling allows you to use a single Smooks instance to transform multiple
+ * source messages. As an example, imagine a situation where messages of different formats
+ * are delivered to a Service. Before consuming the messages, the Service needs to transform
+ * these message payloads to a common format. To accomplish this, you can use profiling.
+ * <p/>
+ * The action can have the default profile name configured through the "messageProfile"
+ * property. Each incoming ESB message can specify it's profile name through the
+ * message property of the same name ("messageProfile"). For more on profiling, see
+ * the <a href="http://milyn.codehaus.org/Smooks+Example+-+profiling">profiling example</a>.
+ *
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
* @author <a href="mailto:daniel.bevenius at gmail.com">daniel.bevenius at gmail.com</a>
*/
@@ -101,12 +117,14 @@
private Smooks smooks;
- private PayloadProcessor payloadProcessor;
+ private String defaultMessageProfile;
- private MessagePayloadProxy payloadProxy;
+ private PayloadProcessor payloadProcessor;
- private boolean excludeNonSerializables;
+ private MessagePayloadProxy payloadProxy;
+ private boolean excludeNonSerializables;
+
private String reportPath;
// public
@@ -127,6 +145,9 @@
throw new ConfigurationException("Failed to create Smooks instance for config '" + smooksConfig + "'.", e);
}
+ // Get the default profile from the config...
+ defaultMessageProfile = configTree.getAttribute(Properties.MESSAGE_PROFILE, Profile.DEFAULT_PROFILE);
+
// Create the Smooks PayloadProcessor...
String resultTypeConfig = configTree.getAttribute("resultType", "STRING");
ResultType resultType;
@@ -159,8 +180,9 @@
*/
public Message process( final Message message) throws ActionProcessingException
{
- // Create Smooks ExecutionContext.
- final ExecutionContext executionContext = createExecutionContext( smooks );
+ // Create Smooks ExecutionContext.
+ final String messageProfofile = (String) message.getProperties().getProperty(Properties.MESSAGE_PROFILE, defaultMessageProfile);
+ final ExecutionContext executionContext = smooks.createExecutionContext(messageProfofile);
if(reportPath != null) {
try {
@@ -171,12 +193,24 @@
}
// Use the Smooks PayloadProcessor to execute the transformation....
- final Object newPayload = payloadProcessor.process( extractPayload( message), executionContext );
+ final Object payload;
+ try {
+ payload = payloadProxy.getPayload(message);
+ } catch (MessageDeliverException e) {
+ throw new ActionProcessingException("MessgeDeliveryException while trying to retrieve the message payload:", e);
+ }
+ final Object newPayload = payloadProcessor.process( payload, executionContext );
// Set the ExecutionContext's attributes on the message instance so other actions can access them.
message.getBody().add( EXECUTION_CONTEXT_ATTR_MAP_KEY, getSerializableObjectsMap( executionContext.getAttributes() ) );
- return packagePayload( newPayload, message );
+ try {
+ payloadProxy.setPayload( message, newPayload );
+ } catch (MessageDeliverException e) {
+ throw new ActionProcessingException("MessgeDeliveryException while trying to retrieve the message payload:", e);
+ }
+
+ return message;
}
@Override
@@ -188,49 +222,6 @@
// protected
- /*
- * Hook for subclasses to control how the execution context is created.
- * Might be useful for Actions that use profiles for example.
- */
- protected ExecutionContext createExecutionContext( final Smooks smooks )
- {
- return smooks.createExecutionContext();
- }
-
- /*
- * Hook for subclasses to extract the message payload in
- * any way they see fit.
- */
- protected Object extractPayload(final Message message ) throws ActionProcessingException
- {
- try
- {
- return payloadProxy.getPayload( message );
- }
- catch (MessageDeliverException e)
- {
- throw new ActionProcessingException("MessgeDeliveryException while trying to retrieve the message payload:", e);
- }
- }
-
- /*
- * Hook for subclasses so they can control what and where the payload
- * is added to the ESB Message object.
- */
- protected Message packagePayload( final Object payload, Message message ) throws ActionProcessingException
- {
- try
- {
- payloadProxy.setPayload( message, payload );
- return message;
- }
- catch (MessageDeliverException e)
- {
- throw new ActionProcessingException("MessgeDeliveryException while trying to retrieve the message payload:", e);
-
- }
- }
-
/**
* Will return a Map containing only the Serializable objects
* that exist in the passed-in Map if {@link #excludeNonSerializables} is true.
Added: labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/smooks/ProfilingUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/smooks/ProfilingUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/smooks/ProfilingUnitTest.java 2008-06-21 14:10:23 UTC (rev 20682)
@@ -0,0 +1,71 @@
+/*
+ * 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.smooks;
+
+import junit.framework.TestCase;
+import org.jboss.internal.soa.esb.util.StreamUtils;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.couriers.FaultMessageException;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.Properties;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.soa.esb.testutils.ESBConfigUtil;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class ProfilingUnitTest extends TestCase {
+
+ private ESBConfigUtil esbConfig;
+ private byte[] personXmlBytes = StreamUtils.readStream(SourceResultUnitTest.class.getResourceAsStream("message/person.xml"));
+
+ protected void setUp() throws Exception {
+ esbConfig = new ESBConfigUtil(getClass().getResourceAsStream("profiling-esb.xml"));
+ esbConfig.setESBProperties(getClass().getResourceAsStream("jbossesb-properties.xml"));
+ esbConfig.installRegistry();
+ esbConfig.startController();
+ }
+
+ protected void tearDown() throws Exception {
+ esbConfig.stopController();
+ esbConfig.uninstallRegistry();
+ esbConfig.resetESBProperties();
+ }
+
+ public void test() throws RegistryException, FaultMessageException, MessageDeliverException {
+ test("profile1", "<someone called=\"Tom Fennelly\" is=\"21\">");
+ test("profile2", "<person name=\"Tom Fennelly\" age=\"21\">");
+ }
+
+ private void test(String profile, String expected) throws MessageDeliverException, RegistryException, FaultMessageException {
+ ServiceInvoker invoker = new ServiceInvoker("Transform", "String");
+ Message message = MessageFactory.getInstance().getMessage();
+
+ // Create the message and set the profile on it...
+ message.getBody().add(new String(personXmlBytes));
+ message.getProperties().setProperty(Properties.MESSAGE_PROFILE, profile);
+
+ message = invoker.deliverSync(message, 30000);
+
+ assertEquals(expected, message.getBody().get());
+ }
+}
Property changes on: labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/smooks/ProfilingUnitTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Copied: labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/smooks/profiling-esb.xml (from rev 20650, labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/smooks/source-result-esb.xml)
===================================================================
--- labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/smooks/profiling-esb.xml (rev 0)
+++ labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/smooks/profiling-esb.xml 2008-06-21 14:10:23 UTC (rev 20682)
@@ -0,0 +1,14 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd">
+
+ <services>
+ <service category="Transform" name="String" description="StringTest" invmScope="GLOBAL">
+ <actions mep="RequestResponse">
+ <action name="action" class="org.jboss.soa.esb.smooks.SmooksAction">
+ <property name="smooksConfig" value="/org/jboss/soa/esb/smooks/profiling-smooks-01.xml" />
+ </action>
+ </actions>
+ </service>
+ </services>
+
+</jbossesb>
\ No newline at end of file
Added: labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/smooks/profiling-smooks-01.xml
===================================================================
--- labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/smooks/profiling-smooks-01.xml (rev 0)
+++ labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/smooks/profiling-smooks-01.xml 2008-06-21 14:10:23 UTC (rev 20682)
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd">
+
+ <profiles>
+ <profile base-profile="profile1" sub-profiles="common" />
+ <profile base-profile="profile2" sub-profiles="common" />
+ </profiles>
+
+ <resource-config selector="person" target-profile="common">
+ <resource>org.milyn.javabean.BeanPopulator</resource>
+ <param name="beanId">person</param>
+ <param name="beanClass">org.jboss.soa.esb.smooks.message.Person1</param>
+ <param name="bindings">
+ <binding property="name" selector="person/name" />
+ <binding property="age" type="Integer" selector="person/age" />
+ </param>
+ </resource-config>
+
+ <resource-config selector="person" target-profile="profile1">
+ <resource type="ftl"><!--<someone called="${person.name}" is="${person.age}">--></resource>
+ </resource-config>
+
+ <resource-config selector="person" target-profile="profile2">
+ <resource type="ftl"><!--<person name="${person.name}" age="${person.age}">--></resource>
+ </resource-config>
+
+</smooks-resource-list>
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/smooks/profiling-smooks-01.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
More information about the jboss-svn-commits
mailing list