camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r738487 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/main/java/org/apache/camel/component/file/ camel-core/src/main/java/org/apache/camel/converter/ components/camel-jms/src/main/java/org/apache/camel...
Date Wed, 28 Jan 2009 13:52:29 GMT
Author: davsclaus
Date: Wed Jan 28 13:52:29 2009
New Revision: 738487

URL: http://svn.apache.org/viewvc?rev=738487&view=rev
Log:
CAMEL-1241: Added missing type converters for genericfile. Rename spring antpath to not be
in same package as genericfile as this is the one end users should use. To avoid end users
selecting the wrong class when they configure it from spring XML.

Added:
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/SpringAntPathMatcherFileFilter.java
  (contents, props changed)
      - copied, changed from r738465, camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/file/AntPathMatcherFileFilter.java
Removed:
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/file/
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/PredicateBuilder.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/AntPathMatcherGenericFileFilter.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConverter.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java
    camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteToJmsTest.java
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteToJmsToFileTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/file/SpringFileAntPathMatcherFileFilterTest-context.xml

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/PredicateBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/PredicateBuilder.java?rev=738487&r1=738486&r2=738487&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/PredicateBuilder.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/PredicateBuilder.java Wed
Jan 28 13:52:29 2009
@@ -223,7 +223,7 @@
 
             @Override
             public String toString() {
-                return expression + " instanceof " + type.getName();
+                return expression + " instanceof " + type.getCanonicalName();
             }
 
             @Override

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/AntPathMatcherGenericFileFilter.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/AntPathMatcherGenericFileFilter.java?rev=738487&r1=738486&r2=738487&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/AntPathMatcherGenericFileFilter.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/AntPathMatcherGenericFileFilter.java
Wed Jan 28 13:52:29 2009
@@ -27,7 +27,8 @@
  * Exclude take precedence over includes. If a file match both exclude and include it will
be regarded as excluded.
  */
 public class AntPathMatcherGenericFileFilter implements GenericFileFilter {
-    private static final String ANTPATHMATCHER_CLASSNAME = "org.apache.camel.component.file.AntPathMatcherFileFilter";
+    private static final String ANTPATHMATCHER_CLASSNAME = "org.apache.camel.spring.util.SpringAntPathMatcherFileFilter";
+
     private String[] excludes;
     private String[] includes;
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConverter.java?rev=738487&r1=738486&r2=738487&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConverter.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConverter.java
Wed Jan 28 13:52:29 2009
@@ -16,13 +16,16 @@
  */
 package org.apache.camel.component.file;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 
 import org.apache.camel.Converter;
-import org.apache.camel.Exchange;
+import org.apache.camel.converter.IOConverter;
 
 /**
  * A set of converter methods for working with remote file types
@@ -35,33 +38,33 @@
     }
 
     @Converter
-    public static byte[] toByteArray(ByteArrayOutputStream os) {
-        return os.toByteArray();
+    public static InputStream toInputStream(GenericFile<File> file) throws FileNotFoundException
{
+        return IOConverter.toInputStream(file.getFile());
     }
 
     @Converter
-    public static String toString(ByteArrayOutputStream os) {
-        return os.toString();
+    public static BufferedReader toReader(GenericFile<File> file) throws FileNotFoundException
{
+        return IOConverter.toReader(file.getFile());
     }
 
     @Converter
-    public static InputStream toInputStream(ByteArrayOutputStream os) {
-        return new ByteArrayInputStream(os.toByteArray());
+    public static OutputStream toOutputStream(GenericFile<File> file) throws FileNotFoundException
{
+        return IOConverter.toOutputStream(file.getFile());
     }
 
     @Converter
-    public static InputStream toInputStream(GenericFile file, Exchange exchange) {
-        return exchange.getContext().getTypeConverter().convertTo(InputStream.class, exchange,
file.getBody());
+    public static BufferedWriter toWriter(GenericFile<File> file) throws IOException
{
+        return IOConverter.toWriter(file.getFile());
     }
 
     @Converter
-    public static byte[] toByteArray(GenericFile file, Exchange exchange) throws IOException
{
-        return exchange.getContext().getTypeConverter().convertTo(byte[].class, exchange,
file.getBody());
+    public static byte[] toByteArray(GenericFile<File> file) throws IOException {
+        return IOConverter.toByteArray(file.getFile());
     }
 
     @Converter
-    public static String toString(GenericFile file, Exchange exchange) throws IOException
{
-        return exchange.getContext().getTypeConverter().convertTo(String.class, file.getBody());
+    public static String toString(GenericFile<File> file) throws IOException {
+        return IOConverter.toString(file.getFile());
     }
 
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java?rev=738487&r1=738486&r2=738487&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java Wed Jan
28 13:52:29 2009
@@ -101,12 +101,12 @@
     }
 
     @Converter
-    public static Reader toReader(InputStream in) throws FileNotFoundException {
+    public static Reader toReader(InputStream in) {
         return new InputStreamReader(in);
     }
 
     @Converter
-    public static Writer toWriter(OutputStream out) throws FileNotFoundException {
+    public static Writer toWriter(OutputStream out) {
         return new OutputStreamWriter(out);
     }
 

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=738487&r1=738486&r2=738487&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
Wed Jan 28 13:52:29 2009
@@ -43,8 +43,8 @@
 import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.file.GenericFile;
 import org.apache.camel.converter.jaxp.XmlConverter;
-import org.apache.camel.impl.DefaultHeaderFilterStrategy;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.util.CamelContextHelper;
 import org.apache.camel.util.ExchangeHelper;
@@ -322,7 +322,7 @@
         if (body instanceof String) {
             return session.createTextMessage((String)body);
         }
-        if (body instanceof File || body instanceof Reader || body instanceof InputStream
|| body instanceof ByteBuffer) {
+        if (body instanceof GenericFile || body instanceof File || body instanceof Reader
|| body instanceof InputStream || body instanceof ByteBuffer) {
             BytesMessage result = session.createBytesMessage();
             byte[] bytes = context.getTypeConverter().convertTo(byte[].class, body);
             result.writeBytes(bytes);

Modified: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteToJmsTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteToJmsTest.java?rev=738487&r1=738486&r2=738487&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteToJmsTest.java
(original)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteToJmsTest.java
Wed Jan 28 13:52:29 2009
@@ -42,7 +42,7 @@
         mock.message(0).bodyAs(String.class).isEqualTo("Hello World");
 
         deleteDirectory("target/routefromfile");
-        template.sendBodyAndHeader("file://target/routefromfile", "Hello World", FileComponent.HEADER_FILE_NAME,
"hello.txt");
+        template.sendBodyAndHeader("newfile://target/routefromfile", "Hello World", FileComponent.HEADER_FILE_NAME,
"hello.txt");
 
         assertMockEndpointsSatisfied();
     }
@@ -59,7 +59,7 @@
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from("file://target/routefromfile").to("activemq:queue:hello");
+                from("newfile://target/routefromfile").to("activemq:queue:hello");
 
                 from("activemq:queue:hello").to("mock:result");
             }

Modified: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteToJmsToFileTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteToJmsToFileTest.java?rev=738487&r1=738486&r2=738487&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteToJmsToFileTest.java
(original)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteToJmsToFileTest.java
Wed Jan 28 13:52:29 2009
@@ -41,7 +41,7 @@
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
 
-        template.sendBodyAndHeader("file://target/file2file/in", "Hello World", FileComponent.HEADER_FILE_NAME,
"hello.txt");
+        template.sendBodyAndHeader("newfile://target/file2file/in", "Hello World", FileComponent.HEADER_FILE_NAME,
"hello.txt");
 
         assertMockEndpointsSatisfied();
         Thread.sleep(100);
@@ -63,9 +63,9 @@
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from("file://target/file2file/in").to("activemq:queue:hello");
+                from("newfile://target/file2file/in").to("activemq:queue:hello");
 
-                from("activemq:queue:hello").to("file://target/file2file/out", "mock:result");
+                from("activemq:queue:hello").to("newfile://target/file2file/out", "mock:result");
             }
         };
     }

Copied: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/SpringAntPathMatcherFileFilter.java
(from r738465, camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/file/AntPathMatcherFileFilter.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/SpringAntPathMatcherFileFilter.java?p2=camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/SpringAntPathMatcherFileFilter.java&p1=camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/file/AntPathMatcherFileFilter.java&r1=738465&r2=738487&rev=738487&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/file/AntPathMatcherFileFilter.java
(original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/SpringAntPathMatcherFileFilter.java
Wed Jan 28 13:52:29 2009
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.component.file;
+package org.apache.camel.spring.util;
 
 import java.io.File;
 import java.io.FileFilter;
@@ -29,8 +29,8 @@
  * <p/>
  * Exclude take precedence over includes. If a file match both exclude and include it will
be regarded as excluded.
  */
-public class AntPathMatcherFileFilter implements FileFilter {
-    private static final transient Log LOG = LogFactory.getLog(AntPathMatcherFileFilter.class);
+public class SpringAntPathMatcherFileFilter implements FileFilter {
+    private static final transient Log LOG = LogFactory.getLog(SpringAntPathMatcherFileFilter.class);
 
     private AntPathMatcher matcher = new AntPathMatcher();
     private String[] excludes;

Propchange: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/SpringAntPathMatcherFileFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/util/SpringAntPathMatcherFileFilter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/file/SpringFileAntPathMatcherFileFilterTest-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/file/SpringFileAntPathMatcherFileFilterTest-context.xml?rev=738487&r1=738486&r2=738487&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/file/SpringFileAntPathMatcherFileFilterTest-context.xml
(original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/file/SpringFileAntPathMatcherFileFilterTest-context.xml
Wed Jan 28 13:52:29 2009
@@ -35,7 +35,7 @@
         </route>
     </camelContext>
 
-    <!-- we use the AntPathMatcherFileFilter to use ant paths for includes and exlucde
-->
+    <!-- we use the antpath file filter to use ant paths for includes and exlucde -->
     <bean id="myAntFilter" class="org.apache.camel.component.file.AntPathMatcherGenericFileFilter">
         <!-- include and file in the subfolder that has day in the name -->
         <property name="includes" value="**/subfolder/**/*day*"/>



Mime
View raw message