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