Mercurial > projects > dwt2
comparison org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/JobActivator.d @ 12:bc29606a740c
Added dwt-addons in original directory structure of eclipse.org
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 14 Mar 2009 18:23:29 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
11:43904fec5dca | 12:bc29606a740c |
---|---|
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 org.eclipse.core.internal.jobs.JobActivator; | |
14 | |
15 import java.lang.all; | |
16 import java.util.Set; | |
17 | |
18 // import org.osgi.framework.BundleActivator; | |
19 // import org.osgi.framework.BundleContext; | |
20 // import org.osgi.framework.ServiceRegistration; | |
21 | |
22 import org.eclipse.core.runtime.jobs.IJobManager; | |
23 | |
24 /** | |
25 * The Jobs plugin class. | |
26 */ | |
27 public class JobActivator /+: BundleActivator+/ { | |
28 | |
29 /** | |
30 * Eclipse property. Set to <code>false</code> to avoid registering JobManager | |
31 * as an OSGi service. | |
32 */ | |
33 private static const String PROP_REGISTER_JOB_SERVICE = "eclipse.service.jobs"; //$NON-NLS-1$ | |
34 /++ | |
35 /** | |
36 * The bundle associated this plug-in | |
37 */ | |
38 private static BundleContext bundleContext; | |
39 | |
40 /** | |
41 * This plugin provides a JobManager service. | |
42 */ | |
43 private ServiceRegistration jobManagerService = null; | |
44 | |
45 /** | |
46 * This method is called upon plug-in activation | |
47 */ | |
48 public void start(BundleContext context) throws Exception { | |
49 bundleContext = context; | |
50 JobOSGiUtils.getDefault().openServices(); | |
51 | |
52 bool shouldRegister = !"false".equalsIgnoreCase(context.getProperty(PROP_REGISTER_JOB_SERVICE)); //$NON-NLS-1$ | |
53 if (shouldRegister) | |
54 registerServices(); | |
55 } | |
56 | |
57 /** | |
58 * This method is called when the plug-in is stopped | |
59 */ | |
60 public void stop(BundleContext context) throws Exception { | |
61 unregisterServices(); | |
62 JobManager.shutdown(); | |
63 JobOSGiUtils.getDefault().closeServices(); | |
64 bundleContext = null; | |
65 } | |
66 | |
67 static BundleContext getContext() { | |
68 return bundleContext; | |
69 } | |
70 | |
71 private void registerServices() { | |
72 jobManagerService = bundleContext.registerService(IJobManager.class.getName(), JobManager.getInstance(), new Hashtable()); | |
73 } | |
74 | |
75 private void unregisterServices() { | |
76 if (jobManagerService !is null) { | |
77 jobManagerService.unregister(); | |
78 jobManagerService = null; | |
79 } | |
80 } | |
81 ++/ | |
82 } |