tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject [2/3] tomee git commit: cleaning up observers with the container
Date Wed, 18 Feb 2015 10:13:50 GMT
cleaning up observers with the container


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/2b0750d4
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/2b0750d4
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/2b0750d4

Branch: refs/heads/develop
Commit: 2b0750d455c5c9a37a0fad0b82513ca9410b4f8f
Parents: a5561f6
Author: Romain Manni-Bucau <rmannibucau@apache.org>
Authored: Wed Feb 18 11:13:13 2015 +0100
Committer: Romain Manni-Bucau <rmannibucau@apache.org>
Committed: Wed Feb 18 11:13:13 2015 +0100

----------------------------------------------------------------------
 .../apache/openejb/assembler/classic/Assembler.java   | 14 ++++++++------
 .../org/apache/openejb/loader/SystemInstance.java     |  4 ++++
 .../org/apache/openejb/observer/ObserverManager.java  |  6 ++++++
 3 files changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/2b0750d4/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
index feac0a1..3b5c656 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
@@ -1526,7 +1526,8 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
         l.lock();
 
         try {
-            SystemInstance.get().fireEvent(new ContainerSystemPreDestroy());
+            SystemInstance systemInstance = SystemInstance.get();
+            systemInstance.fireEvent(new ContainerSystemPreDestroy());
 
             try {
                 EjbTimerServiceImpl.shutdown();
@@ -1578,11 +1579,12 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
                 // no-op
             }
 
-            SystemInstance.get().removeComponent(OpenEjbConfiguration.class);
-            SystemInstance.get().removeComponent(JtaEntityManagerRegistry.class);
-            SystemInstance.get().removeComponent(TransactionSynchronizationRegistry.class);
-            SystemInstance.get().removeComponent(EjbResolver.class);
-            SystemInstance.get().fireEvent(new AssemblerDestroyed());
+            systemInstance.removeComponent(OpenEjbConfiguration.class);
+            systemInstance.removeComponent(JtaEntityManagerRegistry.class);
+            systemInstance.removeComponent(TransactionSynchronizationRegistry.class);
+            systemInstance.removeComponent(EjbResolver.class);
+            systemInstance.fireEvent(new AssemblerDestroyed());
+            systemInstance.removeObservers();
             SystemInstance.reset();
         } finally {
             l.unlock();

http://git-wip-us.apache.org/repos/asf/tomee/blob/2b0750d4/container/openejb-loader/src/main/java/org/apache/openejb/loader/SystemInstance.java
----------------------------------------------------------------------
diff --git a/container/openejb-loader/src/main/java/org/apache/openejb/loader/SystemInstance.java
b/container/openejb-loader/src/main/java/org/apache/openejb/loader/SystemInstance.java
index 9a3f373..f53d1cb 100644
--- a/container/openejb-loader/src/main/java/org/apache/openejb/loader/SystemInstance.java
+++ b/container/openejb-loader/src/main/java/org/apache/openejb/loader/SystemInstance.java
@@ -380,4 +380,8 @@ public final class SystemInstance {
     public boolean hasProperty(final String propName) {
         return this.internalProperties.get(propName) != null;
     }
+
+    public void removeObservers() {
+        observerManager.destroy();
+    }
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/2b0750d4/container/openejb-loader/src/main/java/org/apache/openejb/observer/ObserverManager.java
----------------------------------------------------------------------
diff --git a/container/openejb-loader/src/main/java/org/apache/openejb/observer/ObserverManager.java
b/container/openejb-loader/src/main/java/org/apache/openejb/observer/ObserverManager.java
index 37becbe..75b4f1f 100644
--- a/container/openejb-loader/src/main/java/org/apache/openejb/observer/ObserverManager.java
+++ b/container/openejb-loader/src/main/java/org/apache/openejb/observer/ObserverManager.java
@@ -126,6 +126,12 @@ public class ObserverManager {
         return invocation;
     }
 
+    public void destroy() {
+        for (final Observer o : new LinkedList<>(observers)) {
+            removeObserver(o.observer);
+        }
+    }
+
     private static enum Phase {
         BEFORE,
         INVOKE,


Mime
View raw message