Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2014-03-24 21:28:31 +0000
committerThomas Watson2014-03-24 21:28:31 +0000
commit8a83ca61091dc2825bf19d2b6c3ebebd1f90a556 (patch)
tree05874b88c809ddd833d4eb91c9a68fd0bdd5dc24 /bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/FrameworkDebugOptions.java
parent2a9e5783274435db23f903fe97350c75f4e0800a (diff)
downloadrt.equinox.framework-8a83ca61091dc2825bf19d2b6c3ebebd1f90a556.tar.gz
rt.equinox.framework-8a83ca61091dc2825bf19d2b6c3ebebd1f90a556.tar.xz
rt.equinox.framework-8a83ca61091dc2825bf19d2b6c3ebebd1f90a556.zip
Bug 431052 - Support DebugOptionsListener for framework trace optionsI20140325-0830
Diffstat (limited to 'bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/FrameworkDebugOptions.java')
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/FrameworkDebugOptions.java52
1 files changed, 36 insertions, 16 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/FrameworkDebugOptions.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/FrameworkDebugOptions.java
index 7c6c13ed7..73b3147d9 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/FrameworkDebugOptions.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/debug/FrameworkDebugOptions.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2013 IBM Corporation and others.
+ * Copyright (c) 2003, 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
@@ -35,6 +35,8 @@ public class FrameworkDebugOptions implements DebugOptions, ServiceTrackerCustom
/** The default name of the .options file if loading when the -debug command-line argument is used */
private static final String OPTIONS = ".options"; //$NON-NLS-1$
+ /** A lock object used to synchronize access to the trace file */
+ private final static Object writeLock = new Object();
/** monitor used to lock the options maps */
private final Object lock = new Object();
/** A current map of all the options with values set */
@@ -47,6 +49,8 @@ public class FrameworkDebugOptions implements DebugOptions, ServiceTrackerCustom
protected File outFile = null;
/** Is verbose debugging enabled? Changing this value causes a new tracing session to start. */
protected boolean verboseDebug = true;
+ /** A flag to determine if the message being written is done to a new file (i.e. should the header information be written) */
+ private boolean newSession = true;
private final EquinoxConfiguration environmentInfo;
private volatile BundleContext context;
private volatile ServiceTracker<DebugOptionsListener, DebugOptionsListener> listenerTracker;
@@ -346,7 +350,7 @@ public class FrameworkDebugOptions implements DebugOptions, ServiceTrackerCustom
if (options != null)
return;
// notify the trace that a new session is started
- EclipseDebugTrace.newSession = true;
+ this.newSession = true;
// enable platform debugging - there is no .options file
environmentInfo.setConfiguration(OSGI_DEBUG, ""); //$NON-NLS-1$
@@ -417,15 +421,30 @@ public class FrameworkDebugOptions implements DebugOptions, ServiceTrackerCustom
* (non-Javadoc)
* @see org.eclipse.osgi.service.debug.DebugOptions#setFile(java.io.File)
*/
- public synchronized void setFile(final File traceFile) {
-
- this.outFile = traceFile;
- if (this.outFile != null)
- environmentInfo.setConfiguration(PROP_TRACEFILE, this.outFile.getAbsolutePath());
- else
- environmentInfo.clearConfiguration(PROP_TRACEFILE);
- // the file changed so start a new session
- EclipseDebugTrace.newSession = true;
+ public void setFile(final File traceFile) {
+ synchronized (lock) {
+ this.outFile = traceFile;
+ if (this.outFile != null)
+ environmentInfo.setConfiguration(PROP_TRACEFILE, this.outFile.getAbsolutePath());
+ else
+ environmentInfo.clearConfiguration(PROP_TRACEFILE);
+ // the file changed so start a new session
+ this.newSession = true;
+ }
+ }
+
+ boolean newSession() {
+ synchronized (lock) {
+ if (newSession) {
+ this.newSession = false;
+ return true;
+ }
+ return false;
+ }
+ }
+
+ Object getWriteLock() {
+ return writeLock;
}
/*
@@ -445,11 +464,12 @@ public class FrameworkDebugOptions implements DebugOptions, ServiceTrackerCustom
* (non-Javadoc)
* @see org.eclipse.osgi.service.debug.DebugOptions#setVerbose(boolean)
*/
- public synchronized void setVerbose(final boolean verbose) {
-
- this.verboseDebug = verbose;
- // the verbose flag changed so start a new session
- EclipseDebugTrace.newSession = true;
+ public void setVerbose(final boolean verbose) {
+ synchronized (lock) {
+ this.verboseDebug = verbose;
+ // the verbose flag changed so start a new session
+ this.newSession = true;
+ }
}
/**

Back to the top