openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r907609 - /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebApplicationLifeCycle.java
Date Mon, 08 Feb 2010 10:07:38 GMT
Author: struberg
Date: Mon Feb  8 10:07:38 2010
New Revision: 907609

URL: http://svn.apache.org/viewvc?rev=907609&view=rev
Log:
OWB-269 fix NPE when using WebApplicationLifeCycle in Test

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebApplicationLifeCycle.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebApplicationLifeCycle.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebApplicationLifeCycle.java?rev=907609&r1=907608&r2=907609&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebApplicationLifeCycle.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebApplicationLifeCycle.java
Mon Feb  8 10:07:38 2010
@@ -157,26 +157,32 @@
 
     public void applicationStarted(Object startupObject)
     {
-        if(startupObject != null && !(ServletContextEvent.class.isAssignableFrom(startupObject.getClass())))
+        ServletContext servletContext = null;
+        if(startupObject != null)
         {
-            throw new WebBeansException(logger.getTokenString(OWBLogConst.EXCEPT_0001));
+            if(startupObject instanceof ServletContextEvent)
+            {
+                servletContext = ((ServletContextEvent) startupObject).getServletContext();
+            }
+            else
+            {
+                throw new WebBeansException(logger.getTokenString(OWBLogConst.EXCEPT_0001));
+            }
         }
         
-        ServletContextEvent event = (ServletContextEvent)startupObject; 
-        
         // Initalize Application Context
         logger.info(OWBLogConst.INFO_0002);
         
         long begin = System.currentTimeMillis();
 
         //Application Context initialization
-        ContextFactory.initApplicationContext(event.getServletContext());
+        ContextFactory.initApplicationContext(servletContext);
         
         //Singleton context
-        ContextFactory.initSingletonContext(event.getServletContext());
+        ContextFactory.initSingletonContext(servletContext);
 
         this.discovery = ServiceLoader.getService(ScannerService.class);
-        this.discovery.init(event.getServletContext());
+        this.discovery.init(servletContext);
 
         // load all optional plugins
         PluginLoader.getInstance().startUp();
@@ -200,9 +206,7 @@
         {
             logger.debug(OWBLogConst.DEBUG_0001);
             
-            ServletContext context = event.getServletContext();
-
-            JspApplicationContext applicationCtx = JspFactory.getDefaultFactory().getJspApplicationContext(context);
+            JspApplicationContext applicationCtx = JspFactory.getDefaultFactory().getJspApplicationContext(servletContext);
             applicationCtx.addELResolver(new WebBeansELResolver());            
         }
         
@@ -213,23 +217,28 @@
 
     public void applicationEnded(Object endObject)
     {
-        logger.info(OWBLogConst.INFO_0006);
-        
-        if(endObject != null && !(ServletContextEvent.class.isAssignableFrom(endObject.getClass())))
+        ServletContext servletContext = null;
+        if(endObject != null)
         {
-            throw new WebBeansException(logger.getTokenString(OWBLogConst.EXCEPT_0002));
+            if(endObject instanceof ServletContextEvent)
+            {
+                servletContext = ((ServletContextEvent) endObject).getServletContext();
+            }
+            else
+            {
+                throw new WebBeansException(logger.getTokenString(OWBLogConst.EXCEPT_0002));
+            }
         }
-        
-        ServletContextEvent event = (ServletContextEvent)endObject;
-        
+        logger.info(OWBLogConst.INFO_0006);
+
         //Fire shut down
         this.rootManager.fireEvent(new BeforeShutdownImpl(), new Annotation[0]);
                 
         service.shutdownNow();
 
-        ContextFactory.destroyApplicationContext(event.getServletContext());
+        ContextFactory.destroyApplicationContext(servletContext);
         
-        ContextFactory.destroySingletonContext(event.getServletContext());
+        ContextFactory.destroySingletonContext(servletContext);
 
         jndiService.unbind(WebBeansConstants.WEB_BEANS_MANAGER_JNDI_NAME);
 
@@ -242,31 +251,31 @@
         //Clear singleton list
         WebBeansFinder.clearInstances();
                 
-        logger.info(OWBLogConst.INFO_0008, new Object[]{event.getServletContext().getContextPath()});
       
+        logger.info(OWBLogConst.INFO_0008, new Object[]{servletContext != null ? servletContext.getContextPath()
: null});
     }
     
     public void sessionPassivated(HttpSessionEvent event)
     {
-    	logger.info(OWBLogConst.INFO_0009, new Object[]{event.getSession().getId()});
+        logger.info(OWBLogConst.INFO_0009, new Object[]{event.getSession().getId()});
     }
-    
+
     public void sessionActivated(HttpSessionEvent event)
     {
-    	logger.info(OWBLogConst.INFO_0010, new Object[]{event.getSession().getId()});
+        logger.info(OWBLogConst.INFO_0010, new Object[]{event.getSession().getId()});
     }
-    
+
     private static class ConversationCleaner implements Runnable
     {
-    	public ConversationCleaner()
-    	{
-    		
-    	}
-    	
+        public ConversationCleaner()
+        {
+
+        }
+
         public void run()
         {
             ConversationManager.getInstance().destroyWithRespectToTimout();
 
-        }    	
+        }
     }
 
     @Override



Mime
View raw message