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