You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2008/07/09 10:17:57 UTC

svn commit: r675113 - in /myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource: CoreClassLoaderResourceLoader.java CoreCommonScriptsResourceLoader.java

Author: matzew
Date: Wed Jul  9 01:17:56 2008
New Revision: 675113

URL: http://svn.apache.org/viewvc?rev=675113&view=rev
Log:
TRINIDAD-1149 - ApacheChart.js resource loading problems

Thanks to Andy Schwartz for this patch.
We now get a nice PERF. improvement on pages that don't contain the chart!

Modified:
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreClassLoaderResourceLoader.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreCommonScriptsResourceLoader.java

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreClassLoaderResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreClassLoaderResourceLoader.java?rev=675113&r1=675112&r2=675113&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreClassLoaderResourceLoader.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreClassLoaderResourceLoader.java Wed Jul  9 01:17:56 2008
@@ -49,6 +49,7 @@
   protected URL findResource(
     String path) throws IOException
   {
+    // Strip the version string, since it is not present in the actual file name.
     String version = CoreRenderKitResourceLoader.__getVersion();
     int index = path.indexOf(version);
     if (index >= 0)
@@ -57,6 +58,38 @@
               path.substring(index + version.length()));
     }
 
+    // Fix up "jsLibs/Debug" -> "jsLibsDebug/".
+    path = _fixJavaScriptDebugPath(path);
+
     return super.findResource(path);
   }
+
+  // LibraryScriptlet prefixes debug JS libraries with the prefix
+  // "Debug".  So, for example,  the "Foo.js" library ends up being
+  // referred to via an URL of the form "<base>/jsLibs/DebugFoo.js".
+  // Unfortunately, this is out of sync with reality, since our
+  // JS libraries actually live under a "jsLibsDebug" directory,
+  // ie. the debug "Foo.js" lives at "META-INF/adf/jsLibsDebug/Foo.js".
+  // As a result, CoreClassLoaderResourceLoader fails to locate
+  // scripts that are rendered via a LibraryScriptlet.
+  //
+  // To work around this problem, this code converts paths of the
+  // form "jsLibs/Debug" to "jsLibsDebug/", which allows our
+  // library look ups to succeed.
+  //
+  // Note that an alternate approach might be to tweak LibraryScriptlet
+  // to generate the paths that CoreClassLoaderResourceLoader expects.
+  // One issue with this is that our "Common" and "LocaleInfo" libraries
+  // are handled somewhat differently, so any changes to LibraryScriptlet
+  // will impact at least those scripts as well.  Performing this mapping
+  // here seems the least intrusive.
+  private String _fixJavaScriptDebugPath(String path)
+  {
+    return (path.indexOf(_JS_DEBUG_PATH) >= 0) ?
+      path.replaceFirst(_JS_DEBUG_PATH, _FIXED_JS_DEBUG_PATH) :
+      path;
+  }
+
+  private static final String _JS_DEBUG_PATH = "jsLibs/Debug";
+  private static final String _FIXED_JS_DEBUG_PATH = "jsLibsDebug/";
 }

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreCommonScriptsResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreCommonScriptsResourceLoader.java?rev=675113&r1=675112&r2=675113&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreCommonScriptsResourceLoader.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreCommonScriptsResourceLoader.java Wed Jul  9 01:17:56 2008
@@ -74,7 +74,6 @@
     "META-INF/adf/jsLibs/Shuttle.js",
     "META-INF/adf/jsLibs/PanelPopup.js",
     "META-INF/adf/jsLibs/PopupDialog.js",
-    "META-INF/adf/jsLibs/ApacheChart.js",
     "META-INF/adf/jsLibs/Page.js",
     "META-INF/adf/jsLibs/StatusIndicator.js",
     // XMMLHttp libraries
@@ -108,7 +107,6 @@
     "META-INF/adf/jsLibsDebug/Shuttle.js",
     "META-INF/adf/jsLibsDebug/PanelPopup.js",
     "META-INF/adf/jsLibsDebug/PopupDialog.js",
-    "META-INF/adf/jsLibsDebug/ApacheChart.js",
 
     "META-INF/adf/jsLibsDebug/Page.js",
     "META-INF/adf/jsLibsDebug/StatusIndicator.js",