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