shiro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lhazlew...@apache.org
Subject svn commit: r1479219 - /shiro/trunk/web/src/main/java/org/apache/shiro/web/env/EnvironmentLoader.java
Date Sat, 04 May 2013 23:13:04 GMT
Author: lhazlewood
Date: Sat May  4 23:13:04 2013
New Revision: 1479219

URL: http://svn.apache.org/r1479219
Log:
SHIRO-387: applied recommended servletContext attribute-based suggestion

Modified:
    shiro/trunk/web/src/main/java/org/apache/shiro/web/env/EnvironmentLoader.java

Modified: shiro/trunk/web/src/main/java/org/apache/shiro/web/env/EnvironmentLoader.java
URL: http://svn.apache.org/viewvc/shiro/trunk/web/src/main/java/org/apache/shiro/web/env/EnvironmentLoader.java?rev=1479219&r1=1479218&r2=1479219&view=diff
==============================================================================
--- shiro/trunk/web/src/main/java/org/apache/shiro/web/env/EnvironmentLoader.java (original)
+++ shiro/trunk/web/src/main/java/org/apache/shiro/web/env/EnvironmentLoader.java Sat May
 4 23:13:04 2013
@@ -108,11 +108,6 @@ public class EnvironmentLoader {
     private static final Logger log = LoggerFactory.getLogger(EnvironmentLoader.class);
 
     /**
-     * The Shiro environment (object graph) managed by this loader.
-     */
-    private WebEnvironment environment;
-
-    /**
      * Initializes Shiro's {@link WebEnvironment} instance for the specified {@code ServletContext}
based on the
      * {@link #CONFIG_LOCATIONS_PARAM} value.
      *
@@ -135,8 +130,9 @@ public class EnvironmentLoader {
         long startTime = System.currentTimeMillis();
 
         try {
-            this.environment = createEnvironment(servletContext);
-            servletContext.setAttribute(ENVIRONMENT_ATTRIBUTE_KEY, this.environment);
+
+            WebEnvironment environment = createEnvironment(servletContext);
+            servletContext.setAttribute(ENVIRONMENT_ATTRIBUTE_KEY,environment);
 
             log.debug("Published WebEnvironment as ServletContext attribute with name [{}]",
                     ENVIRONMENT_ATTRIBUTE_KEY);
@@ -146,7 +142,7 @@ public class EnvironmentLoader {
                 log.info("Shiro environment initialized in {} ms.", elapsed);
             }
 
-            return this.environment;
+            return environment;
         } catch (RuntimeException ex) {
             log.error("Shiro environment initialization failed", ex);
             servletContext.setAttribute(ENVIRONMENT_ATTRIBUTE_KEY, ex);
@@ -239,7 +235,8 @@ public class EnvironmentLoader {
     public void destroyEnvironment(ServletContext servletContext) {
         servletContext.log("Cleaning up Shiro Environment");
         try {
-            LifecycleUtils.destroy(this.environment);
+            Object environment = servletContext.getAttribute(ENVIRONMENT_ATTRIBUTE_KEY);
+            LifecycleUtils.destroy(environment);
         } finally {
             servletContext.removeAttribute(ENVIRONMENT_ATTRIBUTE_KEY);
         }



Mime
View raw message