1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.apache.camel.builder; |
18 |
|
|
19 |
|
import org.apache.camel.Processor; |
20 |
|
import org.apache.camel.processor.Logger; |
21 |
|
import org.apache.camel.processor.LoggingErrorHandler; |
22 |
|
import org.apache.camel.processor.LoggingLevel; |
23 |
|
import org.apache.camel.processor.ErrorHandlerSupport; |
24 |
|
import org.apache.commons.logging.Log; |
25 |
|
import org.apache.commons.logging.LogFactory; |
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
public class LoggingErrorHandlerBuilder extends ErrorHandlerBuilderSupport { |
33 |
3 |
private Log log = LogFactory.getLog(Logger.class); |
34 |
3 |
private LoggingLevel level = LoggingLevel.INFO; |
35 |
|
|
36 |
0 |
public LoggingErrorHandlerBuilder() { |
37 |
0 |
} |
38 |
|
|
39 |
3 |
public LoggingErrorHandlerBuilder(Log log) { |
40 |
3 |
this.log = log; |
41 |
3 |
} |
42 |
|
|
43 |
0 |
public LoggingErrorHandlerBuilder(Log log, LoggingLevel level) { |
44 |
0 |
this.log = log; |
45 |
0 |
this.level = level; |
46 |
0 |
} |
47 |
|
|
48 |
|
public ErrorHandlerBuilder copy() { |
49 |
0 |
LoggingErrorHandlerBuilder answer = new LoggingErrorHandlerBuilder(); |
50 |
0 |
answer.setLog(getLog()); |
51 |
0 |
answer.setLevel(getLevel()); |
52 |
0 |
return answer; |
53 |
|
} |
54 |
|
|
55 |
|
public Processor createErrorHandler(Processor processor) { |
56 |
3 |
LoggingErrorHandler handler = new LoggingErrorHandler(processor, log, level); |
57 |
3 |
configure(handler); |
58 |
3 |
return handler; |
59 |
|
} |
60 |
|
|
61 |
|
public LoggingLevel getLevel() { |
62 |
0 |
return level; |
63 |
|
} |
64 |
|
|
65 |
|
public void setLevel(LoggingLevel level) { |
66 |
0 |
this.level = level; |
67 |
0 |
} |
68 |
|
|
69 |
|
public Log getLog() { |
70 |
0 |
return log; |
71 |
|
} |
72 |
|
|
73 |
|
public void setLog(Log log) { |
74 |
0 |
this.log = log; |
75 |
0 |
} |
76 |
|
} |