[337907] Reduce the amount of Strings created when tracing is disabled
diff --git a/plugins/org.eclipse.jst.server.ui/.options b/plugins/org.eclipse.jst.server.ui/.options
index a747d69..045d38c 100644
--- a/plugins/org.eclipse.jst.server.ui/.options
+++ b/plugins/org.eclipse.jst.server.ui/.options
@@ -1,4 +1,10 @@
 # Debugging options for the org.eclipse.jst.server.ui plugin
 
-# Turn on general debugging
+# Turn on general tracing
 org.eclipse.jst.server.ui/debug=true
+
+# Tracing options
+org.eclipse.jst.server.ui/config=false
+org.eclipse.jst.server.ui/finest=false
+org.eclipse.jst.server.ui/warning=false
+org.eclipse.jst.server.ui/severe=false
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.jst.server.ui/META-INF/MANIFEST.MF
index 418151d..c72c58b 100644
--- a/plugins/org.eclipse.jst.server.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.jst.server.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.jst.server.ui; singleton:=true
-Bundle-Version: 1.1.201.qualifier
+Bundle-Version: 1.1.202.qualifier
 Bundle-Activator: org.eclipse.jst.server.ui.internal.JavaServerUIPlugin
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
diff --git a/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/ImageResource.java b/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/ImageResource.java
index 684357d..861e500 100644
--- a/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/ImageResource.java
+++ b/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/ImageResource.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2009 IBM Corporation and others.
+ * Copyright (c) 2003, 2011 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
@@ -35,7 +35,9 @@
 			String pathSuffix = "icons/";
 			ICON_BASE_URL = JavaServerUIPlugin.getInstance().getBundle().getEntry(pathSuffix);
 		} catch (Exception e) {
-			Trace.trace(Trace.SEVERE, "Could not set icon base URL", e);
+			if(Trace.SEVERE) {
+				Trace.trace(Trace.STRING_SEVERE, "Could not set icon base URL", e);
+			}
 		}
 	}
 
@@ -96,7 +98,9 @@
 			imageRegistry.put(key, id);
 			imageDescriptors.put(key, id);
 		} catch (Exception e) {
-			Trace.trace(Trace.WARNING, "Error registering image " + key + " from " + partialURL, e);
+			if(Trace.WARNING) {
+				Trace.trace(Trace.STRING_WARNING, "Error registering image " + key + " from " + partialURL, e);
+			}
 		}
 	}
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/JavaServerUIPlugin.java b/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/JavaServerUIPlugin.java
index 6eaf765..dbb47b8 100644
--- a/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/JavaServerUIPlugin.java
+++ b/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/JavaServerUIPlugin.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * Copyright (c) 2003, 2011 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
@@ -10,12 +10,17 @@
  *******************************************************************************/
 package org.eclipse.jst.server.ui.internal;
 
+import java.util.Hashtable;
+
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.service.debug.DebugOptions;
+import org.eclipse.osgi.service.debug.DebugOptionsListener;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
 /**
  * The main server tooling plugin class.
  */
@@ -77,4 +82,14 @@
 			return null;
 		return workBench.getActiveWorkbenchWindow();
 	}
-}
+
+    public void start(BundleContext context) throws Exception {
+
+    	super.start(context);
+
+    	// register the debug options listener
+		final Hashtable<String, String> props = new Hashtable<String, String>(4);
+		props.put(DebugOptions.LISTENER_SYMBOLICNAME, JavaServerUIPlugin.PLUGIN_ID);
+		context.registerService(DebugOptionsListener.class.getName(), new Trace(), props);
+    }
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/RuntimeLabelProvider.java b/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/RuntimeLabelProvider.java
index f5be1c1..16ccb5d 100644
--- a/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/RuntimeLabelProvider.java
+++ b/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/RuntimeLabelProvider.java
@@ -1,5 +1,5 @@
 /******************************************************************************
- * Copyright (c) 2005 BEA Systems, Inc.
+ * Copyright (c) 2005, 2011 BEA Systems, Inc.
  * 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
diff --git a/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/Trace.java b/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/Trace.java
index 0f54f82..9ea245b 100644
--- a/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/Trace.java
+++ b/plugins/org.eclipse.jst.server.ui/src/org/eclipse/jst/server/ui/internal/Trace.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * Copyright (c) 2003, 2011 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,48 +12,80 @@
 
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.service.debug.DebugOptions;
+import org.eclipse.osgi.service.debug.DebugOptionsListener;
+
 /**
  * Helper class to route trace output.
  */
-public class Trace {
-	public static final byte CONFIG = 0;
-	public static final byte WARNING = 1;
-	public static final byte SEVERE = 2;
-	public static final byte FINEST = 3;
+public class Trace implements DebugOptionsListener {
 
+	// tracing enablement flags
+	public static boolean CONFIG = false;
+	public static boolean WARNING = false;
+	public static boolean SEVERE = false;
+	public static boolean FINEST = false;
+
+	// tracing levels.  One most exist for each debug option
+	public final static String STRING_CONFIG = "/config"; //$NON-NLS-1$
+	public final static String STRING_FINEST = "/finest"; //$NON-NLS-1$
+	public final static String STRING_WARNING = "/warning"; //$NON-NLS-1$
+	public final static String STRING_SEVERE = "/severe"; //$NON-NLS-1$
+	
 	/**
-	 * Trace constructor comment.
+	 * Trace constructor. This should never be explicitly called by clients and is used to register this class with the
+	 * {@link DebugOptions} service.
 	 */
-	private Trace() {
+	public Trace() {
 		super();
 	}
 
-	/**
-	 * Trace the given text.
-	 *
-	 * @param level a trace level
-	 * @param s a message
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.osgi.service.debug.DebugOptionsListener#optionsChanged(org.eclipse.osgi.service.debug.DebugOptions)
 	 */
-	public static void trace(byte level, String s) {
+	public void optionsChanged(DebugOptions options) {
+		Trace.CONFIG = options.getBooleanOption(JavaServerUIPlugin.PLUGIN_ID + Trace.STRING_CONFIG, false);
+		Trace.WARNING = options.getBooleanOption(JavaServerUIPlugin.PLUGIN_ID + Trace.STRING_WARNING, false);
+		Trace.SEVERE = options.getBooleanOption(JavaServerUIPlugin.PLUGIN_ID + Trace.STRING_SEVERE, false);
+		Trace.FINEST = options.getBooleanOption(JavaServerUIPlugin.PLUGIN_ID + Trace.STRING_FINEST, false);
+	}
+
+	/**
+	 * Trace the given message.
+	 * 
+	 * @param level
+	 *            The tracing level.
+	 * @param s
+	 *            The message to trace
+	 */
+	public static void trace(final String level, final String s) {
 		Trace.trace(level, s, null);
 	}
-	
+
 	/**
 	 * Trace the given message and exception.
-	 *
-	 * @param level a trace level
-	 * @param s a message
-	 * @param t a throwable
+	 * 
+	 * @param level
+	 *            The tracing level.
+	 * @param s
+	 *            The message to trace
+	 * @param t
+	 *            A {@link Throwable} to trace
 	 */
-	public static void trace(byte level, String s, Throwable t) {
-		if (level == SEVERE)
-			JavaServerUIPlugin.getInstance().getLog().log(new Status(IStatus.ERROR, JavaServerUIPlugin.PLUGIN_ID, s, t));
-		
-		if (!JavaServerUIPlugin.getInstance().isDebugging())
-			return;
-		
-		System.out.println(JavaServerUIPlugin.PLUGIN_ID + " " + s);
-		if (t != null)
-			t.printStackTrace();
-	}
+	public static void trace(final String level, final String s, final Throwable t) {
+
+		if (Trace.STRING_SEVERE.equals(level)) {
+			JavaServerUIPlugin.getInstance().getLog()
+					.log(new Status(IStatus.ERROR, JavaServerUIPlugin.PLUGIN_ID, s, t));
+		}
+		if (JavaServerUIPlugin.getInstance().isDebugging()) {
+			System.out.println(JavaServerUIPlugin.PLUGIN_ID + " " + level + " " + s);
+			if (t != null) {
+				t.printStackTrace();
+			}
+		}
+	}	
 }
\ No newline at end of file