1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package ch.qos.logback.core.joran;
16
17 import ch.qos.logback.core.Context;
18 import ch.qos.logback.core.joran.util.PropertySetter;
19 import ch.qos.logback.core.joran.util.beans.BeanDescriptionCache;
20 import ch.qos.logback.core.model.Model;
21 import ch.qos.logback.core.model.ParamModel;
22 import ch.qos.logback.core.model.processor.ModelHandlerBase;
23 import ch.qos.logback.core.model.processor.ModelHandlerException;
24 import ch.qos.logback.core.model.processor.ModelInterpretationContext;
25
26 public class ParamModelHandler extends ModelHandlerBase {
27
28 private final BeanDescriptionCache beanDescriptionCache;
29
30 public ParamModelHandler(Context context, BeanDescriptionCache beanDescriptionCache) {
31 super(context);
32 this.beanDescriptionCache = beanDescriptionCache;
33 }
34
35 static public ModelHandlerBase makeInstance(Context context, ModelInterpretationContext ic) {
36 return new ParamModelHandler(context, ic.getBeanDescriptionCache());
37 }
38
39 @Override
40 protected Class<ParamModel> getSupportedModelClass() {
41 return ParamModel.class;
42 }
43
44 @Override
45 public void handle(ModelInterpretationContext mic, Model model) throws ModelHandlerException {
46
47 ParamModel paramModel = (ParamModel) model;
48
49 String valueStr = mic.subst(paramModel.getValue());
50
51 Object o = mic.peekObject();
52
53 PropertySetter propSetter = new PropertySetter(beanDescriptionCache, o);
54 propSetter.setContext(context);
55
56
57 String finalName = mic.subst(paramModel.getName());
58 propSetter.setProperty(finalName, valueStr);
59 }
60
61 }