From 36eecb1a08a817605dcc81d949921123d3e23487 Mon Sep 17 00:00:00 2001 From: antelder Date: Tue, 2 Sep 2008 08:20:57 +0000 Subject: Change so the target binding is passed in to the JMS service listener. (used by the jms based sca binding so it can get the tagert uri) git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@691145 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/binding/jms/provider/JMSBindingListener.java | 7 +++++-- .../sca/binding/jms/provider/JMSBindingProviderFactory.java | 2 +- .../sca/binding/jms/provider/JMSBindingServiceBindingProvider.java | 7 +++++-- .../tuscany/sca/binding/jms/provider/ObjectMessageProcessor.java | 7 ++++++- .../tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java | 2 +- .../provider/JMSBindingServiceQueueCreateModeTestCaseFIXME.java | 2 +- 6 files changed, 19 insertions(+), 8 deletions(-) (limited to 'java/sca/modules/binding-jms-runtime') diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java index 6a2ba35aa3..4701c7b805 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingListener.java @@ -33,6 +33,7 @@ import javax.jms.Session; import javax.jms.Topic; import javax.naming.NamingException; +import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; @@ -54,6 +55,7 @@ public class JMSBindingListener implements MessageListener { private static final String ON_MESSAGE_METHOD_NAME = "onMessage"; private JMSBinding jmsBinding; + private Binding targetBinding; private JMSResourceFactory jmsResourceFactory; private RuntimeComponentService service; private JMSMessageProcessor requestMessageProcessor; @@ -61,10 +63,11 @@ public class JMSBindingListener implements MessageListener { private String correlationScheme; private List serviceOperations; - public JMSBindingListener(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeComponentService service) throws NamingException { + public JMSBindingListener(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeComponentService service, Binding targetBinding) throws NamingException { this.jmsBinding = jmsBinding; this.jmsResourceFactory = jmsResourceFactory; this.service = service; + this.targetBinding = targetBinding; requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding); responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding); correlationScheme = jmsBinding.getCorrelationScheme(); @@ -107,7 +110,7 @@ public class JMSBindingListener implements MessageListener { setHeaderProperties(requestJMSMsg, tuscanyMsg, operation); - return service.getRuntimeWire(jmsBinding).invoke(operation, tuscanyMsg); + return service.getRuntimeWire(targetBinding).invoke(operation, tuscanyMsg); } protected Operation getTargetOperation(String operationName) { diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.java index 5afe0abf34..00424d32c2 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.java @@ -49,7 +49,7 @@ public class JMSBindingProviderFactory implements BindingProviderFactory getModelType() { diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java index 2e19db86ca..a84283be65 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java @@ -31,6 +31,7 @@ import javax.jms.Session; import javax.jms.Topic; import javax.naming.NamingException; +import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; @@ -50,6 +51,7 @@ public class JMSBindingServiceBindingProvider implements ServiceBindingProvider private static final Logger logger = Logger.getLogger(JMSBindingServiceBindingProvider.class.getName()); private RuntimeComponentService service; + private Binding targetBinding; private JMSBinding jmsBinding; private JMSResourceFactory jmsResourceFactory; private MessageConsumer consumer; @@ -58,10 +60,11 @@ public class JMSBindingServiceBindingProvider implements ServiceBindingProvider private Destination destination; - public JMSBindingServiceBindingProvider(RuntimeComponent component, RuntimeComponentService service, JMSBinding binding, WorkScheduler workScheduler) { + public JMSBindingServiceBindingProvider(RuntimeComponent component, RuntimeComponentService service, Binding targetBinding, JMSBinding binding, WorkScheduler workScheduler) { this.service = service; this.jmsBinding = binding; this.workScheduler = workScheduler; + this.targetBinding = targetBinding; jmsResourceFactory = new JMSResourceFactory(binding.getConnectionFactoryName(), binding.getInitialContextFactoryName(), binding.getJndiURL()); @@ -139,7 +142,7 @@ public class JMSBindingServiceBindingProvider implements ServiceBindingProvider consumer = session.createConsumer(destination); } - final JMSBindingListener listener = new JMSBindingListener(jmsBinding, jmsResourceFactory, service); + final JMSBindingListener listener = new JMSBindingListener(jmsBinding, jmsResourceFactory, service, targetBinding); try { consumer.setMessageListener(listener); diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/ObjectMessageProcessor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/ObjectMessageProcessor.java index e83fad89a4..e9ae3cecaa 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/ObjectMessageProcessor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/ObjectMessageProcessor.java @@ -43,7 +43,12 @@ public class ObjectMessageProcessor extends AbstractMessageProcessor { protected Object[] extractPayload(Message msg) { try { - return new Object[] {((ObjectMessage)msg).getObject()}; + Object o = ((ObjectMessage)msg).getObject(); + if (o != null && o.getClass().isArray()) { + return (Object[])o; + } else { + return new Object[] { o}; + } } catch (JMSException e) { throw new JMSBindingException(e); diff --git a/java/sca/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java b/java/sca/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java index b27795ab09..03cc0bf1c4 100644 --- a/java/sca/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java +++ b/java/sca/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java @@ -204,7 +204,7 @@ public class OperationSelectionTestCaseFIXME { .andReturn(operationReturnValue); // Create the JMS Binding Listener - final JMSBindingListener bindingListener = new JMSBindingListener(jmsBinding, jmsResourceFactory, service); + final JMSBindingListener bindingListener = new JMSBindingListener(jmsBinding, jmsResourceFactory, service, null); // Simulate a message final TextMessage requestJMSMsg = EasyMock.createStrictMock(TextMessage.class); diff --git a/java/sca/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceQueueCreateModeTestCaseFIXME.java b/java/sca/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceQueueCreateModeTestCaseFIXME.java index c3c18fbfbe..b002c35cc8 100644 --- a/java/sca/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceQueueCreateModeTestCaseFIXME.java +++ b/java/sca/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceQueueCreateModeTestCaseFIXME.java @@ -141,7 +141,7 @@ public class JMSBindingServiceQueueCreateModeTestCaseFIXME { // Try and create the JMS Binding Service for the JMS Binding try { JMSBindingServiceBindingProvider jmsService = - new JMSBindingServiceBindingProvider(null, service, jmsBinding, null); + new JMSBindingServiceBindingProvider(null, service, null, jmsBinding, null); jmsService.start(); // Check whether we were expecting an exception -- cgit v1.2.3