01: package logging;
02:
03: import org.eclipse.core.runtime.Plugin;
04: import org.osgi.framework.BundleContext;
05: import java.util.*;
06:
07: public class LoggingPlugin extends Plugin {
08:
09: private static LoggingPlugin plugin;
10:
11: private ArrayList logManagers = new ArrayList();
12:
13: public LoggingPlugin() {
14: super ();
15: plugin = this ;
16: }
17:
18: public static LoggingPlugin getDefault() {
19: return plugin;
20: }
21:
22: /**
23: * Iterates over the list of active log managers and shutdowns each one
24: * before calling the base class implementation.
25: * @see Plugin#stop
26: */
27: public void stop(BundleContext context) throws Exception {
28: synchronized (this .logManagers) {
29: Iterator it = this .logManagers.iterator();
30: while (it.hasNext()) {
31: PluginLogManager logManager = (PluginLogManager) it
32: .next();
33: logManager.internalShutdown();
34: }
35: this .logManagers.clear();
36: }
37: super .stop(context);
38: }
39:
40: /**
41: * Adds a log manager object to the list of active log managers
42: */
43: void addLogManager(PluginLogManager logManager) {
44: synchronized (this .logManagers) {
45: if (logManager != null)
46: this .logManagers.add(logManager);
47: }
48: }
49:
50: /**
51: * Removes a log manager object from the list of active log managers
52: */
53: void removeLogManager(PluginLogManager logManager) {
54: synchronized (this.logManagers) {
55: if (logManager != null)
56: this.logManagers.remove(logManager);
57: }
58: }
59: }
|