1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
package org.apache.camel.spring.converter; |
19 |
|
|
20 |
|
import org.apache.camel.Converter; |
21 |
|
import org.springframework.core.io.ByteArrayResource; |
22 |
|
import org.springframework.core.io.FileSystemResource; |
23 |
|
import org.springframework.core.io.Resource; |
24 |
|
import org.springframework.core.io.UrlResource; |
25 |
|
|
26 |
|
import java.io.File; |
27 |
|
import java.io.IOException; |
28 |
|
import java.io.InputStream; |
29 |
|
import java.net.URL; |
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
@Converter |
38 |
0 |
public class ResourceConverter { |
39 |
|
@Converter |
40 |
|
public static InputStream toInputStream(Resource resource) throws IOException { |
41 |
0 |
return resource.getInputStream(); |
42 |
|
} |
43 |
|
|
44 |
|
@Converter |
45 |
|
public static File toFile(Resource resource) throws IOException { |
46 |
0 |
return resource.getFile(); |
47 |
|
} |
48 |
|
|
49 |
|
@Converter |
50 |
|
public static URL toUrl(Resource resource) throws IOException { |
51 |
0 |
return resource.getURL(); |
52 |
|
} |
53 |
|
|
54 |
|
@Converter |
55 |
|
public static UrlResource toResource(String uri) throws IOException { |
56 |
0 |
return new UrlResource(uri); |
57 |
|
} |
58 |
|
|
59 |
|
@Converter |
60 |
|
public static UrlResource toResource(URL uri) throws IOException { |
61 |
0 |
return new UrlResource(uri); |
62 |
|
} |
63 |
|
|
64 |
|
@Converter |
65 |
|
public static FileSystemResource toResource(File file) throws IOException { |
66 |
0 |
return new FileSystemResource(file); |
67 |
|
} |
68 |
|
|
69 |
|
@Converter |
70 |
|
public static ByteArrayResource toResource(byte[] data) throws IOException { |
71 |
0 |
return new ByteArrayResource(data); |
72 |
|
} |
73 |
|
} |