1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.core.joran;
15
16 import ch.qos.logback.core.joran.action.*;
17 import ch.qos.logback.core.joran.conditional.ElseAction;
18 import ch.qos.logback.core.joran.conditional.IfAction;
19 import ch.qos.logback.core.joran.conditional.ThenAction;
20 import ch.qos.logback.core.joran.sanity.AppenderWithinAppenderSanityChecker;
21 import ch.qos.logback.core.joran.sanity.SanityChecker;
22 import ch.qos.logback.core.joran.spi.ElementSelector;
23 import ch.qos.logback.core.joran.spi.RuleStore;
24 import ch.qos.logback.core.joran.spi.SaxEventInterpretationContext;
25 import ch.qos.logback.core.joran.spi.SaxEventInterpreter;
26 import ch.qos.logback.core.model.*;
27 import ch.qos.logback.core.model.processor.*;
28 import ch.qos.logback.core.spi.ContextAware;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 abstract public class JoranConfiguratorBase<E> extends GenericXMLConfigurator {
44
45 @Override
46 protected void addElementSelectorAndActionAssociations(RuleStore rs) {
47
48
49 rs.addRule(new ElementSelector("*/variable"), PropertyAction::new);
50 rs.addRule(new ElementSelector("*/property"), PropertyAction::new);
51
52 rs.addRule(new ElementSelector("*/substitutionProperty"), PropertyAction::new);
53
54 rs.addRule(new ElementSelector("configuration/import"), ImportAction::new);
55
56
57 rs.addRule(new ElementSelector("configuration/timestamp"), TimestampAction::new);
58 rs.addRule(new ElementSelector("configuration/shutdownHook"), ShutdownHookAction::new);
59 rs.addRule(new ElementSelector("configuration/sequenceNumberGenerator"), SequenceNumberGeneratorAction::new);
60 rs.addRule(new ElementSelector("configuration/serializeModel"), SerializeModelAction::new);
61
62 rs.addRule(new ElementSelector("configuration/define"), DefinePropertyAction::new);
63 rs.addRule(new ElementSelector("configuration/evaluator"), EventEvaluatorAction::new);
64
65
66
67 rs.addRule(new ElementSelector("configuration/contextProperty"), ContextPropertyAction::new);
68
69 rs.addRule(new ElementSelector("configuration/conversionRule"), ConversionRuleAction::new);
70
71 rs.addRule(new ElementSelector("configuration/statusListener"), StatusListenerAction::new);
72
73 rs.addRule(new ElementSelector("*/appender"), AppenderAction::new);
74 rs.addRule(new ElementSelector("configuration/appender/appender-ref"), AppenderRefAction::new);
75 rs.addRule(new ElementSelector("configuration/newRule"), NewRuleAction::new);
76
77 rs.addRule(new ElementSelector("*/param"), ParamAction::new);
78
79
80 rs.addRule(new ElementSelector("*/if"), IfAction::new);
81 rs.addTransparentPathPart("if");
82 rs.addRule(new ElementSelector("*/if/then"), ThenAction::new);
83 rs.addTransparentPathPart("then");
84 rs.addRule(new ElementSelector("*/if/else"), ElseAction::new);
85 rs.addTransparentPathPart("else");
86
87 rs.addRule(new ElementSelector("*/appender/sift"), SiftAction::new);
88 rs.addTransparentPathPart("sift");
89
90
91 }
92
93
94
95
96
97
98 protected void sanityCheck(Model topModel) {
99 performCheck(new AppenderWithinAppenderSanityChecker(), topModel);
100 }
101
102 protected void performCheck(SanityChecker sc, Model model) {
103 if(sc instanceof ContextAware)
104 ((ContextAware) sc).setContext(context);
105 sc.check(model);
106 }
107
108 @Override
109 protected void setImplicitRuleSupplier(SaxEventInterpreter interpreter) {
110 interpreter.setImplicitActionSupplier( ImplicitModelAction::new );
111 }
112
113 @Override
114 public void buildModelInterpretationContext() {
115 super.buildModelInterpretationContext();
116 modelInterpretationContext.createAppenderBags();
117 }
118
119 public SaxEventInterpretationContext getInterpretationContext() {
120 return saxEventInterpreter.getSaxEventInterpretationContext();
121 }
122
123 @Override
124 protected void addModelHandlerAssociations(DefaultProcessor defaultProcessor) {
125
126 }
127
128 }