- Set of minor optimizations.
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 10 Feb 2007 02:30:04 +0000 (02:30 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 10 Feb 2007 02:30:04 +0000 (02:30 +0000)
- getServletContext is used often.
- Submitted by Arvind Srinivasan.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@505618 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/core/StandardWrapperFacade.java

index 88ac27a..c42e1d9 100644 (file)
@@ -59,6 +59,12 @@ public final class StandardWrapperFacade
     private ServletConfig config = null;
 
 
+    /**
+     * Wrapped context (facade).
+     */
+    private ServletContext context = null;
+
+
     // -------------------------------------------------- ServletConfig Methods
 
 
@@ -68,11 +74,12 @@ public final class StandardWrapperFacade
 
 
     public ServletContext getServletContext() {
-        ServletContext theContext = config.getServletContext();
-        if ((theContext != null) &&
-            (theContext instanceof ApplicationContext))
-            theContext = ((ApplicationContext) theContext).getFacade();
-        return (theContext);
+        if (context == null) {
+            context = config.getServletContext();
+            if ((context != null) && (context instanceof ApplicationContext))
+                context = ((ApplicationContext) context).getFacade();
+        }
+        return (context);
     }