1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
package org.apache.camel.component.mail; |
19 |
|
|
20 |
|
import org.apache.camel.CamelContext; |
21 |
|
import org.apache.camel.Endpoint; |
22 |
|
import org.apache.camel.impl.DefaultComponent; |
23 |
|
import org.apache.camel.util.IntrospectionSupport; |
24 |
|
|
25 |
|
import java.util.Map; |
26 |
|
import java.net.URI; |
27 |
|
import java.net.URL; |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
public class MailComponent extends DefaultComponent<MailExchange> { |
33 |
|
public static final String QUEUE_PREFIX = "queue:"; |
34 |
|
public static final String TOPIC_PREFIX = "topic:"; |
35 |
|
private MailConfiguration configuration; |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
public static MailComponent mailComponent() { |
41 |
0 |
return new MailComponent(); |
42 |
|
} |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
public static MailComponent mailComponent(MailConfiguration configuration) { |
48 |
0 |
return new MailComponent(configuration); |
49 |
|
} |
50 |
|
|
51 |
8 |
public MailComponent() { |
52 |
8 |
this.configuration = new MailConfiguration(); |
53 |
8 |
} |
54 |
|
|
55 |
0 |
public MailComponent(MailConfiguration configuration) { |
56 |
0 |
this.configuration = configuration; |
57 |
0 |
} |
58 |
|
|
59 |
|
public MailComponent(CamelContext context) { |
60 |
0 |
super(context); |
61 |
0 |
this.configuration = new MailConfiguration(); |
62 |
0 |
} |
63 |
|
|
64 |
|
@Override |
65 |
|
protected Endpoint<MailExchange> createEndpoint(String uri, String remaining, Map parameters) throws Exception { |
66 |
|
|
67 |
12 |
MailConfiguration config = getConfiguration().copy(); |
68 |
12 |
config.configure(new URI(uri)); |
69 |
|
|
70 |
|
|
71 |
12 |
MailEndpoint endpoint = new MailEndpoint(uri, this, config); |
72 |
|
|
73 |
12 |
IntrospectionSupport.setProperties(endpoint.getConfiguration(), parameters); |
74 |
12 |
return endpoint; |
75 |
|
} |
76 |
|
|
77 |
|
public MailConfiguration getConfiguration() { |
78 |
12 |
return configuration; |
79 |
|
} |
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
public void setConfiguration(MailConfiguration configuration) { |
87 |
0 |
this.configuration = configuration; |
88 |
0 |
} |
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
protected String convertPathToActualDestination(String path) { |
95 |
0 |
return path; |
96 |
|
} |
97 |
|
} |