1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.apache.camel.component.mina; |
18 |
|
|
19 |
|
import java.net.SocketAddress; |
20 |
|
|
21 |
|
import org.apache.camel.Consumer; |
22 |
|
import org.apache.camel.Processor; |
23 |
|
import org.apache.camel.Producer; |
24 |
|
import org.apache.camel.impl.DefaultEndpoint; |
25 |
|
import org.apache.mina.common.IoAcceptor; |
26 |
|
import org.apache.mina.common.IoConnector; |
27 |
|
import org.apache.mina.common.IoServiceConfig; |
28 |
|
import org.apache.mina.common.IoSession; |
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
2 |
public class MinaEndpoint extends DefaultEndpoint<MinaExchange> { |
34 |
|
private final IoAcceptor acceptor; |
35 |
|
private final SocketAddress address; |
36 |
|
private final IoConnector connector; |
37 |
|
private final IoServiceConfig config; |
38 |
|
|
39 |
|
public MinaEndpoint(String endpointUri, MinaComponent component, SocketAddress address, IoAcceptor acceptor, IoConnector connector, IoServiceConfig config) { |
40 |
2 |
super(endpointUri, component); |
41 |
2 |
this.config = config; |
42 |
2 |
this.address = address; |
43 |
2 |
this.acceptor = acceptor; |
44 |
2 |
this.connector = connector; |
45 |
2 |
} |
46 |
|
|
47 |
|
public Producer<MinaExchange> createProducer() throws Exception { |
48 |
2 |
return new MinaProducer(this); |
49 |
|
} |
50 |
|
|
51 |
|
public Consumer<MinaExchange> createConsumer(Processor processor) throws Exception { |
52 |
2 |
return new MinaConsumer(this, processor); |
53 |
|
} |
54 |
|
|
55 |
|
public MinaExchange createExchange() { |
56 |
2 |
return new MinaExchange(getContext()); |
57 |
|
} |
58 |
|
|
59 |
|
public MinaExchange createExchange(IoSession session, Object object) { |
60 |
2 |
MinaExchange exchange = new MinaExchange(getContext()); |
61 |
2 |
exchange.getIn().setBody(object); |
62 |
|
|
63 |
2 |
return exchange; |
64 |
|
} |
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
public IoAcceptor getAcceptor() { |
69 |
2 |
return acceptor; |
70 |
|
} |
71 |
|
|
72 |
|
public SocketAddress getAddress() { |
73 |
4 |
return address; |
74 |
|
} |
75 |
|
|
76 |
|
public IoConnector getConnector() { |
77 |
2 |
return connector; |
78 |
|
} |
79 |
|
|
80 |
|
public IoServiceConfig getConfig() { |
81 |
4 |
return config; |
82 |
|
} |
83 |
|
|
84 |
|
public boolean isSingleton() { |
85 |
2 |
return true; |
86 |
|
} |
87 |
|
|
88 |
|
} |