deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject git commit: DELTASPIKE-528 ContextController#stopApplicationScope fixed
Date Thu, 27 Feb 2014 10:24:01 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 10478c8e8 -> ab5105bd5


DELTASPIKE-528 ContextController#stopApplicationScope fixed


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

Branch: refs/heads/master
Commit: ab5105bd574289f23404fddea5647328ecbcbc9f
Parents: 10478c8
Author: gpetracek <gpetracek@apache.org>
Authored: Thu Feb 27 11:15:24 2014 +0100
Committer: gpetracek <gpetracek@apache.org>
Committed: Thu Feb 27 11:15:24 2014 +0100

----------------------------------------------------------------------
 .../cdise/weld/ContextController.java           |  3 +++
 .../cdise/tck/ContainerCtrlTckTest.java         |  9 ++++++++
 .../apache/deltaspike/cdise/tck/beans/Car.java  | 22 ++++++++++++++++++--
 .../deltaspike/cdise/tck/beans/CarRepair.java   | 22 ++++++++++++++++++--
 .../deltaspike/cdise/tck/beans/TestUser.java    | 22 ++++++++++++++++++++
 5 files changed, 74 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ab5105bd/deltaspike/cdictrl/impl-weld/src/main/java/org/apache/deltaspike/cdise/weld/ContextController.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/impl-weld/src/main/java/org/apache/deltaspike/cdise/weld/ContextController.java
b/deltaspike/cdictrl/impl-weld/src/main/java/org/apache/deltaspike/cdise/weld/ContextController.java
index 64c1df0..f6c7eaf 100644
--- a/deltaspike/cdictrl/impl-weld/src/main/java/org/apache/deltaspike/cdise/weld/ContextController.java
+++ b/deltaspike/cdictrl/impl-weld/src/main/java/org/apache/deltaspike/cdise/weld/ContextController.java
@@ -66,6 +66,9 @@ public class ContextController
     {
         if (applicationContext.isActive())
         {
+            applicationContext.invalidate();
+
+            //needed for weld < v1.1.9
             if (applicationContext instanceof AbstractSharedContext)
             {
                 ((AbstractSharedContext) applicationContext).getBeanStore().clear();

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ab5105bd/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/ContainerCtrlTckTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/ContainerCtrlTckTest.java
b/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/ContainerCtrlTckTest.java
index 51b8780..db5d6d4 100644
--- a/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/ContainerCtrlTckTest.java
+++ b/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/ContainerCtrlTckTest.java
@@ -23,6 +23,7 @@ import org.apache.deltaspike.cdise.api.CdiContainer;
 import org.apache.deltaspike.cdise.api.CdiContainerLoader;
 import org.apache.deltaspike.cdise.tck.beans.Car;
 import org.apache.deltaspike.cdise.tck.beans.CarRepair;
+import org.apache.deltaspike.cdise.tck.beans.TestUser;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -122,8 +123,16 @@ public class ContainerCtrlTckTest
         carRepair.getCar().getUser().setName("tester");
         Assert.assertEquals("tester", car.getUser().getName());
 
+        Assert.assertFalse(CarRepair.isPreDestroyCalled());
+        Assert.assertFalse(Car.isPreDestroyCalled());
+        Assert.assertFalse(TestUser.isPreDestroyCalled());
+
         cdiContainer.getContextControl().stopContexts();
 
+        Assert.assertTrue(CarRepair.isPreDestroyCalled());
+        Assert.assertTrue(Car.isPreDestroyCalled());
+        Assert.assertTrue(TestUser.isPreDestroyCalled());
+
         try
         {
             car.getUser();

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ab5105bd/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/Car.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/Car.java
b/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/Car.java
index dbb1125..93e33b0 100644
--- a/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/Car.java
+++ b/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/Car.java
@@ -19,22 +19,40 @@
 package org.apache.deltaspike.cdise.tck.beans;
 
 
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
 import javax.enterprise.context.RequestScoped;
 import javax.inject.Inject;
 
 @RequestScoped
 public class Car
 {
+    private static ThreadLocal<Boolean> preDestroyCalled = new ThreadLocal<Boolean>();
+
     @Inject
     private TestUser user;
 
+    @PostConstruct
+    protected void onPostConstruct()
+    {
+        //reset it
+        preDestroyCalled.remove();
+        preDestroyCalled.set(false);
+    }
+
+    @PreDestroy
+    protected void onPreDestroy()
+    {
+        preDestroyCalled.set(true);
+    }
+
     public TestUser getUser()
     {
         return user;
     }
 
-    public void setUser(TestUser user)
+    public static boolean isPreDestroyCalled()
     {
-        this.user = user;
+        return preDestroyCalled.get();
     }
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ab5105bd/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/CarRepair.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/CarRepair.java
b/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/CarRepair.java
index beec2f5..d479685 100644
--- a/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/CarRepair.java
+++ b/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/CarRepair.java
@@ -18,22 +18,40 @@
  */
 package org.apache.deltaspike.cdise.tck.beans;
 
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
 import javax.enterprise.context.ApplicationScoped;
 import javax.inject.Inject;
 
 @ApplicationScoped
 public class CarRepair
 {
+    private static ThreadLocal<Boolean> preDestroyCalled = new ThreadLocal<Boolean>();
+
     @Inject
     private Car car;
 
+    @PostConstruct
+    protected void onPostConstruct()
+    {
+        //reset it
+        preDestroyCalled.remove();
+        preDestroyCalled.set(false);
+    }
+
+    @PreDestroy
+    protected void onPreDestroy()
+    {
+        preDestroyCalled.set(true);
+    }
+
     public Car getCar()
     {
         return car;
     }
 
-    public void setCar(Car car)
+    public static boolean isPreDestroyCalled()
     {
-        this.car = car;
+        return preDestroyCalled.get();
     }
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ab5105bd/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/TestUser.java
----------------------------------------------------------------------
diff --git a/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/TestUser.java
b/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/TestUser.java
index 318a8b4..8233710 100644
--- a/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/TestUser.java
+++ b/deltaspike/cdictrl/tck/src/main/java/org/apache/deltaspike/cdise/tck/beans/TestUser.java
@@ -18,6 +18,8 @@
  */
 package org.apache.deltaspike.cdise.tck.beans;
 
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
 import javax.enterprise.context.SessionScoped;
 import java.io.Serializable;
 
@@ -25,9 +27,24 @@ import java.io.Serializable;
 public class TestUser implements Serializable
 {
     private static final long serialVersionUID = -4171521313675763849L;
+    private static ThreadLocal<Boolean> preDestroyCalled = new ThreadLocal<Boolean>();
 
     private String name;
 
+    @PostConstruct
+    protected void onPostConstruct()
+    {
+        //reset it
+        preDestroyCalled.remove();
+        preDestroyCalled.set(false);
+    }
+
+    @PreDestroy
+    protected void onPreDestroy()
+    {
+        preDestroyCalled.set(true);
+    }
+
     public String getName()
     {
         return name;
@@ -37,4 +54,9 @@ public class TestUser implements Serializable
     {
         this.name = name;
     }
+
+    public static boolean isPreDestroyCalled()
+    {
+        return preDestroyCalled.get();
+    }
 }


Mime
View raw message