use of org.eclipse.osgi.service.debug.DebugOptions in project hale by halestudio.
the class Activator method getBooleanDebugOption.
/**
* Return the debug value of the option if founded otherwise return
* defaultValue.
*
* @param option
* @param defaultValue
* @return
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public static boolean getBooleanDebugOption(String option, boolean defaultValue) {
// 1) search param from JVM
String s = System.getProperty(DEBUG_PROPERTY);
if (!Utils.isEmpty(s)) {
return Utils.isTrue(s, defaultValue);
}
// 2) search param from nonosgiregistry.properties files.
if (nonosgiregistryProps == null) {
nonosgiregistryProps = Utils.load(Activator.class.getClassLoader());
s = nonosgiregistryProps.getProperty(DEBUG_PROPERTY);
if (!Utils.isEmpty(s)) {
return Utils.isTrue(s, defaultValue);
}
}
// 3) Search param from OSGi options
Activator activator = getDefault();
if (activator == null)
// No OSGi context
return defaultValue;
BundleContext myBundleContext = activator.bundleContext;
if (myBundleContext == null)
return defaultValue;
// Search the DebugOptions OSGi service
if (getDefault().debugTracker == null) {
getDefault().debugTracker = new ServiceTracker(getDefault().bundleContext, DebugOptions.class.getName(), null);
getDefault().debugTracker.open();
}
DebugOptions options = (DebugOptions) getDefault().debugTracker.getService();
if (options != null) {
// get the value of the option by using OSGi service DebugOptions
return Utils.isTrue(options.getOption(option), defaultValue);
}
return defaultValue;
}
use of org.eclipse.osgi.service.debug.DebugOptions in project eclipse.platform.runtime by eclipse.
the class ServiceContextTest method testServiceContextAsParent.
/**
* Tests accessing OSGi services through a child context that is not aware of them.
*/
@Test
public void testServiceContextAsParent() {
IEclipseContext child = context.createChild("child");
DebugOptions service = (DebugOptions) child.get(DebugOptions.class.getName());
assertNotNull(service);
}
use of org.eclipse.osgi.service.debug.DebugOptions in project eclipse.platform.runtime by eclipse.
the class Plugin method isDebugging.
/**
* Returns whether this plug-in is in debug mode.
* By default plug-ins are not in debug mode. A plug-in can put itself
* into debug mode or the user can set an execution option to do so.
* <p>
* Note that the plug-in's debug flag is initialized when the
* plug-in is started. The result of calling this method before the plug-in
* has started is unspecified.
* </p>
*
* @return whether this plug-in is in debug mode
* XXX deprecate use the service and cache as needed
*/
public boolean isDebugging() {
Bundle debugBundle = getBundle();
if (debugBundle == null)
return debug;
// $NON-NLS-1$
String key = debugBundle.getSymbolicName() + "/debug";
// first check if platform debugging is enabled
final DebugOptions debugOptions = getDebugOptions();
if (debugOptions == null)
return debug;
// if platform debugging is enabled, check to see if this plugin is enabled for debugging
return debugOptions.isDebugEnabled() ? InternalPlatform.getDefault().getBooleanOption(key, false) : false;
}
use of org.eclipse.osgi.service.debug.DebugOptions in project epp.mpc by eclipse.
the class MarketplaceClientCorePlugin method start.
public void start(BundleContext context) throws Exception {
bundle = context.getBundle();
instance = this;
ProxyHelper.acquireProxyService();
registerServices(context);
serviceHelper = new ServiceHelperImpl();
serviceHelper.startTracking(context);
Hashtable<String, String> props = new Hashtable<String, String>(2);
props.put(org.eclipse.osgi.service.debug.DebugOptions.LISTENER_SYMBOLICNAME, MarketplaceClientCore.BUNDLE_ID);
context.registerService(DebugOptionsListener.class.getName(), new DebugOptionsListener() {
public void optionsChanged(DebugOptions options) {
DebugTrace debugTrace = null;
boolean debug = options.getBooleanOption(MarketplaceClientCore.BUNDLE_ID + DEBUG_OPTION, false);
boolean fakeClient = false;
if (debug) {
debugTrace = options.newDebugTrace(MarketplaceClientCore.BUNDLE_ID);
fakeClient = options.getBooleanOption(MarketplaceClientCore.BUNDLE_ID + DEBUG_FAKE_CLIENT_OPTION, false);
}
DEBUG = debug;
DEBUG_FAKE_CLIENT = fakeClient;
MarketplaceClientCorePlugin.debugTrace = debugTrace;
}
}, props);
}
use of org.eclipse.osgi.service.debug.DebugOptions in project polymap4-core by Polymap4.
the class AuthPlugin method getBooleanOption.
public boolean getBooleanOption(String option, boolean defaultValue) {
if (debugTracker == null) {
if (bundleContext == null)
return defaultValue;
debugTracker = new ServiceTracker(bundleContext, DebugOptions.class.getName(), null);
debugTracker.open();
}
DebugOptions options = (DebugOptions) debugTracker.getService();
if (options == null)
return defaultValue;
String value = options.getOption(option);
if (value == null)
return defaultValue;
// $NON-NLS-1$
return value.equalsIgnoreCase("true");
}
Aggregations