1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.classic.joran.action;
15
16 import org.xml.sax.Attributes;
17
18 import ch.qos.logback.core.joran.action.BaseModelAction;
19 import ch.qos.logback.core.joran.action.PreconditionValidator;
20 import ch.qos.logback.core.joran.spi.SaxEventInterpretationContext;
21 import ch.qos.logback.core.model.InsertFromJNDIModel;
22 import ch.qos.logback.core.model.Model;
23
24
25
26
27
28
29
30 public class InsertFromJNDIAction extends BaseModelAction {
31
32 public static final String ENV_ENTRY_NAME_ATTR = "env-entry-name";
33 public static final String AS_ATTR = "as";
34
35 @Override
36 protected Model buildCurrentModel(SaxEventInterpretationContext interpretationContext, String name,
37 Attributes attributes) {
38 InsertFromJNDIModel ifjm = new InsertFromJNDIModel();
39 ifjm.setEnvEntryName(attributes.getValue(ENV_ENTRY_NAME_ATTR));
40 ifjm.setAs(attributes.getValue(AS_ATTR));
41 ifjm.setScopeStr(attributes.getValue(SCOPE_ATTRIBUTE));
42
43 return ifjm;
44 }
45
46 @Override
47 protected boolean validPreconditions(SaxEventInterpretationContext seic, String name, Attributes attributes) {
48 PreconditionValidator validator = new PreconditionValidator(this, seic, name, attributes);
49 validator.generic(ENV_ENTRY_NAME_ATTR);
50 validator.generic(AS_ATTR);
51
52 return validator.isValid();
53 }
54
55 }