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