Index: EMFModelValidationPlugin.java =================================================================== RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.validation/plugins/org.eclipse.emf.validation/src/org/eclipse/emf/validation/internal/EMFModelValidationPlugin.java,v retrieving revision 1.6 diff -u -r1.6 EMFModelValidationPlugin.java --- EMFModelValidationPlugin.java 5 Oct 2008 22:12:16 -0000 1.6 +++ EMFModelValidationPlugin.java 23 Jul 2009 07:40:05 -0000 @@ -15,7 +15,9 @@ package org.eclipse.emf.validation.internal; import java.util.Collection; +import java.util.Dictionary; import java.util.HashMap; +import java.util.Hashtable; import java.util.Iterator; import java.util.Map; @@ -26,6 +28,8 @@ import org.eclipse.emf.common.EMFPlugin; import org.eclipse.emf.common.util.ResourceLocator; import org.eclipse.emf.validation.internal.l10n.ValidationMessages; +import org.eclipse.osgi.service.debug.DebugOptions; +import org.eclipse.osgi.service.debug.DebugOptionsListener; import org.eclipse.osgi.util.NLS; import org.osgi.framework.BundleContext; @@ -213,7 +217,7 @@ * * @author Christian W. Damus (cdamus) */ - public static class Implementation extends EMFPlugin.EclipsePlugin { + public static class Implementation extends EMFPlugin.EclipsePlugin implements DebugOptionsListener { /** * Track extensions for extension points defined in this bundle. */ @@ -237,6 +241,11 @@ super.start(context); extensionTracker = new ExtensionTracker(); + + // register listener that is notified whenever debug options change + Dictionary props = new Hashtable(4); + props.put(DebugOptions.LISTENER_SYMBOLICNAME, getPluginId()); + context.registerService(DebugOptionsListener.class.getName(), this, props); } @Override @@ -246,6 +255,10 @@ super.stop(context); } + + public void optionsChanged(DebugOptions options) { + Tracing.invalidateCache(); + } } public static class Tracing { @@ -255,13 +268,31 @@ private static final Map cachedOptions = new HashMap(); /** + * The cached Boolean value indicating whether tracing is enabled. + */ + private static Boolean debugging = null; + + /** + * Invalidates the cached debug options and the cached Boolean value + * indicating whether tracing is enabled. + */ + protected static void invalidateCache() { + cachedOptions.clear(); + debugging = null; + } + + /** * Retrieves a Boolean value indicating whether tracing is enabled. * * @return Whether tracing is enabled for the plug-in. * */ protected static boolean shouldTrace() { - return plugin.isDebugging(); + if (debugging == null) { + debugging = plugin.isDebugging(); + } + + return debugging.booleanValue(); } /**