1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.core;
15
16 import java.util.HashMap;
17 import java.util.Map;
18
19 import ch.qos.logback.core.status.StatusManager;
20
21 public class ContextBase implements Context {
22
23 private long birthTime = System.currentTimeMillis();
24
25 private String name;
26 private StatusManager sm = new BasicStatusManager();
27
28
29
30 Map<String, String> propertyMap = new HashMap<String, String>();
31 Map<String, Object> objectMap = new HashMap<String, Object>();
32
33 Object configurationLock = new Object();
34
35 public StatusManager getStatusManager() {
36 return sm;
37 }
38
39
40
41
42
43
44
45
46
47
48
49
50 public void setStatusManager(StatusManager statusManager) {
51
52 if (sm == null) {
53 throw new IllegalArgumentException("null StatusManager not allowed");
54 }
55 this.sm = statusManager;
56 }
57
58 public Map<String, String> getCopyOfPropertyMap() {
59 return new HashMap<String, String>(propertyMap);
60 }
61
62 public void putProperty(String key, String val) {
63 this.propertyMap.put(key, val);
64 }
65
66 public String getProperty(String key) {
67 return (String) this.propertyMap.get(key);
68 }
69
70 public Object getObject(String key) {
71 return objectMap.get(key);
72 }
73
74 public void putObject(String key, Object value) {
75 objectMap.put(key, value);
76 }
77
78 public String getName() {
79 return name;
80 }
81
82
83
84
85 public void reset() {
86 propertyMap.clear();
87 objectMap.clear();
88 }
89
90
91
92
93
94
95
96
97
98 public void setName(String name) throws IllegalStateException {
99 if (name != null && name.equals(this.name)) {
100 return;
101 }
102 if (this.name == null
103 || CoreConstants.DEFAULT_CONTEXT_NAME.equals(this.name)) {
104 this.name = name;
105 } else {
106 throw new IllegalStateException("Context has been already given a name");
107 }
108 }
109
110 public long getBithTime() {
111 return birthTime;
112 }
113
114 public Object getConfigurationLock() {
115 return configurationLock;
116 }
117 }