camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject svn commit: r799863 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/ camel-core/src/main/java/org/apache/camel/impl/ components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/ components/camel-spring-integration/src/main/ja...
Date Sat, 01 Aug 2009 13:56:17 GMT
Author: hadrian
Date: Sat Aug  1 13:56:17 2009
New Revision: 799863

URL: http://svn.apache.org/viewvc?rev=799863&view=rev
Log:
CAMEL-1822. Consolidated copy() and copyFrom() in the Exchange api

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java
    camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationEndpoint.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java?rev=799863&r1=799862&r2=799863&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java Sat Aug  1 13:56:17
2009
@@ -278,13 +278,6 @@
     Exchange copy(boolean handoverOnCompletion);
 
     /**
-     * Copies the data into this exchange from the given exchange
-     *
-     * @param source is the source from which headers and messages will be copied
-     */
-    void copyFrom(Exchange source);
-
-    /**
      * Returns the endpoint which originated this message exchange if a consumer on an endpoint
created the message exchange
      * otherwise this property will be null
      */

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java?rev=799863&r1=799862&r2=799863&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java Sat Aug
 1 13:56:17 2009
@@ -158,9 +158,7 @@
                 return exchangeType.cast(exchange);
             }
         }
-        Exchange answer = createExchange();
-        answer.copyFrom(exchange);
-        return answer;
+        return exchange.copy();
     }
 
     /**

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java?rev=799863&r1=799862&r2=799863&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java Sat Aug
 1 13:56:17 2009
@@ -63,8 +63,8 @@
 
     public DefaultExchange(Exchange parent) {
         this(parent.getContext(), parent.getPattern());
-        this.unitOfWork = parent.getUnitOfWork();
         this.fromEndpoint = parent.getFromEndpoint();
+        this.unitOfWork = parent.getUnitOfWork();
     }
 
     public DefaultExchange(Endpoint fromEndpoint) {
@@ -72,9 +72,8 @@
     }
     
     public DefaultExchange(Endpoint fromEndpoint, ExchangePattern pattern) {
-        this.context = fromEndpoint.getCamelContext();
+        this(fromEndpoint.getCamelContext(), pattern);
         this.fromEndpoint = fromEndpoint;
-        this.pattern = pattern;
     }
 
     @Override
@@ -83,8 +82,14 @@
     }
 
     public Exchange copy() {
-        Exchange exchange = new DefaultExchange(this);
-        exchange.copyFrom(this);
+        DefaultExchange exchange = new DefaultExchange(this);
+
+        exchange.setProperties(safeCopy(getProperties()));
+        safeCopy(exchange.getIn(), getIn());
+        if (hasOut()) {
+            safeCopy(exchange.getOut(), getOut());
+        }
+        exchange.setException(getException());
         return exchange;
     }
 
@@ -92,7 +97,7 @@
         Exchange copy = copy();
         // do not share the unit of work
         copy.setUnitOfWork(null);
-        // handover on completeion to the copy if we got any
+        // hand over on completion to the copy if we got any
         if (handoverOnCompletion && unitOfWork != null) {
             unitOfWork.handoverSynchronization(copy);
         }
@@ -101,24 +106,6 @@
         return copy;
     }
 
-    public void copyFrom(Exchange exchange) {
-        if (exchange == this) {
-            return;
-        }
-        setProperties(safeCopy(exchange.getProperties()));
-
-        // this can cause strangeness if we copy, say, a FileMessage onto an FtpExchange
with overloaded getExchange() methods etc.
-        safeCopy(getIn(), exchange.getIn());
-        if (exchange.hasOut()) {
-            safeCopy(getOut(), exchange.getOut());
-        }
-        setException(exchange.getException());
-
-        unitOfWork = exchange.getUnitOfWork();
-        pattern = exchange.getPattern();
-        setFromEndpoint(exchange.getFromEndpoint());
-    }
-
     private static void safeCopy(Message message, Message that) {
         if (message != null) {
             message.copyFrom(that);

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java?rev=799863&r1=799862&r2=799863&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java
Sat Aug  1 13:56:17 2009
@@ -43,11 +43,6 @@
     }
 
     @Override
-    public Exchange createExchange() {
-        return new DefaultExchange(this);
-    }
-
-    @Override
     @SuppressWarnings("unchecked")
     public Exchange createExchange(GenericFile<T> file) {
         Exchange answer = new DefaultExchange(this);

Modified: camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationEndpoint.java?rev=799863&r1=799862&r2=799863&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationEndpoint.java
(original)
+++ camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationEndpoint.java
Sat Aug  1 13:56:17 2009
@@ -65,14 +65,6 @@
         return new SpringIntegrationConsumer(this, processor);
     }
 
-    public Exchange createExchange() {
-        return createExchange(getExchangePattern());
-    }
-
-    public Exchange createExchange(ExchangePattern pattern) {
-        return new DefaultExchange(this, pattern);
-    }
-
     public void setInputChannel(String input) {
         inputChannel = input;
     }



Mime
View raw message