1 package net.sf.appstatus.core.services;
2
3 public abstract class AbstractServiceMonitor implements IServiceMonitor {
4
5 private final boolean useThreadLocal;
6
7
8
9
10
11
12 public AbstractServiceMonitor(boolean useThreadLocal) {
13 this.useThreadLocal = useThreadLocal;
14 }
15
16 public void beginCall(Object... parameters) {
17 if (useThreadLocal) {
18 IServiceMonitor current = ServiceMonitorLocator.getCurrentServiceMonitor();
19 if (null != current) {
20 current.nestedCall();
21 }
22
23 ServiceMonitorLocator.getServiceMonitorStack().push(this);
24 }
25 }
26
27 public void endCall() {
28 if (useThreadLocal) {
29 ServiceMonitorLocator.getServiceMonitorStack().remove(this);
30 }
31 }
32
33 }