1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
package org.apache.camel.component.jbi; |
19 |
|
|
20 |
|
import org.apache.camel.Consumer; |
21 |
|
import org.apache.camel.Endpoint; |
22 |
|
import org.apache.camel.Exchange; |
23 |
|
import org.apache.camel.Processor; |
24 |
|
import org.apache.camel.Producer; |
25 |
|
import org.apache.camel.impl.DefaultConsumer; |
26 |
|
import org.apache.camel.impl.DefaultEndpoint; |
27 |
|
import org.apache.camel.impl.DefaultProducer; |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
0 |
public class JbiEndpoint extends DefaultEndpoint<Exchange> { |
35 |
|
private Processor toJbiProcessor; |
36 |
|
private final CamelJbiComponent jbiComponent; |
37 |
|
|
38 |
|
public JbiEndpoint(CamelJbiComponent jbiComponent, String uri) { |
39 |
0 |
super(uri, jbiComponent); |
40 |
0 |
this.jbiComponent = jbiComponent; |
41 |
0 |
toJbiProcessor = new ToJbiProcessor(jbiComponent.getBinding(), jbiComponent.getComponentContext(), uri); |
42 |
0 |
} |
43 |
|
|
44 |
|
public Producer<Exchange> createProducer() throws Exception { |
45 |
0 |
return new DefaultProducer<Exchange>(this) { |
46 |
0 |
public void process(Exchange exchange) throws Exception { |
47 |
0 |
toJbiProcessor.process(exchange); |
48 |
0 |
} |
49 |
|
}; |
50 |
|
} |
51 |
|
|
52 |
|
public Consumer<Exchange> createConsumer(final Processor processor) throws Exception { |
53 |
0 |
return new DefaultConsumer<Exchange>(this, processor) { |
54 |
|
CamelJbiEndpoint jbiEndpoint; |
55 |
|
|
56 |
|
@Override |
57 |
|
protected void doStart() throws Exception { |
58 |
0 |
super.doStart(); |
59 |
0 |
jbiEndpoint = jbiComponent.activateJbiEndpoint(JbiEndpoint.this, processor); |
60 |
0 |
} |
61 |
|
|
62 |
|
@Override |
63 |
0 |
protected void doStop() throws Exception { |
64 |
0 |
if (jbiEndpoint != null) { |
65 |
0 |
jbiComponent.deactivateJbiEndpoint(jbiEndpoint); |
66 |
|
} |
67 |
0 |
super.doStop(); |
68 |
0 |
} |
69 |
|
}; |
70 |
|
} |
71 |
|
|
72 |
|
|
73 |
|
public JbiExchange createExchange() { |
74 |
0 |
return new JbiExchange(getContext(), getBinding()); |
75 |
|
} |
76 |
|
|
77 |
|
public JbiBinding getBinding() { |
78 |
0 |
return jbiComponent.getBinding(); |
79 |
|
} |
80 |
|
|
81 |
|
public boolean isSingleton() { |
82 |
0 |
return true; |
83 |
|
} |
84 |
|
} |