camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r801980 - in /camel/sandbox/tuning-experiment: camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java components/camel-velocity/src/main/java/org/apache/camel/component/velocity/VelocityEndpoint.java
Date Fri, 07 Aug 2009 12:51:03 GMT
Author: davsclaus
Date: Fri Aug  7 12:51:03 2009
New Revision: 801980

URL: http://svn.apache.org/viewvc?rev=801980&view=rev
Log:
Tuning now more works and we got the use original body to use the facade as well and it works
nicely with JMS that used to be pesky.

Modified:
    camel/sandbox/tuning-experiment/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java
    camel/sandbox/tuning-experiment/components/camel-velocity/src/main/java/org/apache/camel/component/velocity/VelocityEndpoint.java

Modified: camel/sandbox/tuning-experiment/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java
URL: http://svn.apache.org/viewvc/camel/sandbox/tuning-experiment/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java?rev=801980&r1=801979&r2=801980&view=diff
==============================================================================
--- camel/sandbox/tuning-experiment/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java
(original)
+++ camel/sandbox/tuning-experiment/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java
Fri Aug  7 12:51:03 2009
@@ -47,19 +47,13 @@
     private List<Synchronization> synchronizations;
     private List<RouteNode> routeNodes;
     private Map<ProcessorDefinition, AtomicInteger> routeIndex = new HashMap<ProcessorDefinition,
AtomicInteger>();
-    private Message originalInMessage;
+    private CopyOnWriteMessageFacade originalInMessage;
 
     public DefaultUnitOfWork(Exchange exchange) {
-        // TODO: optimize to only copy original message if enabled to do so in the route
-
-        // special for JmsMessage as it can cause it to loose headers later. Yeah JMS suchs
-        if (exchange.getIn().getClass().getSimpleName().equals("JmsMessage")) {
-            this.originalInMessage = new DefaultMessage();
-            this.originalInMessage.setBody(exchange.getIn().getBody());
-            // cannot copy headers with a JmsMessage as the underlying javax.jms.Message
object goes nuts 
-        } else {
-            this.originalInMessage = exchange.getIn().copy();
-        }
+        // wrap in facade
+        CopyOnWriteMessageFacade facade = new CopyOnWriteMessageFacade(exchange.getIn());
+        originalInMessage = facade;
+        exchange.setIn(facade);
     }
 
     public void start() throws Exception {
@@ -155,7 +149,8 @@
     }
 
     public Message getOriginalInMessage() {
-        return originalInMessage;
+        // return the read only view of the original message
+        return originalInMessage.getReadOnlyDelegate();
     }
 
     public int getAndIncrement(ProcessorDefinition node) {

Modified: camel/sandbox/tuning-experiment/components/camel-velocity/src/main/java/org/apache/camel/component/velocity/VelocityEndpoint.java
URL: http://svn.apache.org/viewvc/camel/sandbox/tuning-experiment/components/camel-velocity/src/main/java/org/apache/camel/component/velocity/VelocityEndpoint.java?rev=801980&r1=801979&r2=801980&view=diff
==============================================================================
--- camel/sandbox/tuning-experiment/components/camel-velocity/src/main/java/org/apache/camel/component/velocity/VelocityEndpoint.java
(original)
+++ camel/sandbox/tuning-experiment/components/camel-velocity/src/main/java/org/apache/camel/component/velocity/VelocityEndpoint.java
Fri Aug  7 12:51:03 2009
@@ -132,6 +132,8 @@
         for (String key : headers.keySet()) {
             out.setHeader(key, headers.get(key));
         }
+        // and copy headers from in as they can have been mutated directly by velocity engine
+        out.getHeaders().putAll(exchange.getIn().getHeaders());
     }
 
 }



Mime
View raw message