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.Consumer; |
20 |
|
import org.apache.camel.Endpoint; |
21 |
|
import org.apache.camel.Exchange; |
22 |
|
import org.apache.camel.Processor; |
23 |
|
import org.apache.camel.spi.ExceptionHandler; |
24 |
|
import org.apache.camel.util.ServiceHelper; |
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
public class DefaultConsumer<E extends Exchange> extends ServiceSupport implements Consumer<E> { |
30 |
|
private Endpoint<E> endpoint; |
31 |
|
private Processor processor; |
32 |
|
private ExceptionHandler exceptionHandler; |
33 |
|
|
34 |
201 |
public DefaultConsumer(Endpoint<E> endpoint, Processor processor) { |
35 |
201 |
this.endpoint = endpoint; |
36 |
201 |
this.processor = processor; |
37 |
201 |
} |
38 |
|
|
39 |
|
@Override |
40 |
|
public String toString() { |
41 |
0 |
return "Consumer on " + endpoint; |
42 |
|
} |
43 |
|
|
44 |
|
public Endpoint<E> getEndpoint() { |
45 |
15 |
return endpoint; |
46 |
|
} |
47 |
|
|
48 |
|
public Processor getProcessor() { |
49 |
621 |
return processor; |
50 |
|
} |
51 |
|
|
52 |
|
public ExceptionHandler getExceptionHandler() { |
53 |
0 |
if (exceptionHandler == null) { |
54 |
0 |
exceptionHandler = new LoggingExceptionHandler(getClass()); |
55 |
|
} |
56 |
0 |
return exceptionHandler; |
57 |
|
} |
58 |
|
|
59 |
|
public void setExceptionHandler(ExceptionHandler exceptionHandler) { |
60 |
0 |
this.exceptionHandler = exceptionHandler; |
61 |
0 |
} |
62 |
|
|
63 |
|
protected void doStop() throws Exception { |
64 |
195 |
ServiceHelper.stopServices(processor); |
65 |
195 |
} |
66 |
|
|
67 |
|
protected void doStart() throws Exception { |
68 |
198 |
ServiceHelper.startServices(processor); |
69 |
198 |
} |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
protected void handleException(Throwable t) { |
77 |
0 |
getExceptionHandler().handleException(t); |
78 |
0 |
} |
79 |
|
} |