camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1162778 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/ camel-core/src/main/java/org/apache/camel/builder/xml/ camel-core/src/main/java/org/apache/camel/component/file/ camel-core/src/main/java/org/apache/camel/util/ componen...
Date Mon, 29 Aug 2011 13:00:21 GMT
Author: cschneider
Date: Mon Aug 29 13:00:21 2011
New Revision: 1162778

URL: http://svn.apache.org/viewvc?rev=1162778&view=rev
Log:
Introduce abstraction WrappedFile for GenericFile to avoid dependencies to the file component
from the rest of core

Added:
    camel/trunk/camel-core/src/main/java/org/apache/camel/WrappedFile.java
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/XPathBuilder.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
    camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
    camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
    camel/trunk/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/WrappedFile.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/WrappedFile.java?rev=1162778&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/WrappedFile.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/WrappedFile.java Mon Aug 29 13:00:21
2011
@@ -0,0 +1,7 @@
+package org.apache.camel;
+
+public interface WrappedFile<T> {
+
+    T getFile();
+
+}

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/XPathBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/XPathBuilder.java?rev=1162778&r1=1162777&r2=1162778&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/XPathBuilder.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/xml/XPathBuilder.java Mon
Aug 29 13:00:21 2011
@@ -47,8 +47,8 @@ import org.apache.camel.Message;
 import org.apache.camel.Predicate;
 import org.apache.camel.RuntimeExpressionException;
 import org.apache.camel.Service;
+import org.apache.camel.WrappedFile;
 import org.apache.camel.component.bean.BeanInvocation;
-import org.apache.camel.component.file.GenericFile;
 import org.apache.camel.impl.DefaultExchange;
 import org.apache.camel.spi.Language;
 import org.apache.camel.spi.NamespaceAware;
@@ -779,7 +779,7 @@ public class XPathBuilder implements Exp
         }
 
         // lets try coerce some common types into something JAXP can deal with
-        if (answer instanceof GenericFile) {
+        if (answer instanceof WrappedFile) {
             // special for files so we can work with them out of the box
             InputStream is = exchange.getContext().getTypeConverter().convertTo(InputStream.class,
answer);
             answer = new InputSource(is);

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java?rev=1162778&r1=1162777&r2=1162778&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
Mon Aug 29 13:00:21 2011
@@ -21,6 +21,7 @@ import java.util.Date;
 import java.util.Map;
 
 import org.apache.camel.Exchange;
+import org.apache.camel.WrappedFile;
 import org.apache.camel.util.FileUtil;
 import org.apache.camel.util.ObjectHelper;
 import org.slf4j.Logger;
@@ -30,7 +31,7 @@ import org.slf4j.LoggerFactory;
  * Generic File. Specific implementations of a file based endpoint need to
  * provide a File for transfer.
  */
-public class GenericFile<T>  {
+public class GenericFile<T> implements WrappedFile<T>  {
     private static final transient Logger LOG = LoggerFactory.getLogger(GenericFile.class);
 
     private String endpointPath;
@@ -250,6 +251,10 @@ public class GenericFile<T>  {
         this.lastModified = lastModified;
     }
 
+    /* (non-Javadoc)
+     * @see org.apache.camel.component.file.WrappedFile#getFile()
+     */
+    @Override
     public T getFile() {
         return file;
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java?rev=1162778&r1=1162777&r2=1162778&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java Mon Aug
29 13:00:21 2011
@@ -30,7 +30,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.StreamCache;
 import org.apache.camel.StringSource;
-import org.apache.camel.component.file.GenericFile;
+import org.apache.camel.WrappedFile;
 
 /**
  * Some helper methods when working with {@link org.apache.camel.Message}.
@@ -213,7 +213,7 @@ public final class MessageHelper {
                 return prepend + "[Body is instance of java.io.Reader]";
             } else if (obj instanceof Writer) {
                 return prepend + "[Body is instance of java.io.Writer]";
-            } else if (obj instanceof GenericFile || obj instanceof File) {
+            } else if (obj instanceof WrappedFile || obj instanceof File) {
                 return prepend + "[Body is file based: " + obj + "]";
             }
         }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java?rev=1162778&r1=1162777&r2=1162778&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java Mon Aug 29
13:00:21 2011
@@ -48,7 +48,7 @@ import org.apache.camel.Message;
 import org.apache.camel.Ordered;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.TypeConverter;
-import org.apache.camel.component.file.GenericFile;
+import org.apache.camel.WrappedFile;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -1250,9 +1250,9 @@ public final class ObjectHelper {
      * @return the scanner, is newer <tt>null</tt>
      */
     public static Scanner getScanner(Exchange exchange, Object value) {
-        if (value instanceof GenericFile) {
+        if (value instanceof WrappedFile) {
             // generic file is just a wrapper for the real file so call again with the real
file
-            GenericFile<?> gf = (GenericFile<?>) value;
+            WrappedFile<?> gf = (WrappedFile<?>) value;
             return getScanner(exchange, gf.getFile());
         }
 

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=1162778&r1=1162777&r2=1162778&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
Mon Aug 29 13:00:21 2011
@@ -46,7 +46,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.NoTypeConversionAvailableException;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.StreamCache;
-import org.apache.camel.component.file.GenericFile;
+import org.apache.camel.WrappedFile;
 import org.apache.camel.impl.DefaultExchangeHolder;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.util.CamelContextHelper;
@@ -472,7 +472,7 @@ public class JmsBinding {
         // let body determine the type
         if (body instanceof Node || body instanceof String) {
             type = Text;
-        } else if (body instanceof byte[] || body instanceof GenericFile || body instanceof
File || body instanceof Reader
+        } else if (body instanceof byte[] || body instanceof WrappedFile || body instanceof
File || body instanceof Reader
                 || body instanceof InputStream || body instanceof ByteBuffer || body instanceof
StreamCache) {
             type = Bytes;
         } else if (body instanceof Map) {

Modified: camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java?rev=1162778&r1=1162777&r2=1162778&view=diff
==============================================================================
--- camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
(original)
+++ camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
Mon Aug 29 13:00:21 2011
@@ -27,6 +27,7 @@ import javax.xml.transform.dom.DOMSource
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.StringSource;
+import org.apache.camel.WrappedFile;
 import org.apache.camel.component.file.GenericFile;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.spi.HeaderFilterStrategyAware;
@@ -201,7 +202,7 @@ public class DefaultRestletBinding imple
 
         // set response body according to the message body
         Object body = out.getBody();
-        if (body instanceof GenericFile) {
+        if (body instanceof WrappedFile) {
             // grab body from generic file holder
             GenericFile<?> gf = (GenericFile<?>) body;
             body = gf.getBody();

Modified: camel/trunk/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java?rev=1162778&r1=1162777&r2=1162778&view=diff
==============================================================================
--- camel/trunk/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java
(original)
+++ camel/trunk/components/camel-saxon/src/main/java/org/apache/camel/component/xquery/XQueryBuilder.java
Mon Aug 29 13:00:21 2011
@@ -56,8 +56,8 @@ import org.apache.camel.Predicate;
 import org.apache.camel.Processor;
 import org.apache.camel.RuntimeExpressionException;
 import org.apache.camel.StringSource;
+import org.apache.camel.WrappedFile;
 import org.apache.camel.component.bean.BeanInvocation;
-import org.apache.camel.component.file.GenericFile;
 import org.apache.camel.converter.IOConverter;
 import org.apache.camel.converter.jaxp.XmlConverter;
 import org.apache.camel.spi.NamespaceAware;
@@ -437,7 +437,7 @@ public abstract class XQueryBuilder impl
                 Object body = in.getBody();
 
                 // lets try coerce some common types into something JAXP can deal with
-                if (body instanceof GenericFile) {
+                if (body instanceof WrappedFile) {
                     // special for files so we can work with them out of the box
                     InputStream is = exchange.getContext().getTypeConverter().convertTo(InputStream.class,
body);
                     source = converter.toDOMSource(is);



Mime
View raw message