blob: 13387378fd1a391e768fb6ab71817900d00a769f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
package org.eclipse.ecf.internal.docshare;
import org.eclipse.ecf.internal.provisional.docshare.DocShare;
import java.util.Hashtable;
import org.eclipse.ecf.core.IContainerManager;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.util.ECFException;
import org.eclipse.ecf.datashare.IChannelContainerAdapter;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import org.osgi.util.tracker.ServiceTracker;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.ecf.internal.provisional.docshare"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
private BundleContext context;
private ServiceTracker containerManagerTracker;
private boolean listenerActive;
private static final Hashtable docsharechannels = new Hashtable();
public DocShare getDocShare(ID containerID) {
return (DocShare) docsharechannels.get(containerID);
}
public DocShare addDocShare(ID containerID, IChannelContainerAdapter channelAdapter) throws ECFException {
return (DocShare) docsharechannels.put(containerID, new DocShare(channelAdapter));
}
public DocShare removeDocShare(ID containerID) {
return (DocShare) docsharechannels.remove(containerID);
}
/**
* The constructor
*/
public Activator() {
// nothing to do
}
public boolean isListenerActive() {
return listenerActive;
}
public void setListenerActive(boolean active) {
this.listenerActive = active;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext ctxt) throws Exception {
super.start(ctxt);
plugin = this;
this.context = ctxt;
setListenerActive(true);
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext ctxt) throws Exception {
super.stop(ctxt);
if (containerManagerTracker != null) {
containerManagerTracker.close();
containerManagerTracker = null;
}
plugin = null;
this.context = null;
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
public IContainerManager getContainerManager() {
if (containerManagerTracker == null) {
containerManagerTracker = new ServiceTracker(context, IContainerManager.class.getName(), null);
containerManagerTracker.open();
}
return (IContainerManager) containerManagerTracker.getService();
}
}
|