-
Notifications
You must be signed in to change notification settings - Fork 1
/
Activator.java
105 lines (91 loc) · 3.41 KB
/
Activator.java
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
104
105
/*******************************************************************************
* Copyright (c) 2012 Egon Willighagen <egonw@users.sf.net>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contact: http://www.bioclipse.net/
******************************************************************************/
package net.bioclipse.conceptwiki;
import net.bioclipse.conceptwiki.business.IConceptwikiManager;
import net.bioclipse.conceptwiki.business.IJavaConceptwikiManager;
import net.bioclipse.conceptwiki.business.IJavaScriptConceptwikiManager;
import org.apache.log4j.Logger;
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 {
private static final Logger logger = Logger.getLogger(Activator.class);
// The shared instance
private static Activator plugin;
// Trackers for getting the managers
private ServiceTracker javaFinderTracker;
private ServiceTracker jsFinderTracker;
public Activator() {
}
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
javaFinderTracker
= new ServiceTracker( context,
IJavaConceptwikiManager.class.getName(),
null );
javaFinderTracker.open();
jsFinderTracker
= new ServiceTracker( context,
IJavaScriptConceptwikiManager.class.getName(),
null );
jsFinderTracker.open();
}
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
public IConceptwikiManager getJavaConceptwikiManager() {
IConceptwikiManager manager = null;
try {
manager = (IConceptwikiManager)
javaFinderTracker.waitForService(1000*10);
}
catch (InterruptedException e) {
throw new IllegalStateException(
"Could not get the Java ConceptwikiManager",
e );
}
if (manager == null) {
throw new IllegalStateException(
"Could not get the Java ConceptwikiManager");
}
return manager;
}
public IJavaScriptConceptwikiManager getJavaScriptConceptwikiManager() {
IJavaScriptConceptwikiManager manager = null;
try {
manager = (IJavaScriptConceptwikiManager)
jsFinderTracker.waitForService(1000*10);
}
catch (InterruptedException e) {
throw new IllegalStateException(
"Could not get the JavaScript ConceptwikiManager",
e );
}
if (manager == null) {
throw new IllegalStateException(
"Could not get the JavaScript ConceptwikiManager");
}
return manager;
}
}