You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2010/09/19 16:26:41 UTC

svn commit: r998674 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java

Author: ningjiang
Date: Sun Sep 19 14:26:41 2010
New Revision: 998674

URL: http://svn.apache.org/viewvc?rev=998674&view=rev
Log:
CAMEL-1331 FileOperations should expect body to be convertible to File

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
    camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java?rev=998674&r1=998673&r2=998674&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java Sun Sep 19 14:26:41 2010
@@ -169,15 +169,14 @@ public class FileOperations implements G
 
             // is the body file based
             File source = null;
-            if (exchange.getIn().getBody() instanceof File || exchange.getIn().getBody() instanceof GenericFile) {
-                source = exchange.getIn().getBody(File.class);
-            }
+            // get the File Object from in message
+            source = exchange.getIn().getBody(File.class);            
 
             if (source != null) {
                 // okay we know the body is a file type
 
                 // so try to see if we can optimize by renaming the local work path file instead of doing
-                // a full file to file copy, as the local work copy is to be deleted afterwords anyway
+                // a full file to file copy, as the local work copy is to be deleted afterwards anyway
                 // local work path
                 File local = exchange.getIn().getHeader(Exchange.FILE_LOCAL_WORK_PATH, File.class);
                 if (local != null && local.exists()) {
@@ -287,8 +286,8 @@ public class FileOperations implements G
     }
 
     /**
-     * Creates and prepares the output file channel. Will position itself in correct position if eg. it should append
-     * or override any existing content.
+     * Creates and prepares the output file channel. Will position itself in correct position if the file is writable
+     *  eg. it should append or override any existing content.
      */
     private FileChannel prepareOutputFileChannel(File target, FileChannel out) throws IOException {
         if (endpoint.getFileExist() == GenericFileExist.Append) {

Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java?rev=998674&r1=998673&r2=998674&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java (original)
+++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java Sun Sep 19 14:26:41 2010
@@ -481,7 +481,6 @@ public class JmsBinding {
      */
     protected JmsMessageType getJMSMessageTypeForBody(Exchange exchange, Object body, Map<String, Object> headers, Session session, CamelContext context) {
         JmsMessageType type = null;
-
         // let body determine the type
         if (body instanceof Node || body instanceof String) {
             type = Text;
@@ -491,7 +490,10 @@ public class JmsBinding {
         } else if (body instanceof Map) {
             type = Map;
         } else if (body instanceof Serializable) {
-            type = Object;
+            type = Object;            
+        } else if (exchange.getContext().getTypeConverter().convertTo(File.class, body) != null 
+                || exchange.getContext().getTypeConverter().convertTo(InputStream.class, body) != null) {
+            type = Bytes;
         }
         return type;
     }