Mercurial > projects > dwt2
comparison org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/JobOSGiUtils.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 | af948d4bbf8c |
comparison
equal
deleted
inserted
replaced
11:43904fec5dca | 12:bc29606a740c |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2005, 2007 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.JobOSGiUtils; | |
14 | |
15 import java.lang.all; | |
16 import java.util.Set; | |
17 | |
18 // import org.osgi.framework.Bundle; | |
19 // import org.osgi.framework.BundleContext; | |
20 // import org.osgi.service.packageadmin.PackageAdmin; | |
21 // import org.osgi.util.tracker.ServiceTracker; | |
22 | |
23 import org.eclipse.core.runtime.jobs.IJobManager; | |
24 // import org.eclipse.osgi.service.debug.DebugOptions; | |
25 | |
26 /** | |
27 * The class contains a set of helper methods for the runtime Jobs plugin. | |
28 * The following utility methods are supplied: | |
29 * - provides access to debug options | |
30 * - provides some bundle discovery functionality | |
31 * | |
32 * The closeServices() method should be called before the plugin is stopped. | |
33 * | |
34 * @since org.eclipse.core.jobs 3.2 | |
35 */ | |
36 class JobOSGiUtils { | |
37 // private ServiceTracker debugTracker = null; | |
38 // private ServiceTracker bundleTracker = null; | |
39 | |
40 private static /+final+/ JobOSGiUtils singleton; | |
41 | |
42 /** | |
43 * Accessor for the singleton instance | |
44 * @return The JobOSGiUtils instance | |
45 */ | |
46 public static synchronized JobOSGiUtils getDefault() { | |
47 if( singleton is null ){ | |
48 singleton = new JobOSGiUtils(); | |
49 } | |
50 return singleton; | |
51 } | |
52 | |
53 /** | |
54 * Private constructor to block instance creation. | |
55 */ | |
56 private this() { | |
57 // super(); | |
58 } | |
59 | |
60 void openServices() { | |
61 implMissing(__FILE__,__LINE__); | |
62 // BundleContext context = JobActivator.getContext(); | |
63 // if (context is null) { | |
64 // if (JobManager.DEBUG) | |
65 // JobMessages.message("JobsOSGiUtils called before plugin started"); //$NON-NLS-1$ | |
66 // return; | |
67 // } | |
68 // | |
69 // debugTracker = new ServiceTracker(context, DebugOptions.class.getName(), null); | |
70 // debugTracker.open(); | |
71 // | |
72 // bundleTracker = new ServiceTracker(context, PackageAdmin.class.getName(), null); | |
73 // bundleTracker.open(); | |
74 } | |
75 | |
76 void closeServices() { | |
77 implMissing(__FILE__,__LINE__); | |
78 // if (debugTracker !is null) { | |
79 // debugTracker.close(); | |
80 // debugTracker = null; | |
81 // } | |
82 // if (bundleTracker !is null) { | |
83 // bundleTracker.close(); | |
84 // bundleTracker = null; | |
85 // } | |
86 } | |
87 | |
88 public bool getBooleanDebugOption(String option, bool defaultValue) { | |
89 implMissing(__FILE__,__LINE__); | |
90 return false; | |
91 // if (debugTracker is null) { | |
92 // if (JobManager.DEBUG) | |
93 // JobMessages.message("Debug tracker is not set"); //$NON-NLS-1$ | |
94 // return defaultValue; | |
95 // } | |
96 // DebugOptions options = (DebugOptions) debugTracker.getService(); | |
97 // if (options !is null) { | |
98 // String value = options.getOption(option); | |
99 // if (value !is null) | |
100 // return value.equalsIgnoreCase("true"); //$NON-NLS-1$ | |
101 // } | |
102 // return defaultValue; | |
103 } | |
104 | |
105 /** | |
106 * Returns the bundle id of the bundle that contains the provided object, or | |
107 * <code>null</code> if the bundle could not be determined. | |
108 */ | |
109 public String getBundleId(Object object) { | |
110 implMissing(__FILE__,__LINE__); | |
111 // if (bundleTracker is null) { | |
112 // if (JobManager.DEBUG) | |
113 // JobMessages.message("Bundle tracker is not set"); //$NON-NLS-1$ | |
114 // return null; | |
115 // } | |
116 // PackageAdmin packageAdmin = (PackageAdmin) bundleTracker.getService(); | |
117 // if (object is null) | |
118 // return null; | |
119 // if (packageAdmin is null) | |
120 // return null; | |
121 // Bundle source = packageAdmin.getBundle(object.getClass()); | |
122 // if (source !is null && source.getSymbolicName() !is null) | |
123 // return source.getSymbolicName(); | |
124 return null; | |
125 } | |
126 | |
127 /** | |
128 * Calculates whether the job plugin should set worker threads to be daemon | |
129 * threads. When workers are daemon threads, the job plugin does not need | |
130 * to be explicitly shut down because the VM can exit while workers are still | |
131 * alive. | |
132 * @return <code>true</code> if all worker threads should be daemon threads, | |
133 * and <code>false</code> otherwise. | |
134 */ | |
135 bool useDaemonThreads() { | |
136 implMissing(__FILE__,__LINE__); | |
137 return false; | |
138 // BundleContext context = JobActivator.getContext(); | |
139 // if (context is null) { | |
140 // //we are running stand-alone, so consult global system property | |
141 // String value = System.getProperty(IJobManager.PROP_USE_DAEMON_THREADS); | |
142 // //default to use daemon threads if property is absent | |
143 // if (value is null) | |
144 // return true; | |
145 // return "true".equalsIgnoreCase(value); //$NON-NLS-1$ | |
146 // } | |
147 // //only use daemon threads if the property is defined | |
148 // final String value = context.getProperty(IJobManager.PROP_USE_DAEMON_THREADS); | |
149 // //if value is absent, don't use daemon threads to maintain legacy behaviour | |
150 // if (value is null) | |
151 // return false; | |
152 // return "true".equalsIgnoreCase(value); //$NON-NLS-1$ | |
153 } | |
154 } |