geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r1101200 - /geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/WebBeansConfigurationListener.java
Date Mon, 09 May 2011 20:11:42 GMT
Author: dblevins
Date: Mon May  9 20:11:41 2011
New Revision: 1101200

URL: http://svn.apache.org/viewvc?rev=1101200&view=rev
Log:
Kevan's patch, GERONIMO-5896: ContextNotActiveException running JCDI TCK

Modified:
    geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/WebBeansConfigurationListener.java

Modified: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/WebBeansConfigurationListener.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/WebBeansConfigurationListener.java?rev=1101200&r1=1101199&r2=1101200&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/WebBeansConfigurationListener.java
(original)
+++ geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/WebBeansConfigurationListener.java
Mon May  9 20:11:41 2011
@@ -61,12 +61,16 @@ public class WebBeansConfigurationListen
     protected FailOverService failoverService;
 
     /**Manages the container lifecycle*/
+    protected ContainerLifecycle lifeCycle = null;
     protected WebBeansContext webBeansContext;
+
     /**
      * Default constructor
      */
     public WebBeansConfigurationListener()
     {
+        this.webBeansContext = WebBeansContext.getInstance();
+        this.failoverService = webBeansContext.getService(FailOverService.class);     
     }
 
 
@@ -75,8 +79,20 @@ public class WebBeansConfigurationListen
      */
     public void contextInitialized(ServletContextEvent event)
     {
-        this.webBeansContext = WebBeansContext.getInstance();
-        this.failoverService = webBeansContext.getService(FailOverService.class);     
+        try
+        {
+            this.lifeCycle = webBeansContext.getService(ContainerLifecycle.class);
+            if (lifeCycle instanceof org.apache.webbeans.web.lifecycle.WebContainerLifecycle)
{
+            	this.lifeCycle.startApplication(event);
+            } else {
+            	this.lifeCycle = null;
+            }
+        }
+        catch (Exception e)
+        {
+             logger.error(OWBLogConst.ERROR_0018, event.getServletContext().getContextPath());
+             WebBeansUtil.throwRuntimeExceptions(e);
+        }
     }
 
 
@@ -85,7 +101,10 @@ public class WebBeansConfigurationListen
      */
     public void contextDestroyed(ServletContextEvent event)
     {
-        this.webBeansContext.getService(ContainerLifecycle.class).stopApplication(event);
+        if (this.lifeCycle != null) {
+            this.lifeCycle.stopApplication(event);
+            this.lifeCycle = null;
+        }
         this.webBeansContext = null;
     }
 
@@ -100,7 +119,7 @@ public class WebBeansConfigurationListen
         }
 
         if (failoverService != null &&
-                failoverService.isSupportFailOver())
+            failoverService.isSupportFailOver())
         {
             Object request = event.getServletRequest();
             if(request instanceof HttpServletRequest)
@@ -121,7 +140,9 @@ public class WebBeansConfigurationListen
             elStore.destroyELContextStore();
         }
 
-        this.webBeansContext.getContextsService().endContext(RequestScoped.class, event);
+        if (this.lifeCycle != null) {
+        	this.lifeCycle.getContextService().endContext(RequestScoped.class, event);
+        }
 
         this.cleanupRequestThreadLocals();
     }



Mime
View raw message