You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by lh...@apache.org on 2008/04/16 00:58:18 UTC

svn commit: r648447 - /servicemix/smx3/trunk/deployables/serviceengines/servicemix-drools/src/main/java/org/apache/servicemix/drools/model/JbiHelper.java

Author: lhein
Date: Tue Apr 15 15:58:09 2008
New Revision: 648447

URL: http://svn.apache.org/viewvc?rev=648447&view=rev
Log:
extended the helper functions to support Source type parameters

Modified:
    servicemix/smx3/trunk/deployables/serviceengines/servicemix-drools/src/main/java/org/apache/servicemix/drools/model/JbiHelper.java

Modified: servicemix/smx3/trunk/deployables/serviceengines/servicemix-drools/src/main/java/org/apache/servicemix/drools/model/JbiHelper.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/deployables/serviceengines/servicemix-drools/src/main/java/org/apache/servicemix/drools/model/JbiHelper.java?rev=648447&r1=648446&r2=648447&view=diff
==============================================================================
--- servicemix/smx3/trunk/deployables/serviceengines/servicemix-drools/src/main/java/org/apache/servicemix/drools/model/JbiHelper.java (original)
+++ servicemix/smx3/trunk/deployables/serviceengines/servicemix-drools/src/main/java/org/apache/servicemix/drools/model/JbiHelper.java Tue Apr 15 15:58:09 2008
@@ -24,6 +24,7 @@
 import javax.jbi.messaging.MessageExchange;
 import javax.jbi.messaging.MessagingException;
 import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.transform.Source;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -32,6 +33,7 @@
 import org.apache.servicemix.client.ServiceMixClientFacade;
 import org.apache.servicemix.common.EndpointSupport;
 import org.apache.servicemix.drools.DroolsEndpoint;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
 import org.apache.servicemix.jbi.jaxp.StringSource;
 import org.apache.servicemix.jbi.resolver.URIResolver;
 import org.apache.servicemix.jbi.util.MessageUtil;
@@ -102,10 +104,19 @@
     }
     */
     public void route(String uri) throws MessagingException {
-        routeTo(null, uri);
+        Source src = null;
+        routeTo(src, uri);
     }
     
     public void routeTo(String content, String uri) throws MessagingException {
+        if (content == null) {
+            routeTo(this.exchange.getInternalExchange().getMessage("in").getContent(), uri);
+        } else {
+            routeTo(new StringSource(content), uri);
+        }
+    }
+    
+    public void routeTo(Source content, String uri) throws MessagingException {
         MessageExchange me = this.exchange.getInternalExchange();
         String correlationId = (String)exchange.getProperty(JbiConstants.CORRELATION_ID);
         NormalizedMessage in = null;
@@ -113,7 +124,7 @@
             in = me.getMessage("in");
         } else {
             in = me.createMessage();
-            in.setContent(new StringSource(content));
+            in.setContent(content);
         }
         MessageExchange newMe = getChannel().createExchangeFactory().createExchange(me.getPattern());
         URIResolver.configureExchange(newMe, getContext(), uri);
@@ -141,9 +152,14 @@
         update();
     }
     
+    
     public void routeToDefault(String content) throws MessagingException {
         routeTo(content, endpoint.getDefaultRouteURI());
     }
+    
+    public void routeToDefault(Source content) throws MessagingException {
+        routeTo(content, endpoint.getDefaultRouteURI());
+    }
 
     public void fault(String content) throws Exception {
         MessageExchange me = this.exchange.getInternalExchange();
@@ -159,12 +175,28 @@
         update();
     }
     
-    
+    public void fault(Source content) throws Exception {
+        MessageExchange me = this.exchange.getInternalExchange();
+        if (me instanceof InOnly) {
+            me.setError(new Exception(new SourceTransformer().toString(content)));
+            getChannel().send(me);
+        } else {
+            Fault fault = me.createFault();
+            fault.setContent(content);
+            me.setFault(fault);
+            getChannel().sendSync(me);
+        }
+        update();
+    }
 
     public void answer(String content) throws Exception {
+        answer(new StringSource(content));
+    }
+    
+    public void answer(Source content) throws Exception {
         MessageExchange me = this.exchange.getInternalExchange();
         NormalizedMessage out = me.createMessage();
-        out.setContent(new StringSource(content));
+        out.setContent(content);
         me.setMessage(out, "out");
         getChannel().sendSync(me);
         update();