deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ch...@apache.org
Subject git commit: DELTASPIKE-409 Moved Deactivatable handling to EventEmitter
Date Mon, 09 Sep 2013 05:48:43 GMT
Updated Branches:
  refs/heads/master 1e963ac59 -> 61b2e291d


DELTASPIKE-409 Moved Deactivatable handling to EventEmitter


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

Branch: refs/heads/master
Commit: 61b2e291d966c8cd97b5e26d3f0f7265492ff14e
Parents: 1e963ac
Author: Christian Kaltepoth <christian@kaltepoth.de>
Authored: Mon Sep 9 07:28:41 2013 +0200
Committer: Christian Kaltepoth <christian@kaltepoth.de>
Committed: Mon Sep 9 07:28:41 2013 +0200

----------------------------------------------------------------------
 .../impl/event/EventBridgeContextListener.java  | 15 +++------------
 .../servlet/impl/event/EventBridgeFilter.java   | 15 +++------------
 .../impl/event/EventBridgeSessionListener.java  | 15 +++------------
 .../servlet/impl/event/EventEmitter.java        | 20 ++++++++++++++++++--
 4 files changed, 27 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/61b2e291/deltaspike/modules/servlet/impl/src/main/java/org/apache/deltaspike/servlet/impl/event/EventBridgeContextListener.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/servlet/impl/src/main/java/org/apache/deltaspike/servlet/impl/event/EventBridgeContextListener.java
b/deltaspike/modules/servlet/impl/src/main/java/org/apache/deltaspike/servlet/impl/event/EventBridgeContextListener.java
index c80d92e..aa121dd 100644
--- a/deltaspike/modules/servlet/impl/src/main/java/org/apache/deltaspike/servlet/impl/event/EventBridgeContextListener.java
+++ b/deltaspike/modules/servlet/impl/src/main/java/org/apache/deltaspike/servlet/impl/event/EventBridgeContextListener.java
@@ -21,28 +21,19 @@ package org.apache.deltaspike.servlet.impl.event;
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
 
-import org.apache.deltaspike.core.spi.activation.Deactivatable;
-import org.apache.deltaspike.core.util.ClassDeactivationUtils;
 import org.apache.deltaspike.servlet.api.literal.DestroyedLiteral;
 import org.apache.deltaspike.servlet.api.literal.InitializedLiteral;
 
 /**
  * This class listens for servlet context events and forwards them to the CDI event bus.
  */
-public class EventBridgeContextListener extends EventEmitter implements ServletContextListener,
Deactivatable
+public class EventBridgeContextListener extends EventEmitter implements ServletContextListener
 {
 
-    private final boolean activated;
-
-    public EventBridgeContextListener()
-    {
-        this.activated = ClassDeactivationUtils.isActivated(getClass());
-    }
-
     @Override
     public void contextInitialized(ServletContextEvent sce)
     {
-        if (activated)
+        if (isActivated())
         {
             fireEvent(sce.getServletContext(), InitializedLiteral.INSTANCE);
         }
@@ -51,7 +42,7 @@ public class EventBridgeContextListener extends EventEmitter implements
ServletC
     @Override
     public void contextDestroyed(ServletContextEvent sce)
     {
-        if (activated)
+        if (isActivated())
         {
             fireEvent(sce.getServletContext(), DestroyedLiteral.INSTANCE);
         }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/61b2e291/deltaspike/modules/servlet/impl/src/main/java/org/apache/deltaspike/servlet/impl/event/EventBridgeFilter.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/servlet/impl/src/main/java/org/apache/deltaspike/servlet/impl/event/EventBridgeFilter.java
b/deltaspike/modules/servlet/impl/src/main/java/org/apache/deltaspike/servlet/impl/event/EventBridgeFilter.java
index ce1f279..5bcc153 100644
--- a/deltaspike/modules/servlet/impl/src/main/java/org/apache/deltaspike/servlet/impl/event/EventBridgeFilter.java
+++ b/deltaspike/modules/servlet/impl/src/main/java/org/apache/deltaspike/servlet/impl/event/EventBridgeFilter.java
@@ -27,24 +27,15 @@ import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 
-import org.apache.deltaspike.core.spi.activation.Deactivatable;
-import org.apache.deltaspike.core.util.ClassDeactivationUtils;
 import org.apache.deltaspike.servlet.api.literal.DestroyedLiteral;
 import org.apache.deltaspike.servlet.api.literal.InitializedLiteral;
 
 /**
  * This filter sends events to the CDI event bus when requests and responses get created
and destroyed.
  */
-public class EventBridgeFilter extends EventEmitter implements Filter, Deactivatable
+public class EventBridgeFilter extends EventEmitter implements Filter
 {
 
-    private final boolean activated;
-
-    public EventBridgeFilter()
-    {
-        this.activated = ClassDeactivationUtils.isActivated(getClass());
-    }
-
     @Override
     public void init(FilterConfig config) throws ServletException
     {
@@ -57,7 +48,7 @@ public class EventBridgeFilter extends EventEmitter implements Filter, Deactivat
     {
 
         // fire @Initialized events
-        if (activated)
+        if (isActivated())
         {
             fireEvent(request, InitializedLiteral.INSTANCE);
             fireEvent(response, InitializedLiteral.INSTANCE);
@@ -70,7 +61,7 @@ public class EventBridgeFilter extends EventEmitter implements Filter, Deactivat
         finally
         {
             // fire @Destroyed events
-            if (activated)
+            if (isActivated())
             {
                 fireEvent(request, DestroyedLiteral.INSTANCE);
                 fireEvent(response, DestroyedLiteral.INSTANCE);

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/61b2e291/deltaspike/modules/servlet/impl/src/main/java/org/apache/deltaspike/servlet/impl/event/EventBridgeSessionListener.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/servlet/impl/src/main/java/org/apache/deltaspike/servlet/impl/event/EventBridgeSessionListener.java
b/deltaspike/modules/servlet/impl/src/main/java/org/apache/deltaspike/servlet/impl/event/EventBridgeSessionListener.java
index 73f14c3..afa476d 100644
--- a/deltaspike/modules/servlet/impl/src/main/java/org/apache/deltaspike/servlet/impl/event/EventBridgeSessionListener.java
+++ b/deltaspike/modules/servlet/impl/src/main/java/org/apache/deltaspike/servlet/impl/event/EventBridgeSessionListener.java
@@ -21,28 +21,19 @@ package org.apache.deltaspike.servlet.impl.event;
 import javax.servlet.http.HttpSessionEvent;
 import javax.servlet.http.HttpSessionListener;
 
-import org.apache.deltaspike.core.spi.activation.Deactivatable;
-import org.apache.deltaspike.core.util.ClassDeactivationUtils;
 import org.apache.deltaspike.servlet.api.literal.DestroyedLiteral;
 import org.apache.deltaspike.servlet.api.literal.InitializedLiteral;
 
 /**
  * This class listens for HTTP session events and forwards them to the CDI event bus.
  */
-public class EventBridgeSessionListener extends EventEmitter implements HttpSessionListener,
Deactivatable
+public class EventBridgeSessionListener extends EventEmitter implements HttpSessionListener
 {
 
-    private final boolean activated;
-
-    public EventBridgeSessionListener()
-    {
-        this.activated = ClassDeactivationUtils.isActivated(getClass());
-    }
-
     @Override
     public void sessionCreated(HttpSessionEvent se)
     {
-        if (activated)
+        if (isActivated())
         {
             fireEvent(se.getSession(), InitializedLiteral.INSTANCE);
         }
@@ -51,7 +42,7 @@ public class EventBridgeSessionListener extends EventEmitter implements
HttpSess
     @Override
     public void sessionDestroyed(HttpSessionEvent se)
     {
-        if (activated)
+        if (isActivated())
         {
             fireEvent(se.getSession(), DestroyedLiteral.INSTANCE);
         }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/61b2e291/deltaspike/modules/servlet/impl/src/main/java/org/apache/deltaspike/servlet/impl/event/EventEmitter.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/servlet/impl/src/main/java/org/apache/deltaspike/servlet/impl/event/EventEmitter.java
b/deltaspike/modules/servlet/impl/src/main/java/org/apache/deltaspike/servlet/impl/event/EventEmitter.java
index 111299d..d01a67c 100644
--- a/deltaspike/modules/servlet/impl/src/main/java/org/apache/deltaspike/servlet/impl/event/EventEmitter.java
+++ b/deltaspike/modules/servlet/impl/src/main/java/org/apache/deltaspike/servlet/impl/event/EventEmitter.java
@@ -18,19 +18,30 @@
  */
 package org.apache.deltaspike.servlet.impl.event;
 
-import javax.enterprise.inject.spi.BeanManager;
 import java.lang.annotation.Annotation;
 
+import javax.enterprise.inject.spi.BeanManager;
+
 import org.apache.deltaspike.core.api.provider.BeanManagerProvider;
+import org.apache.deltaspike.core.spi.activation.Deactivatable;
+import org.apache.deltaspike.core.util.ClassDeactivationUtils;
 
 /**
  * Base class for classes which send servlet events to the CDI event bus. This class uses
{@link BeanManagerProvider} to
  * obtain the BeanManager.
  */
-abstract class EventEmitter
+abstract class EventEmitter implements Deactivatable
 {
+
     private volatile BeanManager beanManager;
 
+    private final boolean activated;
+
+    public EventEmitter()
+    {
+        this.activated = ClassDeactivationUtils.isActivated(getClass());
+    }
+
     protected void fireEvent(Object event, Annotation... qualifier)
     {
         getBeanManager().fireEvent(event, qualifier);
@@ -52,4 +63,9 @@ abstract class EventEmitter
         return beanManager;
     }
 
+    protected boolean isActivated()
+    {
+        return activated;
+    }
+
 }


Mime
View raw message