tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject [2/4] tomee git commit: destroying sessions in application composer as well
Date Sun, 03 May 2015 22:00:19 GMT
destroying sessions in application composer as well


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

Branch: refs/heads/master
Commit: fd7e9b2103e44e7610e91ee2d34c39aea3a17b2d
Parents: 5af485d
Author: Romain Manni-Bucau <rmannibucau@apache.org>
Authored: Sun May 3 22:23:57 2015 +0200
Committer: Romain Manni-Bucau <rmannibucau@apache.org>
Committed: Sun May 3 22:23:57 2015 +0200

----------------------------------------------------------------------
 .../openejb/OpenEJBDeployableContainer.java     |  6 ++++--
 .../openejb/testing/ApplicationComposers.java   | 22 ++++++++++++++++++++
 2 files changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/fd7e9b21/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java
b/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java
index 44915b8..f999c20 100644
--- a/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java
+++ b/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java
@@ -319,8 +319,10 @@ public class OpenEJBDeployableContainer implements DeployableContainer<OpenEJBCo
                         public void close() throws IOException {
                             try {
                                 final SessionManager sessionManager = SystemInstance.get().getComponent(SessionManager.class);
-                                for (final WebContext web : appCtx.getWebContexts()) {
-                                    sessionManager.destroy(web);
+                                if (sessionManager != null) {
+                                    for (final WebContext web : appCtx.getWebContexts())
{
+                                        sessionManager.destroy(web);
+                                    }
                                 }
                             } catch (final Throwable e) {
                                 // no-op

http://git-wip-us.apache.org/repos/asf/tomee/blob/fd7e9b21/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
b/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
index 9616622..08c2c5e 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
@@ -46,6 +46,7 @@ import org.apache.openejb.config.sys.JaxbOpenejb;
 import org.apache.openejb.config.sys.Openejb;
 import org.apache.openejb.core.LocalInitialContextFactory;
 import org.apache.openejb.core.Operation;
+import org.apache.openejb.core.ParentClassLoaderFinder;
 import org.apache.openejb.core.ThreadContext;
 import org.apache.openejb.core.WebContext;
 import org.apache.openejb.core.ivm.naming.InitContextFactory;
@@ -75,6 +76,7 @@ import org.apache.openejb.util.NetworkUtil;
 import org.apache.openejb.util.PropertyPlaceHolderHelper;
 import org.apache.openejb.util.ServiceManagerProxy;
 import org.apache.openejb.util.URLs;
+import org.apache.openejb.util.reflection.Reflections;
 import org.apache.openejb.web.LightweightWebAppBuilder;
 import org.apache.webbeans.inject.OWBInjector;
 import org.apache.webbeans.spi.ContextsService;
@@ -1447,6 +1449,26 @@ public class ApplicationComposers {
                     }
                 }
             });
+            if (!composer.appContext.getWebContexts().isEmpty()) {
+                composer.beforeDestroyAfterRunnables.add(new Runnable() {
+                    @Override
+                    public void run() {
+                        try {
+                            final Object sessionManager = SystemInstance.get().getComponent(
+                                    ParentClassLoaderFinder.Helper.get().loadClass("org.apache.openejb.server.httpd.session.SessionManager")
+                            );
+                            if (sessionManager != null) {
+                                final Class<?>[] paramTypes = {WebContext.class};
+                                for (final WebContext web : composer.appContext.getWebContexts())
{
+                                    Reflections.invokeByReflection(sessionManager, "destroy",
paramTypes, new Object[] { web });
+                                }
+                            }
+                        } catch (final Throwable e) {
+                            // no-op
+                        }
+                    }
+                });
+            }
             composer.afterRunnables.add(new Runnable() {
                 @Override
                 public void run() {


Mime
View raw message