deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ch...@apache.org
Subject git commit: DELTASPIKE-676 ServletContext is available for injection before EventBridgeContextListener
Date Thu, 31 Jul 2014 13:17:31 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 1d3dc077f -> da28876d3


DELTASPIKE-676 ServletContext is available for injection before EventBridgeContextListener


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

Branch: refs/heads/master
Commit: da28876d32a9e3c01d31df6be9fe5dec2c9eee5d
Parents: 1d3dc07
Author: Christian Kaltepoth <chkal@apache.org>
Authored: Thu Jul 31 15:12:39 2014 +0200
Committer: Christian Kaltepoth <chkal@apache.org>
Committed: Thu Jul 31 15:12:39 2014 +0200

----------------------------------------------------------------------
 .../src/main/resources/META-INF/web-fragment.xml    | 16 ++++++++--------
 .../event/context/ServletContextEventsObserver.java | 10 ++++++++++
 .../event/context/ServletContextEventsTest.java     | 12 ++++++++++--
 3 files changed, 28 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/da28876d/deltaspike/modules/servlet/impl/src/main/resources/META-INF/web-fragment.xml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/servlet/impl/src/main/resources/META-INF/web-fragment.xml
b/deltaspike/modules/servlet/impl/src/main/resources/META-INF/web-fragment.xml
index bffa282..67637dd 100644
--- a/deltaspike/modules/servlet/impl/src/main/resources/META-INF/web-fragment.xml
+++ b/deltaspike/modules/servlet/impl/src/main/resources/META-INF/web-fragment.xml
@@ -31,23 +31,23 @@
     </ordering>
 
     <listener>
-        <display-name>EventBridgeContextListener</display-name>
-        <listener-class>org.apache.deltaspike.servlet.impl.event.EventBridgeContextListener</listener-class>
+        <display-name>ServletContextHolderListener</display-name>
+        <listener-class>org.apache.deltaspike.servlet.impl.produce.ServletContextHolderListener</listener-class>
     </listener>
 
     <listener>
-        <display-name>EventBridgeSessionListener</display-name>
-        <listener-class>org.apache.deltaspike.servlet.impl.event.EventBridgeSessionListener</listener-class>
+        <display-name>RequestResponseHolderListener</display-name>
+        <listener-class>org.apache.deltaspike.servlet.impl.produce.RequestResponseHolderListener</listener-class>
     </listener>
 
     <listener>
-        <display-name>ServletContextHolderListener</display-name>
-        <listener-class>org.apache.deltaspike.servlet.impl.produce.ServletContextHolderListener</listener-class>
+        <display-name>EventBridgeContextListener</display-name>
+        <listener-class>org.apache.deltaspike.servlet.impl.event.EventBridgeContextListener</listener-class>
     </listener>
 
     <listener>
-        <display-name>RequestResponseHolderListener</display-name>
-        <listener-class>org.apache.deltaspike.servlet.impl.produce.RequestResponseHolderListener</listener-class>
+        <display-name>EventBridgeSessionListener</display-name>
+        <listener-class>org.apache.deltaspike.servlet.impl.event.EventBridgeSessionListener</listener-class>
     </listener>
 
     <filter>

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/da28876d/deltaspike/modules/servlet/impl/src/test/java/org/apache/deltaspike/test/servlet/impl/event/context/ServletContextEventsObserver.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/servlet/impl/src/test/java/org/apache/deltaspike/test/servlet/impl/event/context/ServletContextEventsObserver.java
b/deltaspike/modules/servlet/impl/src/test/java/org/apache/deltaspike/test/servlet/impl/event/context/ServletContextEventsObserver.java
index b2e5e3b..098d918 100644
--- a/deltaspike/modules/servlet/impl/src/test/java/org/apache/deltaspike/test/servlet/impl/event/context/ServletContextEventsObserver.java
+++ b/deltaspike/modules/servlet/impl/src/test/java/org/apache/deltaspike/test/servlet/impl/event/context/ServletContextEventsObserver.java
@@ -24,8 +24,10 @@ import java.util.List;
 
 import javax.enterprise.context.ApplicationScoped;
 import javax.enterprise.event.Observes;
+import javax.inject.Inject;
 import javax.servlet.ServletContext;
 
+import org.apache.deltaspike.core.api.common.DeltaSpike;
 import org.apache.deltaspike.core.api.lifecycle.Destroyed;
 import org.apache.deltaspike.core.api.lifecycle.Initialized;
 
@@ -38,9 +40,17 @@ public class ServletContextEventsObserver
 
     private final List<String> eventLog = new ArrayList<String>();
 
+    @Inject
+    @DeltaSpike
+    private ServletContext servletContext;
+
     public void contextInitialized(@Observes @Initialized ServletContext context)
     {
         eventLog.add("Initialized ServletContext: " + context.getServletContextName());
+        if (servletContext != null)
+        {
+            eventLog.add("ServletContext was injected");
+        }
     }
 
     public void contextDestroyed(@Observes @Destroyed ServletContext context)

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/da28876d/deltaspike/modules/servlet/impl/src/test/java/org/apache/deltaspike/test/servlet/impl/event/context/ServletContextEventsTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/servlet/impl/src/test/java/org/apache/deltaspike/test/servlet/impl/event/context/ServletContextEventsTest.java
b/deltaspike/modules/servlet/impl/src/test/java/org/apache/deltaspike/test/servlet/impl/event/context/ServletContextEventsTest.java
index bbb6e03..4ba2f86 100644
--- a/deltaspike/modules/servlet/impl/src/test/java/org/apache/deltaspike/test/servlet/impl/event/context/ServletContextEventsTest.java
+++ b/deltaspike/modules/servlet/impl/src/test/java/org/apache/deltaspike/test/servlet/impl/event/context/ServletContextEventsTest.java
@@ -18,7 +18,6 @@
  */
 package org.apache.deltaspike.test.servlet.impl.event.context;
 
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import javax.inject.Inject;
@@ -67,9 +66,18 @@ public class ServletContextEventsTest
     @Test
     public void shouldReceiveServletContextInitializedEvent()
     {
-        assertEquals(1, observer.getEventCount());
         assertTrue("Didn't receive expected event",
                 observer.getEventLog().contains("Initialized ServletContext: " + MODULE));
     }
 
+    /**
+     * @see https://issues.apache.org/jira/browse/DELTASPIKE-676
+     */
+    @Test
+    public void testDeltaSpike676()
+    {
+        assertTrue("ServletContext wasn't injected",
+                observer.getEventLog().contains("ServletContext was injected"));
+    }
+
 }


Mime
View raw message