aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2008-05-28 00:02:41 +0000
committeraclement <aclement>2008-05-28 00:02:41 +0000
commitfaffcaef8fe5b55258e30d62c57625b7678794de (patch)
tree5696f9fe23aef2ee7333bb423ccf721f262ffcc7
parent6b882fcb403d04c0cd331a926deae9bcddc7148c (diff)
downloadaspectj-faffcaef8fe5b55258e30d62c57625b7678794de.tar.gz
aspectj-faffcaef8fe5b55258e30d62c57625b7678794de.zip
210470 merged into refactoring branch
-rw-r--r--bridge/src/org/aspectj/bridge/context/CompilationAndWeavingContext.java32
1 files changed, 22 insertions, 10 deletions
diff --git a/bridge/src/org/aspectj/bridge/context/CompilationAndWeavingContext.java b/bridge/src/org/aspectj/bridge/context/CompilationAndWeavingContext.java
index e3a0b7b7f..c9acc4967 100644
--- a/bridge/src/org/aspectj/bridge/context/CompilationAndWeavingContext.java
+++ b/bridge/src/org/aspectj/bridge/context/CompilationAndWeavingContext.java
@@ -136,12 +136,17 @@ public class CompilationAndWeavingContext {
private CompilationAndWeavingContext() {
}
- // for testing...
public static void reset() {
- contextMap = new HashMap();
- contextStack = new Stack();
- formatterMap = new HashMap();
- nextTokenId = 1;
+ if (!multiThreaded) {
+ contextMap = new HashMap();
+ contextStack = new Stack();
+ formatterMap = new HashMap();
+ nextTokenId = 1;
+ } else {
+ contextMap.remove(Thread.currentThread());
+ // TODO what about formatterMap?
+ // TODO what about nextTokenId?
+ }
}
public static void setMultiThreaded(boolean mt) { multiThreaded = mt; }
@@ -191,18 +196,25 @@ public class CompilationAndWeavingContext {
}
}
+ /**
+ * Forget about the context for the current thread
+ */
+ public static void resetForThread() {
+ if (!multiThreaded) return;
+ contextMap.remove(Thread.currentThread());
+ }
+
private static Stack getContextStack() {
if (!multiThreaded) {
return contextStack;
}
else {
- if (contextMap.containsKey(Thread.currentThread())) {
- return (Stack) contextMap.get(Thread.currentThread());
- } else {
- Stack contextStack = new Stack();
+ Stack contextStack = (Stack) contextMap.get(Thread.currentThread());
+ if (contextStack == null) {
+ contextStack = new Stack();
contextMap.put(Thread.currentThread(),contextStack);
- return contextStack;
}
+ return contextStack;
}
}