felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r789288 - /felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/AbstractWebConsolePlugin.java
Date Mon, 29 Jun 2009 11:12:25 GMT
Author: fmeschbe
Date: Mon Jun 29 11:12:25 2009
New Revision: 789288

URL: http://svn.apache.org/viewvc?rev=789288&view=rev
Log:
FELIX-1211 Lazily look up the getResource method otherwise the methods
for wrapped plugins will never be found because the instance initializer
is called *before* the WebConsolePluginAdapter sets the field to be
returned in the getResourceProvider call.

Modified:
    felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/AbstractWebConsolePlugin.java

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/AbstractWebConsolePlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/AbstractWebConsolePlugin.java?rev=789288&r1=789287&r2=789288&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/AbstractWebConsolePlugin.java
(original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/AbstractWebConsolePlugin.java
Mon Jun 29 11:12:25 2009
@@ -93,7 +93,22 @@
 
     public static final String GET_RESOURCE_METHOD_NAME = "getResource";
 
-    private final Method getResourceMethod;
+    /**
+     * The reference to the getResource method provided by the
+     * {@link #getResourceProvider()}. This is <code>null</code> if there is
+     * none or before the first check if there is one.
+     *
+     * @see #getGetResourceMethod()
+     */
+    private Method getResourceMethod;
+
+    /**
+     * flag indicating whether the getResource method has already been looked
+     * up or not. This prevens the {@link #getGetResourceMethod()} method from
+     * repeatedly looking up the resource method on plugins which do not have
+     * one.
+     */
+    private boolean getResourceMethodChecked;
 
     private BundleContext bundleContext;
 
@@ -102,10 +117,6 @@
     private String productWeb;
     private String vendorName;
 
-    {
-        getResourceMethod = getGetResourceMethod();
-    }
-
 
     //---------- HttpServlet Overwrites ----------------------------------------
 
@@ -220,8 +231,12 @@
      */
     private Method getGetResourceMethod()
     {
-        Method tmpGetResourceMethod = null;
+        // return what we know of the getResourceMethod, if we already checked
+        if (getResourceMethodChecked) {
+            return getResourceMethod;
+        }
 
+        Method tmpGetResourceMethod = null;
         Object resourceProvider = getResourceProvider();
         if ( resourceProvider != null )
         {
@@ -258,7 +273,12 @@
             }
         }
 
-        return tmpGetResourceMethod;
+        // set what we have found and prevent future lookups
+        getResourceMethod = tmpGetResourceMethod;
+        getResourceMethodChecked = true;
+
+        // now also return the method
+        return getResourceMethod;
     }
 
 
@@ -283,6 +303,7 @@
     private boolean spoolResource( HttpServletRequest request, HttpServletResponse response
) throws IOException
     {
         // no resource if no resource accessor
+        Method getResourceMethod = getGetResourceMethod();
         if ( getResourceMethod == null )
         {
             return false;



Mime
View raw message