1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.apache.camel.impl; |
18 |
|
|
19 |
|
import org.apache.camel.CamelContext; |
20 |
|
import org.apache.camel.Component; |
21 |
|
import org.apache.camel.Consumer; |
22 |
|
import org.apache.camel.Exchange; |
23 |
|
import org.apache.camel.Processor; |
24 |
|
import org.apache.camel.Producer; |
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
public class ProcessorEndpoint extends DefaultEndpoint<Exchange> { |
34 |
|
private final Processor processor; |
35 |
|
|
36 |
|
public ProcessorEndpoint(String endpointUri, CamelContext context, Processor processor) { |
37 |
0 |
super(endpointUri, context); |
38 |
0 |
this.processor = processor; |
39 |
0 |
} |
40 |
|
|
41 |
|
public ProcessorEndpoint(String endpointUri, Component component, Processor processor) { |
42 |
15 |
super(endpointUri, component); |
43 |
15 |
this.processor = processor; |
44 |
15 |
} |
45 |
|
|
46 |
|
public Exchange createExchange() { |
47 |
9 |
return new DefaultExchange(getContext()); |
48 |
|
} |
49 |
|
|
50 |
|
public Producer<Exchange> createProducer() throws Exception { |
51 |
15 |
return new DefaultProducer<Exchange>(this) { |
52 |
15 |
public void process(Exchange exchange) throws Exception { |
53 |
27 |
onExchange(exchange); |
54 |
27 |
} |
55 |
|
}; |
56 |
|
} |
57 |
|
|
58 |
|
public Consumer<Exchange> createConsumer(Processor processor) throws Exception { |
59 |
0 |
throw new UnsupportedOperationException("You cannot consume from this endpoint!"); |
60 |
|
} |
61 |
|
|
62 |
|
public Processor getProcessor() { |
63 |
0 |
return processor; |
64 |
|
} |
65 |
|
|
66 |
|
protected void onExchange(Exchange exchange) throws Exception { |
67 |
27 |
processor.process(exchange); |
68 |
27 |
} |
69 |
|
|
70 |
|
public boolean isSingleton() { |
71 |
15 |
return true; |
72 |
|
} |
73 |
|
} |