1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.core.joran.action;
15
16 import ch.qos.logback.core.model.processor.ModelInterpretationContext;
17 import ch.qos.logback.core.spi.ContextAwarePropertyContainer;
18 import ch.qos.logback.core.util.OptionHelper;
19
20 public class ActionUtil {
21
22 public enum Scope {
23 LOCAL, CONTEXT, SYSTEM
24 };
25
26
27
28
29
30
31
32 static public Scope stringToScope(String scopeStr) {
33 if (Scope.SYSTEM.toString().equalsIgnoreCase(scopeStr))
34 return Scope.SYSTEM;
35 if (Scope.CONTEXT.toString().equalsIgnoreCase(scopeStr))
36 return Scope.CONTEXT;
37
38 return Scope.LOCAL;
39 }
40
41
42 static public void setProperty(ContextAwarePropertyContainer ic, String key, String value, Scope scope) {
43 switch (scope) {
44 case LOCAL:
45 ic.addSubstitutionProperty(key, value);
46 break;
47 case CONTEXT:
48 ic.getContext().putProperty(key, value);
49 break;
50 case SYSTEM:
51 OptionHelper.setSystemProperty(ic, key, value);
52 }
53 }
54 }