You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by js...@apache.org on 2007/03/30 20:19:19 UTC
svn commit: r524222 - in /activemq/camel/trunk/camel-spring/src/main:
java/org/apache/camel/spring/converter/
java/org/apache/camel/spring/converter/ResourceConverter.java
resources/org/apache/camel/TypeConverter
Author: jstrachan
Date: Fri Mar 30 11:19:18 2007
New Revision: 524222
URL: http://svn.apache.org/viewvc?view=rev&rev=524222
Log:
added converters to/from Spring's Resources
Added:
activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/converter/
activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/converter/ResourceConverter.java (with props)
activemq/camel/trunk/camel-spring/src/main/resources/org/apache/camel/TypeConverter
Added: activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/converter/ResourceConverter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/converter/ResourceConverter.java?view=auto&rev=524222
==============================================================================
--- activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/converter/ResourceConverter.java (added)
+++ activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/converter/ResourceConverter.java Fri Mar 30 11:19:18 2007
@@ -0,0 +1,73 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.converter;
+
+import org.apache.camel.Converter;
+import org.springframework.core.io.ByteArrayResource;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.UrlResource;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+/**
+ * Some Spring based
+ * <a href="http://activemq.apache.org/camel/type-converter.html">Type Converters</a>
+ *
+ * @version $Revision$
+ */
+@Converter
+public class ResourceConverter {
+ @Converter
+ public static InputStream toInputStream(Resource resource) throws IOException {
+ return resource.getInputStream();
+ }
+
+ @Converter
+ public static File toFile(Resource resource) throws IOException {
+ return resource.getFile();
+ }
+
+ @Converter
+ public static URL toUrl(Resource resource) throws IOException {
+ return resource.getURL();
+ }
+
+ @Converter
+ public static UrlResource toResource(String uri) throws IOException {
+ return new UrlResource(uri);
+ }
+
+ @Converter
+ public static UrlResource toResource(URL uri) throws IOException {
+ return new UrlResource(uri);
+ }
+
+ @Converter
+ public static FileSystemResource toResource(File file) throws IOException {
+ return new FileSystemResource(file);
+ }
+
+ @Converter
+ public static ByteArrayResource toResource(byte[] data) throws IOException {
+ return new ByteArrayResource(data);
+ }
+}
Propchange: activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/converter/ResourceConverter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/converter/ResourceConverter.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: activemq/camel/trunk/camel-spring/src/main/java/org/apache/camel/spring/converter/ResourceConverter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: activemq/camel/trunk/camel-spring/src/main/resources/org/apache/camel/TypeConverter
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-spring/src/main/resources/org/apache/camel/TypeConverter?view=auto&rev=524222
==============================================================================
--- activemq/camel/trunk/camel-spring/src/main/resources/org/apache/camel/TypeConverter (added)
+++ activemq/camel/trunk/camel-spring/src/main/resources/org/apache/camel/TypeConverter Fri Mar 30 11:19:18 2007
@@ -0,0 +1 @@
+org.apache.camel.spring.converter
\ No newline at end of file