diff options
author | Szymon Ptaszkiewicz | 2014-11-17 08:43:54 +0000 |
---|---|---|
committer | Szymon Ptaszkiewicz | 2014-11-17 08:43:54 +0000 |
commit | 0859978fb44777f6eb7ced86c2e31455e52d23db (patch) | |
tree | 5da60e25e79025c5cd4060a4e97b0b490a9b3bb6 /bundles/org.eclipse.core.net/src | |
parent | b15d7bbdd46145f0bfd6a57fc451491f4947498c (diff) | |
download | eclipse.platform.team-0859978fb44777f6eb7ced86c2e31455e52d23db.tar.gz eclipse.platform.team-0859978fb44777f6eb7ced86c2e31455e52d23db.tar.xz eclipse.platform.team-0859978fb44777f6eb7ced86c2e31455e52d23db.zip |
Bug 451736 - Add org.eclipse.core.net plugin to General > Tracing preference page
Diffstat (limited to 'bundles/org.eclipse.core.net/src')
-rw-r--r-- | bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/Activator.java | 44 | ||||
-rw-r--r-- | bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/Policy.java | 16 |
2 files changed, 20 insertions, 40 deletions
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/Activator.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/Activator.java index 419bd090f..4b692f444 100644 --- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/Activator.java +++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/Activator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2014 IBM Corporation and others. * 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 @@ -26,6 +26,7 @@ import org.eclipse.osgi.framework.log.FrameworkLog; import org.eclipse.osgi.framework.log.FrameworkLogEntry; import org.eclipse.osgi.service.datalocation.Location; import org.eclipse.osgi.service.debug.DebugOptions; +import org.eclipse.osgi.service.debug.DebugOptionsListener; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.Filter; @@ -54,12 +55,10 @@ public class Activator implements BundleActivator { private ServiceTracker instanceLocationTracker; - private ServiceTracker debugTracker; + private ServiceRegistration debugRegistration; private ServiceRegistration proxyService; - private boolean debug = false; - private PreferenceManager preferenceManger; /** @@ -164,15 +163,10 @@ public class Activator implements BundleActivator { instanceLocationTracker = new ServiceTracker(context, filter, null); instanceLocationTracker.open(); - debugTracker = new ServiceTracker(context, DebugOptions.class.getName(), null); - debugTracker.open(); - - String symbolicName = context.getBundle().getSymbolicName(); - if (symbolicName != null) { - String key = symbolicName + "/debug"; //$NON-NLS-1$ - String value = getDebugOption(key); - this.debug = value == null ? false : value.equalsIgnoreCase("true"); //$NON-NLS-1$ - } + // register debug options listener + Hashtable properties = new Hashtable(2); + properties.put(DebugOptions.LISTENER_SYMBOLICNAME, ID); + debugRegistration = context.registerService(DebugOptionsListener.class, Policy.DEBUG_OPTIONS_LISTENER, properties); if (Boolean .valueOf(System.getProperty(PROP_REGISTER_SERVICE, "true")).booleanValue()) { //$NON-NLS-1$ @@ -183,32 +177,16 @@ public class Activator implements BundleActivator { .getName(), proxyManager, new Hashtable()); } } - - String getDebugOption(String option) { - if (debugTracker == null) - return null; - DebugOptions options = (DebugOptions) debugTracker.getService(); - if (options != null) - return options.getOption(option); - return null; - } - - /** - * Returns whether this plug-in is in debug mode. - */ - boolean isDebugging() { - return debug; - } public void stop(BundleContext context) throws Exception { if (proxyService != null) { proxyService.unregister(); proxyService = null; } - - if (debugTracker != null) { - debugTracker.close(); - debugTracker = null; + + if (debugRegistration != null) { + debugRegistration.unregister(); + debugRegistration = null; } if (instanceLocationTracker != null) { diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/Policy.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/Policy.java index 1d2495049..e73c1a99a 100644 --- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/Policy.java +++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/Policy.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others. + * Copyright (c) 2008, 2014 IBM Corporation and others. * 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 @@ -12,6 +12,9 @@ package org.eclipse.core.internal.net; import java.util.Date; +import org.eclipse.osgi.service.debug.DebugOptions; +import org.eclipse.osgi.service.debug.DebugOptionsListener; + public class Policy { // general debug flag @@ -19,13 +22,12 @@ public class Policy { public static boolean DEBUG_SYSTEM_PROVIDERS = false; - static { - // init debug options - if (Activator.getInstance().isDebugging()) { - DEBUG = true; - DEBUG_SYSTEM_PROVIDERS = "true".equalsIgnoreCase(Activator.getInstance().getDebugOption(Activator.ID + "/systemproviders")); //$NON-NLS-1$ //$NON-NLS-2$ + static final DebugOptionsListener DEBUG_OPTIONS_LISTENER = new DebugOptionsListener() { + public void optionsChanged(DebugOptions options) { + DEBUG = options.getBooleanOption(Activator.ID + "/debug", false); //$NON-NLS-1$ + DEBUG_SYSTEM_PROVIDERS = DEBUG && options.getBooleanOption(Activator.ID + "/systemproviders", false); //$NON-NLS-1$ } - } + }; /** * Print a debug message to the console. Pre-pend the message with the |