openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1672995 - /openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java
Date Sun, 12 Apr 2015 09:22:58 GMT
Author: struberg
Date: Sun Apr 12 09:22:57 2015
New Revision: 1672995

URL: http://svn.apache.org/r1672995
Log:
OWB-1025 implement @Initialized and @Destroyed also for WebContextsService

Modified:
    openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java

Modified: openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java?rev=1672995&r1=1672994&r2=1672995&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java
(original)
+++ openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java
Sun Apr 12 09:22:57 2015
@@ -18,6 +18,8 @@
  */
 package org.apache.webbeans.web.context;
 
+import org.apache.webbeans.annotation.DestroyedLiteral;
+import org.apache.webbeans.annotation.InitializedLiteral;
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.context.AbstractContextsService;
@@ -363,23 +365,26 @@ public class WebContextsService extends
                 
                 //Init thread local singleton context
                 initSingletonContext(event.getServletContext());
-            }            
+
+                webBeansContext.getBeanManagerImpl().fireEvent(request, InitializedLiteral.INSTANCE_REQUEST_SCOPED);
+            }
         }
         else
         {
-                //Init thread local application context
-                initApplicationContext(null);
+            //Init thread local application context
+            initApplicationContext(null);
 
-                //Init thread local singleton context
-                initSingletonContext(null);
+            //Init thread local singleton context
+            initSingletonContext(null);
+            webBeansContext.getBeanManagerImpl().fireEvent(new Object(), InitializedLiteral.INSTANCE_REQUEST_SCOPED);
         }
     }
     
     /**
      * Destroys the request context and all of its components. 
-     * @param request http servlet request object
+     * @param requestEvent http servlet request object
      */
-    private void destroyRequestContext(ServletRequestEvent request)
+    private void destroyRequestContext(ServletRequestEvent requestEvent)
     {
         // cleanup open conversations first
         if (supportsConversation)
@@ -409,6 +414,10 @@ public class WebContextsService extends
         requestContexts.remove();
 
         RequestScopedBeanInterceptorHandler.removeThreadLocals();
+
+        Object payload = requestEvent != null && requestEvent.getServletRequest()
!= null ? requestEvent.getServletRequest() : new Object();
+
+        webBeansContext.getBeanManagerImpl().fireEvent(payload, DestroyedLiteral.INSTANCE_REQUEST_SCOPED);
     }
 
     private void cleanupConversations()
@@ -460,6 +469,7 @@ public class WebContextsService extends
             // this is handy if you create asynchronous tasks or
             // batches which use a 'admin' user.
             currentSessionContext = new SessionContext();
+            webBeansContext.getBeanManagerImpl().fireEvent(new Object(), InitializedLiteral.INSTANCE_SESSION_SCOPED);
         }
         else
         {
@@ -473,6 +483,7 @@ public class WebContextsService extends
             {
                 currentSessionContext = new SessionContext();
                 sessionCtxManager.addNewSessionContext(sessionId, currentSessionContext);
+                webBeansContext.getBeanManagerImpl().fireEvent(session, InitializedLiteral.INSTANCE_SESSION_SCOPED);
             }
         }
 
@@ -550,6 +561,8 @@ public class WebContextsService extends
         {
             sharedApplicationContext = newApplicationContext;
         }
+
+        webBeansContext.getBeanManagerImpl().fireEvent(servletContext != null ? servletContext
: new Object(), InitializedLiteral.INSTANCE_APPLICATION_SCOPED);
     }
 
     /**
@@ -628,6 +641,8 @@ public class WebContextsService extends
         webBeansContext.getBeanManagerImpl().clearCacheProxies();
 
         classLoaderToServletContextMapping.remove(WebBeansUtil.getCurrentClassLoader());
+
+        webBeansContext.getBeanManagerImpl().fireEvent(servletContext != null ? servletContext
: new Object(), DestroyedLiteral.INSTANCE_APPLICATION_SCOPED);
     }
     
     /**
@@ -664,6 +679,8 @@ public class WebContextsService extends
         {
             sharedSingletonContext = newSingletonContext;
         }
+
+        webBeansContext.getBeanManagerImpl().fireEvent(servletContext != null ? servletContext
: new Object(), InitializedLiteral.INSTANCE_SINGLETON_SCOPED);
     }
     
     /**
@@ -700,6 +717,8 @@ public class WebContextsService extends
         }
 
         classLoaderToServletContextMapping.remove(WebBeansUtil.getCurrentClassLoader());
+
+        webBeansContext.getBeanManagerImpl().fireEvent(servletContext != null ? servletContext
: new Object(), DestroyedLiteral.INSTANCE_SINGLETON_SCOPED);
     }
 
     /**
@@ -721,7 +740,8 @@ public class WebContextsService extends
             {
                 conversationContexts.get().setActive(true);
             }
-            
+
+            webBeansContext.getBeanManagerImpl().fireEvent(new Object(), InitializedLiteral.INSTANCE_SINGLETON_SCOPED);
         }
         else
         {
@@ -740,6 +760,7 @@ public class WebContextsService extends
         if (context != null)
         {
             context.destroy();
+            webBeansContext.getBeanManagerImpl().fireEvent(new Object(), DestroyedLiteral.INSTANCE_SINGLETON_SCOPED);
         }
 
         conversationContexts.set(null);



Mime
View raw message