1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.access.common.joran;
15
16 import ch.qos.logback.access.common.model.processor.LogbackAccessDefaultNestedComponentRegistryRules;
17 import ch.qos.logback.access.common.spi.IAccessEvent;
18 import ch.qos.logback.access.common.joran.action.ConfigurationAction;
19 import ch.qos.logback.core.joran.JoranConfiguratorBase;
20 import ch.qos.logback.core.joran.action.AppenderRefAction;
21 import ch.qos.logback.core.joran.action.IncludeAction;
22 import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry;
23 import ch.qos.logback.core.joran.spi.ElementSelector;
24 import ch.qos.logback.core.joran.spi.RuleStore;
25 import ch.qos.logback.core.model.processor.DefaultProcessor;
26
27
28
29
30
31
32 public class JoranConfigurator extends JoranConfiguratorBase<IAccessEvent> {
33
34 @Override
35 public void addElementSelectorAndActionAssociations(RuleStore rs) {
36 super.addElementSelectorAndActionAssociations(rs);
37
38 rs.addRule(new ElementSelector("configuration"), () -> new ConfigurationAction());
39 rs.addRule(new ElementSelector("configuration/appender-ref"), () -> new AppenderRefAction());
40 rs.addRule(new ElementSelector("configuration/include"), () -> new IncludeAction());
41 }
42
43 @Override
44 protected void addModelHandlerAssociations(DefaultProcessor defaultProcessor) {
45
46 ModelClassToModelHandlerLinker mham = new ModelClassToModelHandlerLinker(context);
47 mham.link(defaultProcessor);
48
49 }
50
51
52 @Override
53 protected void addDefaultNestedComponentRegistryRules(DefaultNestedComponentRegistry registry) {
54 LogbackAccessDefaultNestedComponentRegistryRules.addDefaultNestedComponentRegistryRules(registry);
55 }
56
57 private JoranConfigurator makeAnotherInstance() {
58 JoranConfigurator jc = new JoranConfigurator();
59 jc.setContext(context);
60 return jc;
61 }
62
63 public void buildModelInterpretationContext() {
64 super.buildModelInterpretationContext();
65 this.modelInterpretationContext.setConfiguratorSupplier( () -> this.makeAnotherInstance() );
66 }
67 }