servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r404758 - in /incubator/servicemix/trunk/servicemix-bpe: pom.xml src/main/java/org/apache/servicemix/bpe/BPEEndpoint.java
Date Sun, 07 May 2006 13:22:03 GMT
Author: gnodet
Date: Sun May  7 06:21:59 2006
New Revision: 404758

URL: http://svn.apache.org/viewcvs?rev=404758&view=rev
Log:
Fix CCE in test

Modified:
    incubator/servicemix/trunk/servicemix-bpe/pom.xml
    incubator/servicemix/trunk/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEEndpoint.java

Modified: incubator/servicemix/trunk/servicemix-bpe/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-bpe/pom.xml?rev=404758&r1=404757&r2=404758&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-bpe/pom.xml (original)
+++ incubator/servicemix/trunk/servicemix-bpe/pom.xml Sun May  7 06:21:59 2006
@@ -77,6 +77,11 @@
       <artifactId>xercesImpl</artifactId>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>

Modified: incubator/servicemix/trunk/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEEndpoint.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEEndpoint.java?rev=404758&r1=404757&r2=404758&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEEndpoint.java
(original)
+++ incubator/servicemix/trunk/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEEndpoint.java
Sun May  7 06:21:59 2006
@@ -39,6 +39,7 @@
 import org.apache.ode.bpe.event.IResponseMessage;
 import org.apache.ode.bpe.event.SimpleRequestMessageEvent;
 import org.apache.ode.bpe.interaction.IInteraction;
+import org.apache.ode.bpe.interaction.InteractionException;
 import org.apache.ode.bpe.interaction.InvocationFactory;
 import org.apache.ode.bpe.interaction.XMLInteractionObject;
 import org.apache.ode.bpe.scope.service.BPRuntimeException;
@@ -148,10 +149,8 @@
                     exchange.setStatus(ExchangeStatus.DONE);
                     channel.send(exchange);
                 } else {
-                    IFormattableValue value = (IFormattableValue) payload.invoke(InvocationFactory.newInstance().createGetObjectInvocation());
-                    Document doc = (Document) value.getValueAs(Document.class);
                     NormalizedMessage out = exchange.createMessage();
-                    out.setContent(new DOMSource(doc));
+                    out.setContent(new DOMSource(getDocument(payload)));
                     exchange.setMessage(out, "out");
                     channel.send(exchange);
                 }
@@ -159,22 +158,21 @@
                 if (payload == null) {
                     throw new UnsupportedOperationException("Expected return data for in-out");

                 }
-                IFormattableValue value = (IFormattableValue) payload.invoke(InvocationFactory.newInstance().createGetObjectInvocation());
-                Document doc = (Document) value.getValueAs(Document.class);
                 NormalizedMessage out = exchange.createMessage();
-                out.setContent(new DOMSource(doc));
+                out.setContent(new DOMSource(getDocument(payload)));
                 exchange.setMessage(out, "out");
                 channel.send(exchange);
             } else {
                 throw new UnsupportedOperationException("Unhandled mep: " + exchange.getPattern());
             }
         } catch (BPRuntimeException e) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Exception caught", e);
+            }
             IInteraction payload = (IInteraction) e.getPartMessage(BPEComponent.PART_PAYLOAD);
             if (payload != null) {
                 Fault fault = exchange.createFault();
-                IFormattableValue value = (IFormattableValue) payload.invoke(InvocationFactory.newInstance().createGetObjectInvocation());
-                Document doc = (Document) value.getValueAs(Document.class);
-                fault.setContent(new DOMSource(doc));
+                fault.setContent(new DOMSource(getDocument(payload)));
                 exchange.setFault(fault);
             } else {
                 exchange.setError(e);
@@ -187,6 +185,17 @@
 	}
 
 	public void stop() throws Exception {
+	}
+	
+	protected Document getDocument(IInteraction interaction) throws InteractionException {
+		Object obj = interaction.invoke(InvocationFactory.newInstance().createGetObjectInvocation());
+        if (obj instanceof Document) {
+        	return (Document) obj;
+        } else if (obj instanceof IFormattableValue) {
+        	return (Document) ((IFormattableValue) obj).getValueAs(Document.class);
+        } else {
+        	throw new IllegalStateException("Unable to handle object of type: " + obj.getClass().getName());
+        }
 	}
 
 



Mime
View raw message