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 |
6 |
public class JbiEndpoint extends DefaultEndpoint<Exchange> { |
35 |
|
private Processor toJbiProcessor; |
36 |
|
private final CamelJbiComponent jbiComponent; |
37 |
|
|
38 |
|
public JbiEndpoint(CamelJbiComponent jbiComponent, String uri) { |
39 |
3 |
super(uri, jbiComponent); |
40 |
3 |
this.jbiComponent = jbiComponent; |
41 |
3 |
toJbiProcessor = new ToJbiProcessor(jbiComponent.getBinding(), jbiComponent.getComponentContext(), uri); |
42 |
3 |
} |
43 |
|
|
44 |
|
public Producer<Exchange> createProducer() throws Exception { |
45 |
3 |
return new DefaultProducer<Exchange>(this) { |
46 |
3 |
public void process(Exchange exchange) throws Exception { |
47 |
3 |
toJbiProcessor.process(exchange); |
48 |
3 |
} |
49 |
|
}; |
50 |
|
} |
51 |
|
|
52 |
|
public Consumer<Exchange> createConsumer(final Processor processor) throws Exception { |
53 |
1 |
return new DefaultConsumer<Exchange>(this, processor) { |
54 |
|
CamelJbiEndpoint jbiEndpoint; |
55 |
|
|
56 |
|
@Override |
57 |
|
protected void doStart() throws Exception { |
58 |
1 |
super.doStart(); |
59 |
1 |
jbiEndpoint = jbiComponent.activateJbiEndpoint(JbiEndpoint.this, processor); |
60 |
1 |
} |
61 |
|
|
62 |
|
@Override |
63 |
1 |
protected void doStop() throws Exception { |
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
1 |
super.doStop(); |
70 |
1 |
} |
71 |
|
}; |
72 |
|
} |
73 |
|
|
74 |
|
|
75 |
|
public JbiExchange createExchange() { |
76 |
2 |
return new JbiExchange(getContext(), getBinding()); |
77 |
|
} |
78 |
|
|
79 |
|
public JbiBinding getBinding() { |
80 |
2 |
return jbiComponent.getBinding(); |
81 |
|
} |
82 |
|
|
83 |
|
public boolean isSingleton() { |
84 |
3 |
return true; |
85 |
|
} |
86 |
|
|
87 |
|
} |