Author: rob.stryker(a)jboss.com
Date: 2011-07-29 06:23:27 -0400 (Fri, 29 Jul 2011)
New Revision: 33349
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/.options
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/Trace.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java
Log:
JBIDE-9425
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.core/.options
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/.options (rev
0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/.options 2011-07-29 10:23:27 UTC (rev
33349)
@@ -0,0 +1,30 @@
+# Debugging options for the org.jboss.ide.eclipse.as.core plugin
+
+# Turn on general debugging
+org.jboss.ide.eclipse.as.core/debug=true
+
+# Tracing options
+org.jboss.ide.eclipse.as.core/config=false
+org.jboss.ide.eclipse.as.core/info=false
+org.jboss.ide.eclipse.as.core/warning=false
+org.jboss.ide.eclipse.as.core/severe=false
+org.jboss.ide.eclipse.as.core/finest=false
+org.jboss.ide.eclipse.as.core/finer=false
+
+# Tracking of server resources
+org.jboss.ide.eclipse.as.core/resources=false
+
+# Loading of extension points
+org.jboss.ide.eclipse.as.core/extension_point=false
+
+# Server listeners
+org.jboss.ide.eclipse.as.core/listeners=false
+
+# runtime targets
+org.jboss.ide.eclipse.as.core/runtime_target=false
+
+# Performance of loading and calling delegates
+org.jboss.ide.eclipse.as.core/performance=false
+
+# Publishing
+org.jboss.ide.eclipse.as.core/publishing=false
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java 2011-07-29
09:21:10 UTC (rev 33348)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/JBossServerCorePlugin.java 2011-07-29
10:23:27 UTC (rev 33349)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2011 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.core;
+import java.util.Hashtable;
+
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
@@ -18,6 +20,8 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.service.debug.DebugOptions;
+import org.eclipse.osgi.service.debug.DebugOptionsListener;
import org.eclipse.wst.common.project.facet.core.FacetedProjectFramework;
import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent;
import org.eclipse.wst.server.core.IServer;
@@ -42,6 +46,9 @@
super();
plugin = this;
}
+ public static JBossServerCorePlugin getInstance() {
+ return plugin;
+ }
public IExtension[] getExtensions (String extensionPoint) {
IExtensionRegistry reg = Platform.getExtensionRegistry();
@@ -61,6 +68,11 @@
UnitedServerListenerManager.getDefault().addListener(XPathModel.getDefault());
UnitedServerListenerManager.getDefault().addListener(ServerListener.getDefault());
FacetedProjectFramework.addListener( JBoss4xEarFacetInstallListener.getDefault(),
IFacetedProjectEvent.Type.POST_INSTALL);
+
+ // register the debug options listener
+ final Hashtable<String, String> props = new Hashtable<String, String>(4);
+ props.put(DebugOptions.LISTENER_SYMBOLICNAME, PLUGIN_ID);
+ context.registerService(DebugOptionsListener.class.getName(), new Trace(), props);
}
/**
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/Trace.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/Trace.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/Trace.java 2011-07-29
10:23:27 UTC (rev 33349)
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * 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
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.jboss.ide.eclipse.as.core;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+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 implements DebugOptionsListener {
+
+ private static final SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy
HH:mm.ss.SSS"); //$NON-NLS-1$
+
+ private static Set<String> logged = new HashSet<String>();
+
+ // tracing enablement flags
+ public static boolean CONFIG = false;
+ public static boolean INFO = false;
+ public static boolean WARNING = false;
+ public static boolean SEVERE = false;
+ public static boolean FINER = false;
+ public static boolean FINEST = false;
+ public static boolean RESOURCES = false;
+ public static boolean EXTENSION_POINT = false;
+ public static boolean LISTENERS = false;
+ public static boolean RUNTIME_TARGET = false;
+ public static boolean PERFORMANCE = false;
+ public static boolean PUBLISHING = 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_INFO = "/info"; //$NON-NLS-1$
+ public final static String STRING_WARNING = "/warning"; //$NON-NLS-1$
+ public final static String STRING_SEVERE = "/severe"; //$NON-NLS-1$
+ public final static String STRING_FINER = "/finer"; //$NON-NLS-1$
+ public final static String STRING_FINEST = "/finest"; //$NON-NLS-1$
+ public final static String STRING_RESOURCES = "/resources"; //$NON-NLS-1$
+ public final static String STRING_EXTENSION_POINT = "/extension_point";
//$NON-NLS-1$
+ public final static String STRING_LISTENERS = "/listeners"; //$NON-NLS-1$
+ public final static String STRING_RUNTIME_TARGET = "/runtime_target";
//$NON-NLS-1$
+ public final static String STRING_PERFORMANCE = "/performance"; //$NON-NLS-1$
+ public final static String STRING_PUBLISHING = "/publishing"; //$NON-NLS-1$
+
+ /**
+ * Trace constructor. This should never be explicitly called by clients and is used to
register this class with the
+ * {@link DebugOptions} service.
+ */
+ public Trace() {
+ super();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ *
org.eclipse.osgi.service.debug.DebugOptionsListener#optionsChanged(org.eclipse.osgi.service.debug.DebugOptions)
+ */
+ public void optionsChanged(DebugOptions options) {
+ Trace.CONFIG = options.getBooleanOption(JBossServerCorePlugin.PLUGIN_ID +
Trace.STRING_CONFIG, false);
+ Trace.INFO = options.getBooleanOption(JBossServerCorePlugin.PLUGIN_ID +
Trace.STRING_INFO, false);
+ Trace.WARNING = options.getBooleanOption(JBossServerCorePlugin.PLUGIN_ID +
Trace.STRING_WARNING, false);
+ Trace.SEVERE = options.getBooleanOption(JBossServerCorePlugin.PLUGIN_ID +
Trace.STRING_SEVERE, false);
+ Trace.FINER = options.getBooleanOption(JBossServerCorePlugin.PLUGIN_ID +
Trace.STRING_FINER, false);
+ Trace.FINEST = options.getBooleanOption(JBossServerCorePlugin.PLUGIN_ID +
Trace.STRING_FINEST, false);
+ Trace.RESOURCES = options.getBooleanOption(JBossServerCorePlugin.PLUGIN_ID +
Trace.STRING_RESOURCES, false);
+ Trace.EXTENSION_POINT = options.getBooleanOption(JBossServerCorePlugin.PLUGIN_ID +
Trace.STRING_EXTENSION_POINT, false);
+ Trace.LISTENERS = options.getBooleanOption(JBossServerCorePlugin.PLUGIN_ID +
Trace.STRING_LISTENERS, false);
+ Trace.RUNTIME_TARGET = options.getBooleanOption(JBossServerCorePlugin.PLUGIN_ID +
Trace.STRING_RUNTIME_TARGET, false);
+ Trace.PERFORMANCE = options.getBooleanOption(JBossServerCorePlugin.PLUGIN_ID +
Trace.STRING_PERFORMANCE, false);
+ Trace.PUBLISHING = options.getBooleanOption(JBossServerCorePlugin.PLUGIN_ID +
Trace.STRING_PUBLISHING, false);
+ }
+
+ /**
+ * Trace the given message.
+ *
+ * @param level
+ * The tracing level.
+ * @param s
+ * The message to trace
+ */
+ public static void trace(final String level, String s) {
+
+ Trace.trace(level, s, null);
+ }
+
+ /**
+ * Trace the given message and exception.
+ *
+ * @param level
+ * The tracing level.
+ * @param s
+ * The message to trace
+ * @param t
+ * A {@link Throwable} to trace
+ */
+ public static void trace(final String level, String s, Throwable t) {
+ if (s == null) {
+ return;
+ }
+ if (Trace.STRING_SEVERE.equals(level)) {
+ if (!logged.contains(s)) {
+ JBossServerCorePlugin.log(new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
s, t));
+ logged.add(s);
+ }
+ }
+ if (JBossServerCorePlugin.getInstance().isDebugging()) {
+ final StringBuffer sb = new StringBuffer(JBossServerCorePlugin.PLUGIN_ID);
+ sb.append(" "); //$NON-NLS-1$
+ sb.append(level);
+ sb.append(" "); //$NON-NLS-1$
+ sb.append(sdf.format(new Date()));
+ sb.append(" "); //$NON-NLS-1$
+ sb.append(s);
+ System.out.println(sb.toString());
+ if (t != null) {
+ t.printStackTrace();
+ }
+ }
+ }
+
+
+}
\ No newline at end of file