blob: d02c3c7788f4dccfd7a1416c4cb46d94d60d0bb9 (
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
|
/*******************************************************************************
* Copyright (c) 2004, 2007 Boeing.
* 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
*
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.framework.servlet;
import org.eclipse.osee.framework.jdk.core.util.OseeApplicationServerContext;
import org.eclipse.osee.framework.resource.common.osgi.OseeHttpServiceTracker;
import org.eclipse.osee.framework.resource.management.IResourceLocatorManager;
import org.eclipse.osee.framework.resource.management.IResourceManager;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.util.tracker.ServiceTracker;
public class Activator implements BundleActivator {
private static Activator instance;
private ServiceTracker resourceManagementTracker;
private ServiceTracker resourceLocatorManagerTracker;
private ServiceTracker servletTracker;
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
Activator.instance = this;
resourceManagementTracker = new ServiceTracker(context, IResourceManager.class.getName(), null);
resourceManagementTracker.open();
resourceLocatorManagerTracker = new ServiceTracker(context, IResourceLocatorManager.class.getName(), null);
resourceLocatorManagerTracker.open();
servletTracker =
new OseeHttpServiceTracker(context, OseeApplicationServerContext.RESOURCE_CONTEXT, ResourceManagerServlet.class);
servletTracker.open();
}
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
servletTracker.close();
servletTracker = null;
resourceManagementTracker.close();
resourceManagementTracker = null;
resourceLocatorManagerTracker.close();
resourceLocatorManagerTracker = null;
Activator.instance = null;
}
public IResourceManager getResourceManager() {
return (IResourceManager) resourceManagementTracker.getService();
}
public IResourceLocatorManager getResourceLocatorManager() {
return (IResourceLocatorManager) resourceLocatorManagerTracker.getService();
}
public static Activator getInstance() {
return Activator.instance;
}
}
|