1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
package org.apache.camel.component.xmpp; |
19 |
|
|
20 |
|
import com.sun.jndi.toolkit.url.Uri; |
21 |
|
import org.apache.camel.CamelContext; |
22 |
|
import org.apache.camel.Endpoint; |
23 |
|
import org.apache.camel.impl.DefaultComponent; |
24 |
|
import org.apache.camel.util.IntrospectionSupport; |
25 |
|
import org.apache.camel.util.ObjectHelper; |
26 |
|
import org.apache.camel.util.URISupport; |
27 |
|
|
28 |
|
import java.net.URI; |
29 |
|
import java.net.URISyntaxException; |
30 |
|
import java.util.Map; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
public class XmppComponent extends DefaultComponent<XmppExchange> { |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
public static XmppComponent xmppComponent() { |
40 |
0 |
return new XmppComponent(); |
41 |
|
} |
42 |
|
|
43 |
2 |
public XmppComponent() { |
44 |
2 |
} |
45 |
|
|
46 |
|
public XmppComponent(CamelContext context) { |
47 |
0 |
super(context); |
48 |
0 |
} |
49 |
|
|
50 |
|
@Override |
51 |
|
protected Endpoint<XmppExchange> createEndpoint(String uri, String remaining, Map parameters) throws Exception { |
52 |
2 |
XmppEndpoint endpoint = new XmppEndpoint(uri, this); |
53 |
|
|
54 |
2 |
URI u = new URI(uri); |
55 |
2 |
endpoint.setHost(u.getHost()); |
56 |
2 |
endpoint.setPort(u.getPort()); |
57 |
2 |
if (u.getUserInfo() != null) { |
58 |
2 |
endpoint.setUser(u.getUserInfo()); |
59 |
|
} |
60 |
2 |
String remainingPath = u.getPath(); |
61 |
2 |
if (remainingPath != null) { |
62 |
2 |
if (remainingPath.startsWith("/")) { |
63 |
1 |
remainingPath = remainingPath.substring(1); |
64 |
|
} |
65 |
|
|
66 |
|
|
67 |
2 |
if (remainingPath.length() > 0) { |
68 |
1 |
endpoint.setParticipant(remainingPath); |
69 |
|
} |
70 |
|
} |
71 |
2 |
return endpoint; |
72 |
|
} |
73 |
|
} |