You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2011/10/18 00:52:48 UTC

svn commit: r1185424 - /tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java

Author: hlship
Date: Mon Oct 17 22:52:48 2011
New Revision: 1185424

URL: http://svn.apache.org/viewvc?rev=1185424&view=rev
Log:
TAP5-1251: Spring integration should not assume the external context is successfully initialized

Modified:
    tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java

Modified: tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java?rev=1185424&r1=1185423&r2=1185424&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java (original)
+++ tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java Mon Oct 17 22:52:48 2011
@@ -32,6 +32,7 @@ import org.springframework.context.Appli
 import org.springframework.core.SpringVersion;
 import org.springframework.web.context.ConfigurableWebApplicationContext;
 import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
 
 import javax.servlet.ServletContext;
 import java.util.Collections;
@@ -77,10 +78,10 @@ public class SpringModuleDef implements 
      */
     protected ApplicationContext locateApplicationContext(ServletContext servletContext)
     {
-        ApplicationContext context = (ApplicationContext) servletContext
-                .getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
+        ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
 
         if (context == null)
+        {
             throw new NullPointerException(
                     String
                             .format(
@@ -88,6 +89,8 @@ public class SpringModuleDef implements 
                                             + "You should either re-enable Tapestry as the creator of the ApplicationContext, or "
                                             + "add a Spring ContextLoaderListener to web.xml.",
                                     WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE));
+        }
+
         return context;
     }