1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package ch.qos.logback.classic.joran;
16
17 import ch.qos.logback.classic.model.*;
18 import ch.qos.logback.classic.model.processor.*;
19 import ch.qos.logback.core.Context;
20 import ch.qos.logback.core.joran.ModelClassToModelHandlerLinkerBase;
21 import ch.qos.logback.core.model.AppenderModel;
22 import ch.qos.logback.core.model.AppenderRefModel;
23 import ch.qos.logback.core.model.InsertFromJNDIModel;
24 import ch.qos.logback.core.model.ModelHandlerFactoryMethod;
25 import ch.qos.logback.core.model.processor.AppenderModelHandler;
26 import ch.qos.logback.core.model.processor.AppenderRefDependencyAnalyser;
27 import ch.qos.logback.core.model.processor.AppenderRefModelHandler;
28 import ch.qos.logback.core.model.processor.DefaultProcessor;
29 import ch.qos.logback.core.model.processor.InsertFromJNDIModelHandler;
30 import ch.qos.logback.core.model.processor.RefContainerDependencyAnalyser;
31
32
33
34
35
36
37
38
39
40
41 public class ModelClassToModelHandlerLinker extends ModelClassToModelHandlerLinkerBase {
42
43 public ModelClassToModelHandlerLinker(Context context) {
44 super(context);
45 }
46
47 ModelHandlerFactoryMethod configurationModelHandlerFactoryMethod;
48
49 @Override
50 public void link(DefaultProcessor defaultProcessor) {
51 super.link(defaultProcessor);
52 defaultProcessor.addHandler(ConfigurationModel.class, getConfigurationModelHandlerFactoryMethod());
53 defaultProcessor.addHandler(ContextNameModel.class, ContextNameModelHandler::makeInstance);
54 defaultProcessor.addHandler(LoggerContextListenerModel.class, LoggerContextListenerModelHandler::makeInstance);
55
56 defaultProcessor.addHandler(PropertiesConfiguratorModel.class, PropertiesConfiguratorModelHandler::makeInstance);
57 defaultProcessor.addHandler(InsertFromJNDIModel.class, InsertFromJNDIModelHandler::makeInstance);
58
59 defaultProcessor.addHandler(AppenderModel.class, AppenderModelHandler::makeInstance);
60 defaultProcessor.addHandler(AppenderRefModel.class, AppenderRefModelHandler::makeInstance);
61 defaultProcessor.addHandler(RootLoggerModel.class, RootLoggerModelHandler::makeInstance);
62 defaultProcessor.addHandler(LoggerModel.class, LoggerModelHandler::makeInstance);
63 defaultProcessor.addHandler(LevelModel.class, LevelModelHandler::makeInstance);
64
65 defaultProcessor.addAnalyser(LoggerModel.class,
66 () -> new RefContainerDependencyAnalyser(context, LoggerModel.class));
67
68 defaultProcessor.addAnalyser(RootLoggerModel.class,
69 () -> new RefContainerDependencyAnalyser(context, RootLoggerModel.class));
70
71 defaultProcessor.addAnalyser(AppenderModel.class,
72 () -> new RefContainerDependencyAnalyser(context, AppenderModel.class));
73
74 defaultProcessor.addAnalyser(AppenderRefModel.class, () -> new AppenderRefDependencyAnalyser(context));
75
76 sealModelFilters(defaultProcessor);
77
78 }
79
80 public ModelHandlerFactoryMethod getConfigurationModelHandlerFactoryMethod() {
81 if(configurationModelHandlerFactoryMethod == null) {
82
83 return ConfigurationModelHandler::makeInstance;
84 } else {
85
86 return configurationModelHandlerFactoryMethod;
87 }
88 }
89
90
91
92
93
94
95 public void setConfigurationModelHandlerFactoryMethod(ModelHandlerFactoryMethod cmhfm) {
96
97 this.configurationModelHandlerFactoryMethod = cmhfm;
98 }
99
100 }