servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r565873 - in /incubator/servicemix/trunk: common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/bindings/soap/interceptors/ common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/interceptors/jbi/ common/servicemix-soap...
Date Tue, 14 Aug 2007 19:40:33 GMT
Author: gnodet
Date: Tue Aug 14 12:40:31 2007
New Revision: 565873

URL: http://svn.apache.org/viewvc?view=rev&rev=565873
Log:
SM-995: JmsProviderEndpoint in-out mode need to be implemented

Added:
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/HelloWorld-RPC-Input-Hello.xml
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/HelloWorld-RPC-Input-OneWay.xml
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/HelloWorld-RPC-Output.xml
Modified:
    incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/bindings/soap/interceptors/SoapOutInterceptor.java
    incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/interceptors/jbi/JbiInInterceptor.java
    incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/interceptors/jbi/JbiOutInterceptor.java
    incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/interceptors/jbi/JbiOutWsdl1Interceptor.java
    incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/wsdl/validator/WSIBPValidator.java
    incubator/servicemix/trunk/common/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/jbi/MockExchangeFactory.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/AbstractConsumerEndpoint.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/DefaultConsumerMarshaler.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/DefaultProviderMarshaler.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsConsumerMarshaler.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsProviderEndpoint.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsProviderMarshaler.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsSoapConsumerMarshaler.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsSoapProviderEndpoint.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsSoapProviderMarshaler.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsConsumerEndpointTest.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsProviderEndpointTest.java
    incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/HelloWorld-RPC.wsdl

Modified: incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/bindings/soap/interceptors/SoapOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/bindings/soap/interceptors/SoapOutInterceptor.java?view=diff&rev=565873&r1=565872&r2=565873
==============================================================================
--- incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/bindings/soap/interceptors/SoapOutInterceptor.java (original)
+++ incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/bindings/soap/interceptors/SoapOutInterceptor.java Tue Aug 14 12:40:31 2007
@@ -26,6 +26,7 @@
 import org.apache.servicemix.soap.api.Message;
 import org.apache.servicemix.soap.bindings.soap.SoapVersion;
 import org.apache.servicemix.soap.core.AbstractInterceptor;
+import org.apache.servicemix.soap.util.DomUtil;
 import org.apache.servicemix.soap.util.stax.DOMStreamReader;
 import org.apache.servicemix.soap.util.stax.StaxUtil;
 import org.w3c.dom.DocumentFragment;
@@ -66,7 +67,7 @@
                 StaxUtil.writeStartElement(writer, soapVersion.getHeader());
                 for (Iterator it = message.getSoapHeaders().values().iterator(); it.hasNext();) {
                     DocumentFragment df = (DocumentFragment) it.next();
-                    Element e = (Element) df.getFirstChild();
+                    Element e = DomUtil.getFirstChildElement(df);
                     StaxUtil.copy(new DOMStreamReader(e), writer);
                 }
                 writer.writeEndElement();

Modified: incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/interceptors/jbi/JbiInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/interceptors/jbi/JbiInInterceptor.java?view=diff&rev=565873&r1=565872&r2=565873
==============================================================================
--- incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/interceptors/jbi/JbiInInterceptor.java (original)
+++ incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/interceptors/jbi/JbiInInterceptor.java Tue Aug 14 12:40:31 2007
@@ -73,8 +73,11 @@
                     throw new IllegalStateException("Content of type " + MessageExchange.class + " not found on message");
                 }
                 if (message.getContent(Exception.class) == null) {
-                    nm = exchange.createMessage();
-                    exchange.setMessage(nm, "out");
+                    nm = exchange.getMessage("out");
+                    if (nm == null) {
+                        nm = exchange.createMessage();
+                        exchange.setMessage(nm, "out");
+                    }
                 } else {
                     exchange.setFault(exchange.createFault());
                     nm = exchange.getFault();

Modified: incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/interceptors/jbi/JbiOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/interceptors/jbi/JbiOutInterceptor.java?view=diff&rev=565873&r1=565872&r2=565873
==============================================================================
--- incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/interceptors/jbi/JbiOutInterceptor.java (original)
+++ incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/interceptors/jbi/JbiOutInterceptor.java Tue Aug 14 12:40:31 2007
@@ -26,6 +26,8 @@
 import javax.xml.namespace.QName;
 import javax.xml.transform.Source;
 
+import org.apache.servicemix.jbi.FaultException;
+import org.apache.servicemix.soap.api.Fault;
 import org.apache.servicemix.soap.api.Message;
 import org.apache.servicemix.soap.api.model.Binding;
 import org.apache.servicemix.soap.api.model.Operation;
@@ -57,6 +59,11 @@
             Binding binding = message.get(Binding.class);
             Operation operation = binding.getOperation(me.getOperation());
             if (operation != null) {
+                if (!me.getPattern().equals(operation.getMep())) {
+                    throw new Fault("Received incorrect exchange mep.  Received " + me.getPattern()
+                                    + " but expected " + operation.getMep() + " for operation "
+                                    + operation.getName());
+                }
                 message.put(Operation.class, operation);
                 if (operation instanceof SoapOperation<?>) {
                     String soapAction = ((SoapOperation<?>) operation).getSoapAction();
@@ -81,6 +88,7 @@
     /**
      * Copy NormalizedMessage headers to SoapMessage headers
      */
+    @SuppressWarnings("unchecked")
     private void fromNMSHeaders(Message message, NormalizedMessage normalizedMessage) {
         if (normalizedMessage.getProperty(JbiConstants.PROTOCOL_HEADERS) != null) {
             Map<String, ?> headers = (Map<String, ?>) normalizedMessage.getProperty(JbiConstants.PROTOCOL_HEADERS);

Modified: incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/interceptors/jbi/JbiOutWsdl1Interceptor.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/interceptors/jbi/JbiOutWsdl1Interceptor.java?view=diff&rev=565873&r1=565872&r2=565873
==============================================================================
--- incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/interceptors/jbi/JbiOutWsdl1Interceptor.java (original)
+++ incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/interceptors/jbi/JbiOutWsdl1Interceptor.java Tue Aug 14 12:40:31 2007
@@ -72,7 +72,7 @@
         while (partWrapper != null) {
             if (!JbiConstants.WSDL11_WRAPPER_NAMESPACE.equals(element.getNamespaceURI()) ||
                 !JbiConstants.WSDL11_WRAPPER_PART_LOCALNAME.equals(partWrapper.getLocalName())) {
-                throw new Fault("Unexpected part wrapper element '" + QNameUtil.toString(element)
+                throw new Fault("Unexpected part wrapper element '" + QNameUtil.toString(partWrapper)
                         + "' expected '{" + JbiConstants.WSDL11_WRAPPER_NAMESPACE + "}part'");
             }
             NodeList nodes = partWrapper.getChildNodes();

Modified: incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/wsdl/validator/WSIBPValidator.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/wsdl/validator/WSIBPValidator.java?view=diff&rev=565873&r1=565872&r2=565873
==============================================================================
--- incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/wsdl/validator/WSIBPValidator.java (original)
+++ incubator/servicemix/trunk/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/wsdl/validator/WSIBPValidator.java Tue Aug 14 12:40:31 2007
@@ -226,9 +226,11 @@
                 validateHeaderParts(binding,
                                     WSDLUtils.getExtensions(bop.getBindingInput(), SOAPHeader.class),
                                     bop.getOperation().getInput().getMessage());
-                validateHeaderParts(binding,
-                                    WSDLUtils.getExtensions(bop.getBindingOutput(), SOAPHeader.class),
-                                    bop.getOperation().getOutput().getMessage());
+                if (bop.getOperation().getOutput() != null) {
+                    validateHeaderParts(binding,
+                                        WSDLUtils.getExtensions(bop.getBindingOutput(), SOAPHeader.class),
+                                        bop.getOperation().getOutput().getMessage());
+                }
                 /*
                 for (BindingFault fault : getBindingFaults(bop)) {
                     validateFaultParts(binding,

Modified: incubator/servicemix/trunk/common/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/jbi/MockExchangeFactory.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/common/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/jbi/MockExchangeFactory.java?view=diff&rev=565873&r1=565872&r2=565873
==============================================================================
--- incubator/servicemix/trunk/common/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/jbi/MockExchangeFactory.java (original)
+++ incubator/servicemix/trunk/common/servicemix-soap2/src/test/java/org/apache/servicemix/soap/interceptors/jbi/MockExchangeFactory.java Tue Aug 14 12:40:31 2007
@@ -38,17 +38,20 @@
             str = str.replace("http://www.w3.org/2006/01/wsdl/", "http://www.w3.org/2004/08/wsdl/");
             pattern = URI.create(str);
         }
+        MessageExchange me;
         if (JbiConstants.IN_ONLY.equals(pattern)) {
-            return createInOnlyExchange();
+            me = createInOnlyExchange();
         } else if (JbiConstants.IN_OUT.equals(pattern)) {
-            return createInOutExchange();
+            me = createInOutExchange();
         } else if (JbiConstants.IN_OPTIONAL_OUT.equals(pattern)) {
-            return createInOptionalOutExchange();
+            me = createInOptionalOutExchange();
         } else if (JbiConstants.ROBUST_IN_ONLY.equals(pattern)) {
-            return createRobustInOnlyExchange();
+            me = createRobustInOnlyExchange();
         } else {
             throw new IllegalArgumentException("Unhandled pattern: " + pattern);
         }
+        ((MockMessageExchange) me).setPattern(pattern);
+        return me;
     }
     public InOnly createInOnlyExchange() throws MessagingException {
         return new MockInOnly();

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/AbstractConsumerEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/AbstractConsumerEndpoint.java?view=diff&rev=565873&r1=565872&r2=565873
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/AbstractConsumerEndpoint.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/AbstractConsumerEndpoint.java Tue Aug 14 12:40:31 2007
@@ -46,6 +46,8 @@
 import org.springframework.jms.support.destination.DynamicDestinationResolver;
 
 public abstract class AbstractConsumerEndpoint extends ConsumerEndpoint {
+    
+    protected static final String PROP_JMS_CONTEXT = JmsContext.class.getName();
 
     private JmsConsumerMarshaler marshaler = new DefaultConsumerMarshaler();
     private boolean synchronous = true;
@@ -65,6 +67,7 @@
     private long replyTimeToLive = Message.DEFAULT_TIME_TO_LIVE;
     private Map replyProperties;
 
+    private boolean stateless;
     private StoreFactory storeFactory;
     private Store store;
     
@@ -276,6 +279,14 @@
         this.synchronous = synchronous;
     }
 
+    public boolean isStateless() {
+        return stateless;
+    }
+
+    public void setStateless(boolean stateless) {
+        this.stateless = stateless;
+    }
+
     public Store getStore() {
         return store;
     }
@@ -302,7 +313,7 @@
         if (template == null) {
             template = new JmsTemplate(getConnectionFactory());
         }
-        if (store == null) {
+        if (store == null && !stateless) {
             if (storeFactory == null) {
                 storeFactory = new MemoryStoreFactory();
             }
@@ -321,7 +332,12 @@
     }
 
     public void process(MessageExchange exchange) throws Exception {
-        JmsContext context = (JmsContext) store.load(exchange.getExchangeId());
+        JmsContext context;
+        if (stateless) {
+            context = (JmsContext) exchange.getProperty(PROP_JMS_CONTEXT);
+        } else {
+            context = (JmsContext) store.load(exchange.getExchangeId());
+        }
         processExchange(exchange, null, context);
     }
 
@@ -398,8 +414,8 @@
             logger.trace("Received: " + jmsMessage);
         }
         try {
-            JmsContext context = marshaler.createContext(jmsMessage, getContext());
-            MessageExchange exchange = marshaler.createExchange(context);
+            JmsContext context = marshaler.createContext(jmsMessage);
+            MessageExchange exchange = marshaler.createExchange(context, getContext());
             configureExchangeTarget(exchange);
             if (synchronous) {
                 sendSync(exchange);
@@ -407,7 +423,11 @@
                     processExchange(exchange, session, context);
                 }
             } else {
-                store.store(exchange.getExchangeId(), context);
+                if (stateless) {
+                    exchange.setProperty(PROP_JMS_CONTEXT, context);
+                } else {
+                    store.store(exchange.getExchangeId(), context);
+                }
                 send(exchange);
             }
         } catch (JMSException e) {

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/DefaultConsumerMarshaler.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/DefaultConsumerMarshaler.java?view=diff&rev=565873&r1=565872&r2=565873
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/DefaultConsumerMarshaler.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/DefaultConsumerMarshaler.java Tue Aug 14 12:40:31 2007
@@ -16,6 +16,10 @@
  */
 package org.apache.servicemix.jms.endpoints;
 
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
 import java.net.URI;
 
 import javax.jbi.component.ComponentContext;
@@ -57,13 +61,13 @@
         this.mep = mep;
     }
 
-    public JmsContext createContext(Message message, ComponentContext context) throws Exception {
-        return new Context(message, context);
+    public JmsContext createContext(Message message) throws Exception {
+        return new Context(message);
     }
 
-    public MessageExchange createExchange(JmsContext context) throws Exception {
-        Context ctx = (Context) context;
-        MessageExchange exchange = ctx.componentContext.getDeliveryChannel().createExchangeFactory().createExchange(mep);
+    public MessageExchange createExchange(JmsContext jmsContext, ComponentContext jbiContext) throws Exception {
+        Context ctx = (Context) jmsContext;
+        MessageExchange exchange = jbiContext.getDeliveryChannel().createExchangeFactory().createExchange(mep);
         NormalizedMessage inMessage = exchange.createMessage();
         populateMessage(ctx.message, inMessage);
         exchange.setMessage(inMessage, "in");
@@ -94,15 +98,19 @@
         }
     }
 
-    protected static class Context implements JmsContext {
+    protected static class Context implements JmsContext, Serializable {
         Message message;
-        ComponentContext componentContext;
-        Context(Message message, ComponentContext componentContext) {
+        Context(Message message) {
             this.message = message;
-            this.componentContext = componentContext;
         }
         public Message getMessage() {
             return this.message;
+        }
+        private void writeObject(ObjectOutputStream out) throws IOException {
+            out.writeObject(message);
+        }
+        private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+            message = (Message) in.readObject();
         }
     }
 

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/DefaultProviderMarshaler.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/DefaultProviderMarshaler.java?view=diff&rev=565873&r1=565872&r2=565873
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/DefaultProviderMarshaler.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/DefaultProviderMarshaler.java Tue Aug 14 12:40:31 2007
@@ -23,8 +23,10 @@
 import javax.jms.Message;
 import javax.jms.Session;
 import javax.jms.TextMessage;
+import javax.xml.transform.Source;
 
 import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
 
 public class DefaultProviderMarshaler implements JmsProviderMarshaler {
 
@@ -56,9 +58,14 @@
         return text;
     }
 
-    public Object getDestination(MessageExchange exchange) {
-        // TODO Auto-generated method stub
-        return null;
+    public void populateMessage(Message message, MessageExchange exchange, NormalizedMessage normalizedMessage) throws Exception {
+        if (message instanceof TextMessage) {
+            TextMessage textMessage = (TextMessage) message;
+            Source source = new StringSource(textMessage.getText());
+            normalizedMessage.setContent(source);
+        } else {
+            throw new UnsupportedOperationException("JMS message is not a TextMessage");
+        }
     }
-
+    
 }

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsConsumerMarshaler.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsConsumerMarshaler.java?view=diff&rev=565873&r1=565872&r2=565873
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsConsumerMarshaler.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsConsumerMarshaler.java Tue Aug 14 12:40:31 2007
@@ -29,9 +29,9 @@
         Message getMessage();
     }
     
-    JmsContext createContext(Message message, ComponentContext context) throws Exception;
+    JmsContext createContext(Message message) throws Exception;
     
-    MessageExchange createExchange(JmsContext context) throws Exception;
+    MessageExchange createExchange(JmsContext jmsContext, ComponentContext jbiContext) throws Exception;
     
     Message createOut(MessageExchange exchange, 
                       NormalizedMessage outMsg,

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsProviderEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsProviderEndpoint.java?view=diff&rev=565873&r1=565872&r2=565873
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsProviderEndpoint.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsProviderEndpoint.java Tue Aug 14 12:40:31 2007
@@ -27,10 +27,16 @@
 
 import org.apache.servicemix.common.endpoints.ProviderEndpoint;
 import org.apache.servicemix.jms.JmsEndpointType;
+import org.apache.servicemix.store.Store;
+import org.apache.servicemix.store.StoreFactory;
+import org.apache.servicemix.store.memory.MemoryStoreFactory;
+import org.springframework.jms.UncategorizedJmsException;
 import org.springframework.jms.core.JmsTemplate;
 import org.springframework.jms.core.JmsTemplate102;
 import org.springframework.jms.core.MessageCreator;
+import org.springframework.jms.core.SessionCallback;
 import org.springframework.jms.support.destination.DestinationResolver;
+import org.springframework.jms.support.destination.DynamicDestinationResolver;
 
 /**
  * 
@@ -40,6 +46,9 @@
  */
 public class JmsProviderEndpoint extends ProviderEndpoint implements JmsEndpointType {
 
+    private static final String MSG_SELECTOR_START = "JMSCorrelationID='";    
+    private static final String MSG_SELECTOR_END = "'";
+
     private JmsProviderMarshaler marshaler = new DefaultProviderMarshaler();
     private DestinationChooser destinationChooser = new SimpleDestinationChooser();
     private JmsTemplate template;
@@ -47,7 +56,7 @@
     private boolean jms102;
     private ConnectionFactory connectionFactory;
     private boolean pubSubDomain;
-    private DestinationResolver destinationResolver;
+    private DestinationResolver destinationResolver = new DynamicDestinationResolver();
     private Destination destination;
     private String destinationName;
     private boolean messageIdEnabled = true;
@@ -59,6 +68,13 @@
     private int priority = Message.DEFAULT_PRIORITY;
     private long timeToLive = Message.DEFAULT_TIME_TO_LIVE;
 
+    private Destination replyDestination;
+    private String replyDestinationName;
+    
+    private boolean stateless;
+    private StoreFactory storeFactory;
+    private Store store;
+    
     /**
      * @return the destination
      */
@@ -289,6 +305,46 @@
         this.timeToLive = timeToLive;
     }
 
+    public boolean isStateless() {
+        return stateless;
+    }
+
+    public void setStateless(boolean stateless) {
+        this.stateless = stateless;
+    }
+
+    public StoreFactory getStoreFactory() {
+        return storeFactory;
+    }
+
+    public void setStoreFactory(StoreFactory storeFactory) {
+        this.storeFactory = storeFactory;
+    }
+
+    public Store getStore() {
+        return store;
+    }
+
+    public void setStore(Store store) {
+        this.store = store;
+    }
+
+    public Destination getReplyDestination() {
+        return replyDestination;
+    }
+
+    public void setReplyDestination(Destination replyDestination) {
+        this.replyDestination = replyDestination;
+    }
+
+    public String getReplyDestinationName() {
+        return replyDestinationName;
+    }
+
+    public void setReplyDestinationName(String replyDestinationName) {
+        this.replyDestinationName = replyDestinationName;
+    }
+
     protected void processInOnly(final MessageExchange exchange, final NormalizedMessage in) throws Exception {
         MessageCreator creator = new MessageCreator() {
             public Message createMessage(Session session) throws JMSException {
@@ -316,16 +372,114 @@
         }
     }
 
-    protected void processInOut(MessageExchange exchange, NormalizedMessage in) throws Exception {
-        
+    protected void processInOut(final MessageExchange exchange, final NormalizedMessage in, final NormalizedMessage out) throws Exception {
+        SessionCallback callback = new SessionCallback() {
+            public Object doInJms(Session session) throws JMSException {
+                try {
+                    processInOutInSession(exchange, in, out, session);
+                    return null;
+                } catch (JMSException e) {
+                    throw e;
+                } catch (RuntimeException e) {
+                    throw e;
+                } catch (Exception e) {
+                    throw new UncategorizedJmsException(e);
+                }
+            }
+        };
+        template.execute(callback, true);
+    }
+    
+    protected void processInOutInSession(final MessageExchange exchange, 
+                                         final NormalizedMessage in, 
+                                         final NormalizedMessage out, 
+                                         final Session session) throws Exception {
+        // Create destinations
+        final Destination dest = getDestination(exchange, in, session);
+        final Destination replyDest = getReplyDestination(exchange, out, session);
+        // Create message and send it
+        final Message sendJmsMsg = marshaler.createMessage(exchange, in, session);
+        //setCorrelationID(sendJmsMsg, exchange);
+        sendJmsMsg.setJMSReplyTo(replyDest);
+        template.send(dest, new MessageCreator() {
+            public Message createMessage(Session session) throws JMSException {
+                return sendJmsMsg;
+            }
+        });
+        // Create selector
+        String jmsId = sendJmsMsg.getJMSMessageID();
+        String selector = MSG_SELECTOR_START + jmsId + MSG_SELECTOR_END;
+        //Receiving JMS Message, Creating and Returning NormalizedMessage out
+        Message receiveJmsMsg = template.receiveSelected(replyDest, selector);
+        if (receiveJmsMsg == null) {
+            throw new IllegalStateException("Unable to receive response");
+        }
+        marshaler.populateMessage(receiveJmsMsg, exchange, out);
+    }
+
+    protected Destination getDestination(MessageExchange exchange, Object message, Session session) throws JMSException {
+        Object dest = null;
+        // Let the destinationChooser a chance to choose the destination 
+        if (destinationChooser != null) {
+            dest = destinationChooser.chooseDestination(exchange, message);
+        }
+        // Default to destinationName properties
+        if (dest == null) {
+            dest = destinationName;
+        }
+        // Resolve destination if needed
+        if (dest instanceof Destination) {
+            return (Destination) dest;
+        } else if (dest instanceof String) {
+            return destinationResolver.resolveDestinationName(session, 
+                                                              (String) dest, 
+                                                              isPubSubDomain());
+        }
+        throw new IllegalStateException("Unable to choose destination for exchange " + exchange);
+    }
+
+    protected Destination getReplyDestination(MessageExchange exchange, Object message, Session session) throws JMSException {
+        Object dest = null;
+        // Let the destinationChooser a chance to choose the destination 
+        if (destinationChooser != null) {
+            dest = destinationChooser.chooseDestination(exchange, message);
+        }
+        // Default to replyDestination / replyDestinationName properties
+        if (dest == null) {
+            dest = replyDestination;
+        }
+        if (dest == null) {
+            dest = replyDestinationName;
+        }
+        // Resolve destination if needed
+        if (dest instanceof Destination) {
+            return (Destination) dest;
+        } else if (dest instanceof String) {
+            return destinationResolver.resolveDestinationName(session, 
+                                                              (String) dest, 
+                                                              isPubSubDomain());
+        }
+        throw new IllegalStateException("Unable to choose replyDestination for exchange " + exchange);
     }
     
     public synchronized void start() throws Exception {
         template = createTemplate();
+        if (store == null && !stateless) {
+            if (storeFactory == null) {
+                storeFactory = new MemoryStoreFactory();
+            }
+            store = storeFactory.open(getService().toString() + getEndpoint());
+        }
         super.start();
     }
     
     public synchronized void stop() throws Exception {
+        if (store != null) {
+            if (storeFactory != null) {
+                storeFactory.close(store);
+            }
+            store = null;
+        }
         super.stop();
     }
     

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsProviderMarshaler.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsProviderMarshaler.java?view=diff&rev=565873&r1=565872&r2=565873
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsProviderMarshaler.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsProviderMarshaler.java Tue Aug 14 12:40:31 2007
@@ -23,7 +23,8 @@
 
 public interface JmsProviderMarshaler {
 
-    Object getDestination(MessageExchange exchange);
-
     Message createMessage(MessageExchange exchange, NormalizedMessage in, Session session) throws Exception;
+
+    void populateMessage(Message message, MessageExchange exchange, NormalizedMessage normalizedMessage) throws Exception;
+    
 }

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsSoapConsumerMarshaler.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsSoapConsumerMarshaler.java?view=diff&rev=565873&r1=565872&r2=565873
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsSoapConsumerMarshaler.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsSoapConsumerMarshaler.java Tue Aug 14 12:40:31 2007
@@ -20,6 +20,7 @@
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.Serializable;
 
 import javax.jbi.component.ComponentContext;
 import javax.jbi.messaging.Fault;
@@ -86,16 +87,16 @@
         this.useJbiWrapper = useJbiWrapper;
     }
 
-    public JmsContext createContext(Message message, ComponentContext context) throws Exception {
-        return new Context(message, context);
+    public JmsContext createContext(Message message) throws Exception {
+        return new Context(message);
     }
 
-    public MessageExchange createExchange(JmsContext context) throws Exception {
+    public MessageExchange createExchange(JmsContext jmsContext, ComponentContext jbiContext) throws Exception {
         org.apache.servicemix.soap.api.Message msg = binding.createMessage();
-        ((Context) context).msg = msg;
-        msg.put(ComponentContext.class, ((Context) context).componentContext);
+        ((Context) jmsContext).msg = msg;
+        msg.put(ComponentContext.class, jbiContext);
         msg.put(JbiConstants.USE_JBI_WRAPPER, useJbiWrapper);
-        msg.setContent(InputStream.class, new ByteArrayInputStream(((TextMessage) context.getMessage()).getText().getBytes())); 
+        msg.setContent(InputStream.class, new ByteArrayInputStream(((TextMessage) jmsContext.getMessage()).getText().getBytes())); 
         InterceptorChain phase = getChain(Phase.ServerIn);
         phase.doIntercept(msg);
         return msg.getContent(MessageExchange.class);
@@ -163,13 +164,11 @@
         return chain;
     }
 
-    protected static class Context implements JmsContext {
+    protected static class Context implements JmsContext, Serializable {
         Message message;
-        ComponentContext componentContext;
         org.apache.servicemix.soap.api.Message msg;
-        Context(Message message, ComponentContext componentContext) {
+        Context(Message message) {
             this.message = message;
-            this.componentContext = componentContext;
         }
         public Message getMessage() {
             return this.message;

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsSoapProviderEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsSoapProviderEndpoint.java?view=diff&rev=565873&r1=565872&r2=565873
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsSoapProviderEndpoint.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsSoapProviderEndpoint.java Tue Aug 14 12:40:31 2007
@@ -16,6 +16,31 @@
  */
 package org.apache.servicemix.jms.endpoints;
 
+import java.io.IOException;
+
+import javax.jbi.management.DeploymentException;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap12.SOAP12Address;
+
+import org.w3c.dom.Element;
+
+import org.apache.servicemix.soap.api.Policy;
+import org.apache.servicemix.soap.util.DomUtil;
+import org.apache.servicemix.soap.wsdl.BindingFactory;
+import org.apache.servicemix.soap.wsdl.WSDLUtils;
+import org.apache.servicemix.soap.wsdl.validator.WSIBPValidator;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.WSDLReader;
+import org.apache.woden.types.NCName;
+import org.apache.woden.wsdl20.Description;
+import org.apache.woden.wsdl20.Endpoint;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.springframework.core.io.Resource;
+
 /**
  * 
  * @author gnodet
@@ -24,20 +49,149 @@
  */
 public class JmsSoapProviderEndpoint extends JmsProviderEndpoint {
 
-    public JmsSoapProviderEndpoint() {
-        setMarshaler(new JmsSoapProviderMarshaler());
+    private Resource wsdl;
+    private boolean useJbiWrapper = true;
+    private boolean validateWsdl = true;
+    private Policy[] policies;
+
+    public Resource getWsdl() {
+        return wsdl;
     }
-    
-    protected JmsSoapProviderMarshaler getSoapMarshaler() {
-        return (JmsSoapProviderMarshaler) getMarshaler();
+
+    public void setWsdl(Resource wsdl) {
+        this.wsdl = wsdl;
+    }
+
+    public boolean isValidateWsdl() {
+        return validateWsdl;
+    }
+
+    public void setValidateWsdl(boolean validateWsdl) {
+        this.validateWsdl = validateWsdl;
+    }
+
+    public boolean isUseJbiWrapper() {
+        return useJbiWrapper;
+    }
+
+    public void setUseJbiWrapper(boolean useJbiWrapper) {
+        this.useJbiWrapper = useJbiWrapper;
+    }
+
+    public Policy[] getPolicies() {
+        return policies;
+    }
+
+    public void setPolicies(Policy[] policies) {
+        this.policies = policies;
+    }
+
+
+    @Override
+    public void validate() throws DeploymentException {
+        if (wsdl == null) {
+            throw new DeploymentException("wsdl property must be set");
+        }
+        JmsSoapProviderMarshaler marshaler = new JmsSoapProviderMarshaler();
+        try {
+            description = DomUtil.parse(wsdl.getInputStream());
+            Element elem = description.getDocumentElement();
+            if (WSDLUtils.WSDL1_NAMESPACE.equals(elem.getNamespaceURI())) {
+                validateWsdl1(marshaler);
+            } else if (WSDLUtils.WSDL2_NAMESPACE.equals(elem.getNamespaceURI())) {
+                validateWsdl2(marshaler);
+            } else {
+                throw new DeploymentException("Unrecognized wsdl namespace: " + elem.getNamespaceURI());
+            }
+            marshaler.setUseJbiWrapper(useJbiWrapper);
+            marshaler.setPolicies(policies);
+            setMarshaler(marshaler);
+        } catch (DeploymentException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new DeploymentException("Unable to read WSDL from: " + wsdl, e);
+        }
+        super.validate();
+    }
+
+    protected void validateWsdl1(JmsSoapProviderMarshaler marshaler) throws WSDLException, IOException, DeploymentException {
+        Definition def = WSDLUtils.createWSDL11Reader().readWSDL(wsdl.getURL().toString());
+        if (validateWsdl) {
+            WSIBPValidator validator = new WSIBPValidator(def);
+            if (!validator.isValid()) {
+                throw new DeploymentException("WSDL is not WS-I BP compliant: " + validator.getErrors());
+            }
+        }
+        Service svc;
+        if (getService() != null) {
+            svc = def.getService(getService());
+            if (svc == null) {
+                throw new DeploymentException("Could not find service '" + getService() + "' in wsdl"); 
+            }
+        } else if (def.getServices().size() == 1) {
+            svc = (Service) def.getServices().values().iterator().next();
+            setService(svc.getQName());
+        } else {
+            throw new DeploymentException("If service is not set, the WSDL must contain a single service definition");
+        }
+        Port port;
+        if (getEndpoint() != null) {
+            port = svc.getPort(getEndpoint());
+            if (port == null) {
+                throw new DeploymentException("Cound not find port '" + getEndpoint() + "' "
+                        + "in wsdl for service '" + getService() + "'");
+            }
+        } else if (svc.getPorts().size() == 1) {
+            port = (Port) svc.getPorts().values().iterator().next();
+            setEndpoint(port.getName());
+        } else {
+            throw new DeploymentException("If endpoint is not set, the WSDL service '" + getService() + "' "
+                                             + "must contain a single port definition");
+        }
+        SOAPAddress sa11 = WSDLUtils.getExtension(port, SOAPAddress.class);
+        SOAP12Address sa12 = WSDLUtils.getExtension(port, SOAP12Address.class);
+        if (sa11 != null) {
+            marshaler.setBaseUrl(sa11.getLocationURI());
+        } else if (sa12 != null) {
+            marshaler.setBaseUrl(sa12.getLocationURI());
+        } else {
+            throw new DeploymentException("No SOAP address defined on port '" + port.getName() + "'");
+        }
+        description = WSDLUtils.getWSDL11Factory().newWSDLWriter().getDocument(def);
+        marshaler.setBinding(BindingFactory.createBinding(port));
     }
     
-    public final void setMarshaler(JmsProviderMarshaler marshaler) {
-        if (marshaler instanceof JmsSoapProviderMarshaler) {
-            super.setMarshaler(marshaler);
+    protected void validateWsdl2(JmsSoapProviderMarshaler marshaler) throws
+                                  org.apache.woden.WSDLException, IOException, DeploymentException {
+        WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
+        DescriptionElement descElement = reader.readWSDL(wsdl.getURL().toString());
+        Description desc = descElement.toComponent();
+        org.apache.woden.wsdl20.Service svc;
+        if (getService() != null) {
+            svc = desc.getService(getService());
+            if (svc == null) {
+                throw new DeploymentException("Could not find service '" + getService() + "' in wsdl"); 
+            }
+        } else if (desc.getServices().length == 1) {
+            svc = desc.getServices()[0];
+            setService(svc.getName());
+        } else {
+            throw new DeploymentException("If service is not set, the WSDL must contain a single service definition");
+        }
+        Endpoint endpoint;
+        if (getEndpoint() != null) {
+            endpoint = svc.getEndpoint(new NCName(getEndpoint()));
+            if (endpoint == null) {
+                throw new DeploymentException("Cound not find endpoint '" + getEndpoint() + "' in wsdl for service '" + getService() + "'");
+            }
+        } else if (svc.getEndpoints().length == 1) {
+            endpoint = svc.getEndpoints()[0];
+            setEndpoint(endpoint.getName().toString());
         } else {
-            throw new IllegalArgumentException("marhaler must be a SOAP marshaler");
+            throw new DeploymentException("If endpoint is not set, the WSDL service '" + getService() + "' "
+                                             + "must contain a single port definition");
         }
+        marshaler.setBinding(BindingFactory.createBinding(endpoint));
     }
 
 }

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsSoapProviderMarshaler.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsSoapProviderMarshaler.java?view=diff&rev=565873&r1=565872&r2=565873
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsSoapProviderMarshaler.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/main/java/org/apache/servicemix/jms/endpoints/JmsSoapProviderMarshaler.java Tue Aug 14 12:40:31 2007
@@ -16,21 +16,102 @@
  */
 package org.apache.servicemix.jms.endpoints;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+
 import javax.jbi.messaging.MessageExchange;
 import javax.jbi.messaging.NormalizedMessage;
 import javax.jms.Message;
 import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.apache.servicemix.soap.api.InterceptorChain;
+import org.apache.servicemix.soap.api.InterceptorProvider.Phase;
+import org.apache.servicemix.soap.api.Policy;
+import org.apache.servicemix.soap.api.model.Binding;
+import org.apache.servicemix.soap.interceptors.jbi.JbiConstants;
 
 public class JmsSoapProviderMarshaler implements JmsProviderMarshaler {
 
+    private Binding<?> binding;
+    private boolean useJbiWrapper = true;
+    private Policy[] policies;
+    private String baseUrl;
+
+    public Binding<?> getBinding() {
+        return binding;
+    }
+
+    public void setBinding(Binding<?> binding) {
+        this.binding = binding;
+    }
+
+    public String getBaseUrl() {
+        return baseUrl;
+    }
+
+    public void setBaseUrl(String baseUrl) {
+        this.baseUrl = baseUrl;
+    }
+
+    public boolean isUseJbiWrapper() {
+        return useJbiWrapper;
+    }
+
+    public void setUseJbiWrapper(boolean useJbiWrapper) {
+        this.useJbiWrapper = useJbiWrapper;
+    }
+
+    public Policy[] getPolicies() {
+        return policies;
+    }
+
+    public void setPolicies(Policy[] policies) {
+        this.policies = policies;
+    }
+
     public Message createMessage(MessageExchange exchange, NormalizedMessage in, Session session) throws Exception {
-        // TODO Auto-generated method stub
-        return null;
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+        org.apache.servicemix.soap.api.Message msg = binding.createMessage();
+        exchange.setProperty(org.apache.servicemix.soap.api.Message.class.getName(), null);
+        msg.put(JbiConstants.USE_JBI_WRAPPER, useJbiWrapper);
+        msg.setContent(MessageExchange.class, exchange);
+        msg.setContent(NormalizedMessage.class, in);
+        msg.setContent(OutputStream.class, baos);
+        exchange.setProperty(Message.class.getName(), msg);
+
+        InterceptorChain phaseOut = getChain(Phase.ClientOut);
+        phaseOut.doIntercept(msg);
+        TextMessage jmsMessage = session.createTextMessage();
+        jmsMessage.setText(baos.toString());
+        return jmsMessage;
+    }
+
+    public void populateMessage(Message message, MessageExchange exchange, NormalizedMessage normalizedMessage) throws Exception {
+        org.apache.servicemix.soap.api.Message req = (org.apache.servicemix.soap.api.Message) exchange.getProperty(Message.class.getName());
+        exchange.setProperty(org.apache.servicemix.soap.api.Message.class.getName(), null);
+        org.apache.servicemix.soap.api.Message msg = binding.createMessage(req);
+        msg.put(JbiConstants.USE_JBI_WRAPPER, useJbiWrapper);
+        msg.setContent(MessageExchange.class, exchange);
+        msg.setContent(NormalizedMessage.class, normalizedMessage);
+        String str = ((TextMessage) message).getText();
+        msg.setContent(InputStream.class, new ByteArrayInputStream(str.getBytes()));
+
+        InterceptorChain phaseIn = getChain(Phase.ClientIn);
+        phaseIn.doIntercept(msg);
     }
 
-    public Object getDestination(MessageExchange exchange) {
-        // TODO Auto-generated method stub
-        return null;
+    protected InterceptorChain getChain(Phase phase) {
+        InterceptorChain chain = binding.getInterceptorChain(phase);
+        if (policies != null) {
+            for (int i = 0; i < policies.length; i++) {
+                chain.add(policies[i].getInterceptors(phase));
+            }
+        }
+        return chain;
     }
 
 }

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsConsumerEndpointTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsConsumerEndpointTest.java?view=diff&rev=565873&r1=565872&r2=565873
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsConsumerEndpointTest.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsConsumerEndpointTest.java Tue Aug 14 12:40:31 2007
@@ -77,6 +77,23 @@
         receiver.getMessageList().assertMessagesReceived(1);
     }
 
+    public void testConsumerStateless() throws Exception {
+        JmsComponent component = new JmsComponent();
+        JmsConsumerEndpoint endpoint = new JmsConsumerEndpoint();
+        endpoint.setService(new QName("jms"));
+        endpoint.setEndpoint("endpoint");
+        endpoint.setTargetService(new QName("receiver"));
+        endpoint.setListenerType("simple");
+        endpoint.setConnectionFactory(connectionFactory);
+        endpoint.setDestinationName("destination");
+        endpoint.setStateless(true);
+        component.setEndpoints(new JmsConsumerEndpoint[] {endpoint});
+        container.activateComponent(component, "servicemix-jms");
+
+        jmsTemplate.convertAndSend("destination", "<hello>world</hello>");
+        receiver.getMessageList().assertMessagesReceived(1);
+    }
+
     public void testConsumerSimpleJmsTx() throws Exception {
         JmsComponent component = new JmsComponent();
         JmsConsumerEndpoint endpoint = new JmsConsumerEndpoint();

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsProviderEndpointTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsProviderEndpointTest.java?view=diff&rev=565873&r1=565872&r2=565873
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsProviderEndpointTest.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/java/org/apache/servicemix/jms/JmsProviderEndpointTest.java Tue Aug 14 12:40:31 2007
@@ -16,13 +16,24 @@
  */
 package org.apache.servicemix.jms;
 
+import java.io.ByteArrayOutputStream;
+
 import javax.jbi.messaging.ExchangeStatus;
 import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.InOut;
+import javax.jms.JMSException;
 import javax.jms.Message;
+import javax.jms.Session;
+import javax.jms.TextMessage;
 import javax.xml.namespace.QName;
 
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
 import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.jbi.util.FileUtil;
 import org.apache.servicemix.jms.endpoints.JmsProviderEndpoint;
+import org.apache.servicemix.jms.endpoints.JmsSoapProviderEndpoint;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.jms.core.MessageCreator;
 
 public class JmsProviderEndpointTest extends AbstractJmsTestSupport {
 
@@ -44,6 +55,82 @@
         
         Message msg = jmsTemplate.receive("destination");
         assertNotNull(msg);
+    }
+    
+    public void testSoapProviderInOnly() throws Exception {
+        JmsComponent component = new JmsComponent();
+        
+        JmsSoapProviderEndpoint endpoint = new JmsSoapProviderEndpoint();
+        endpoint.setService(new QName("uri:HelloWorld", "HelloService"));
+        endpoint.setEndpoint("HelloPort");
+        endpoint.setConnectionFactory(connectionFactory);
+        endpoint.setDestinationName("destination");
+        endpoint.setWsdl(new ClassPathResource("org/apache/servicemix/jms/HelloWorld-RPC.wsdl"));
+        component.setEndpoints(new JmsProviderEndpoint[] {endpoint});
+        container.activateComponent(component, "servicemix-jms");
+        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        FileUtil.copyInputStream(new ClassPathResource("org/apache/servicemix/jms/HelloWorld-RPC-Input-OneWay.xml").getInputStream(), baos);
+        InOnly me = client.createInOnlyExchange();
+        me.getInMessage().setContent(new StringSource(baos.toString()));
+        me.setOperation(new QName("uri:HelloWorld", "OneWay"));
+        me.setService(new QName("uri:HelloWorld", "HelloService"));
+        client.sendSync(me);
+        assertEquals(ExchangeStatus.DONE, me.getStatus());
+        
+        Message msg = jmsTemplate.receive("destination");
+        assertNotNull(msg);
+        System.err.println(((TextMessage) msg).getText());
+    }
+    
+    public void testSoapProviderInOut() throws Exception {
+        JmsComponent component = new JmsComponent();
+        
+        JmsSoapProviderEndpoint endpoint = new JmsSoapProviderEndpoint();
+        endpoint.setService(new QName("uri:HelloWorld", "HelloService"));
+        endpoint.setEndpoint("HelloPort");
+        endpoint.setConnectionFactory(connectionFactory);
+        endpoint.setDestinationName("destination");
+        endpoint.setReplyDestinationName("reply");
+        endpoint.setWsdl(new ClassPathResource("org/apache/servicemix/jms/HelloWorld-RPC.wsdl"));
+        component.setEndpoints(new JmsProviderEndpoint[] {endpoint});
+        container.activateComponent(component, "servicemix-jms");
+        
+        Thread th = new Thread() {
+            public void run() {
+                try {
+                    final Message msg = jmsTemplate.receive("destination");
+                    assertNotNull(msg);
+                    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                    FileUtil.copyInputStream(new ClassPathResource("org/apache/servicemix/jms/HelloWorld-RPC-Output.xml")
+                                .getInputStream(), baos);
+                    jmsTemplate.send("reply", new MessageCreator() {
+                        public Message createMessage(Session session) throws JMSException {
+                            TextMessage rep = session.createTextMessage(baos.toString());
+                            rep.setJMSCorrelationID(msg.getJMSMessageID());
+                            return rep;
+                        }
+                    });
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        };
+        th.start();
+        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        FileUtil.copyInputStream(new ClassPathResource("org/apache/servicemix/jms/HelloWorld-RPC-Input-Hello.xml").getInputStream(), baos);
+        InOut me = client.createInOutExchange();
+        me.getInMessage().setContent(new StringSource(baos.toString()));
+        me.setOperation(new QName("uri:HelloWorld", "Hello"));
+        me.setService(new QName("uri:HelloWorld", "HelloService"));
+        client.sendSync(me);
+        assertEquals(ExchangeStatus.ACTIVE, me.getStatus());
+        assertNotNull(me.getOutMessage());
+        assertNotNull(me.getOutMessage().getContent());
+        System.err.println(new SourceTransformer().contentToString(me.getOutMessage()));
+        client.done(me);
+        
     }
     
 }

Added: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/HelloWorld-RPC-Input-Hello.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/HelloWorld-RPC-Input-Hello.xml?view=auto&rev=565873
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/HelloWorld-RPC-Input-Hello.xml (added)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/HelloWorld-RPC-Input-Hello.xml Tue Aug 14 12:40:31 2007
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<jbi:message xmlns:jbi="http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper">
+
+  <jbi:part>
+    <HelloHeader1 xmlns="uri:HelloWorld">
+      <id1>abcdefghij</id1>
+    </HelloHeader1>
+  </jbi:part>
+
+  <jbi:part>
+    <HelloHeader2 xmlns="uri:HelloWorld">
+      <id2>1234567890</id2>
+    </HelloHeader2>
+  </jbi:part>
+
+  <jbi:part>
+      foo
+  </jbi:part>
+
+  <jbi:part>
+      bar
+  </jbi:part>
+
+</jbi:message>

Added: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/HelloWorld-RPC-Input-OneWay.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/HelloWorld-RPC-Input-OneWay.xml?view=auto&rev=565873
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/HelloWorld-RPC-Input-OneWay.xml (added)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/HelloWorld-RPC-Input-OneWay.xml Tue Aug 14 12:40:31 2007
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<jbi:message xmlns:jbi="http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper">
+
+  <jbi:part>
+      Hello
+  </jbi:part>
+
+</jbi:message>

Added: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/HelloWorld-RPC-Output.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/HelloWorld-RPC-Output.xml?view=auto&rev=565873
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/HelloWorld-RPC-Output.xml (added)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/HelloWorld-RPC-Output.xml Tue Aug 14 12:40:31 2007
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
+
+  <SOAP-ENV:Body>
+    <HelloResponse xmlns="uri:HelloWorld">
+      <text xmlns="uri:HelloWorld">foo</text>
+    </HelloResponse>
+  </SOAP-ENV:Body>
+
+</SOAP-ENV:Envelope>

Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/HelloWorld-RPC.wsdl
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/HelloWorld-RPC.wsdl?view=diff&rev=565873&r1=565872&r2=565873
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/HelloWorld-RPC.wsdl (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-jms/src/test/resources/org/apache/servicemix/jms/HelloWorld-RPC.wsdl Tue Aug 14 12:40:31 2007
@@ -44,6 +44,10 @@
         </schema>
     </types>
 
+    <message name="OneWayRequest">
+        <part name="param1" type="xsd:string"/>
+    </message>
+
     <message name="HelloRequest">
         <part name="header1" element="tns:HelloHeader1"/>
         <part name="header2" element="tns:HelloHeader2"/>
@@ -56,6 +60,9 @@
     </message>
 
     <portType name="HelloPortType">
+    	<operation name="OneWay">
+            <input message="tns:OneWayRequest"/>
+    	</operation>
         <operation name="Hello">
             <input message="tns:HelloRequest"/>
             <output message="tns:HelloResponse"/>
@@ -64,6 +71,12 @@
 
     <binding name="HelloSoapBinding" type="tns:HelloPortType">
         <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+        <operation name="OneWay">
+            <soap:operation soapAction=""/>
+            <input>
+                <soap:body use="literal" parts="param1" namespace="uri:HelloWorld"/>
+            </input>
+        </operation>
         <operation name="Hello">
             <soap:operation soapAction=""/>
             <input>



Mime
View raw message