comparison dwtx/core/internal/jobs/JobActivator.d @ 122:9d0585bcb7aa

Add core.jobs package
author Frank Benoit <benoit@tionex.de>
date Tue, 12 Aug 2008 02:34:21 +0200
parents
children
comparison
equal deleted inserted replaced
121:c0304616ea23 122:9d0585bcb7aa
1 /*******************************************************************************
2 * Copyright (c) 2005, 2006 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/
13 module dwtx.core.internal.jobs.JobActivator;
14
15 import dwt.dwthelper.utils;
16
17 // import org.osgi.framework.BundleActivator;
18 // import org.osgi.framework.BundleContext;
19 // import org.osgi.framework.ServiceRegistration;
20
21 import dwtx.core.runtime.jobs.IJobManager;
22
23 /**
24 * The Jobs plugin class.
25 */
26 public class JobActivator /+: BundleActivator+/ {
27
28 /**
29 * Eclipse property. Set to <code>false</code> to avoid registering JobManager
30 * as an OSGi service.
31 */
32 private static const String PROP_REGISTER_JOB_SERVICE = "eclipse.service.jobs"; //$NON-NLS-1$
33 /++
34 /**
35 * The bundle associated this plug-in
36 */
37 private static BundleContext bundleContext;
38
39 /**
40 * This plugin provides a JobManager service.
41 */
42 private ServiceRegistration jobManagerService = null;
43
44 /**
45 * This method is called upon plug-in activation
46 */
47 public void start(BundleContext context) throws Exception {
48 bundleContext = context;
49 JobOSGiUtils.getDefault().openServices();
50
51 bool shouldRegister = !"false".equalsIgnoreCase(context.getProperty(PROP_REGISTER_JOB_SERVICE)); //$NON-NLS-1$
52 if (shouldRegister)
53 registerServices();
54 }
55
56 /**
57 * This method is called when the plug-in is stopped
58 */
59 public void stop(BundleContext context) throws Exception {
60 unregisterServices();
61 JobManager.shutdown();
62 JobOSGiUtils.getDefault().closeServices();
63 bundleContext = null;
64 }
65
66 static BundleContext getContext() {
67 return bundleContext;
68 }
69
70 private void registerServices() {
71 jobManagerService = bundleContext.registerService(IJobManager.class.getName(), JobManager.getInstance(), new Hashtable());
72 }
73
74 private void unregisterServices() {
75 if (jobManagerService !is null) {
76 jobManagerService.unregister();
77 jobManagerService = null;
78 }
79 }
80 ++/
81 }