You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by st...@apache.org on 2011/04/16 22:57:19 UTC
svn commit: r1094052 - in
/myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler:
AdvancedResource.java AdvancedResourceHandler.java
Author: struberg
Date: Sat Apr 16 20:57:18 2011
New Revision: 1094052
URL: http://svn.apache.org/viewvc?rev=1094052&view=rev
Log:
also look for resources in the webapp folder
Modified:
myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/AdvancedResource.java
myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/AdvancedResourceHandler.java
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/AdvancedResource.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/AdvancedResource.java?rev=1094052&r1=1094051&r2=1094052&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/AdvancedResource.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/AdvancedResource.java Sat Apr 16 20:57:18 2011
@@ -27,6 +27,7 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
@@ -175,7 +176,22 @@ public class AdvancedResource extends Re
@Override
public URL getURL()
{
- return ResourceUtils.getContextClassLoader().getResource(BASE_DIR + getInternalResourcePath());
+ URL resourceUrl = ResourceUtils.getContextClassLoader().getResource(BASE_DIR + getInternalResourcePath());
+
+ if (resourceUrl == null)
+ {
+ // we need to check the META-INF/resources directly in the webapp
+ try
+ {
+ resourceUrl = FacesContext.getCurrentInstance().getExternalContext().getResource("/" + BASE_DIR + getInternalResourcePath());
+ }
+ catch (MalformedURLException e)
+ {
+ return null;
+ }
+ }
+
+ return resourceUrl;
}
@Override
@@ -373,7 +389,13 @@ public class AdvancedResource extends Re
private InputStream getUncompressedInputStream() throws IOException
{
- return ResourceUtils.getContextClassLoader().getResourceAsStream(BASE_DIR + getInternalResourcePath());
+ InputStream is = ResourceUtils.getContextClassLoader().getResourceAsStream(BASE_DIR + getInternalResourcePath());
+ if (is== null)
+ {
+ // we need to check the META-INF/resources directly in the webapp
+ is = FacesContext.getCurrentInstance().getExternalContext().getResourceAsStream("/" + BASE_DIR + getInternalResourcePath());
+ }
+ return is;
}
private InputStream getCompressedInputStream(FacesContext facesContext) throws IOException
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/AdvancedResourceHandler.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/AdvancedResourceHandler.java?rev=1094052&r1=1094051&r2=1094052&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/AdvancedResourceHandler.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/AdvancedResourceHandler.java Sat Apr 16 20:57:18 2011
@@ -26,34 +26,40 @@ import javax.faces.application.ResourceH
import javax.faces.context.FacesContext;
/**
- * Custom JSF 2 ResourceHandler implementation, supporting:
- * - relative paths between resources (css files referencing images without using #resource['..'])
- * - caching resources in the client (disabled if ProjectStage == Development)
- * - GZIP compression and local cache in tmp dir (disabled if ProjectStage == Development)
- * - i18n (supporting country code and language).
+ * <p>Custom JSF 2 ResourceHandler implementation, supporting:</p>
+ * <ul>
+ * <li>relative paths between resources (css files referencing images without using #resource['..'])</li>
+ * <li>caching resources in the client (disabled if ProjectStage == Development)</li>
+ * <li>GZIP compression and local cache in tmp dir (disabled if ProjectStage == Development)</li>
+ * <li>i18n (supporting country code and language).</li>
+ * </ul>
*
* The i18n mechanism looks up the resource in the following order (e.g. current Locale is "de_AT"):
- * 1. libraryName/de_AT/resourceName
- * 2. libraryName/de/resourceName
- * 3. libraryName/resourceName
+ * <ol>
+ * <li>libraryName/de_AT/resourceName</li>
+ * <li>libraryName/de/resourceName</li>
+ * <li>libraryName/resourceName</li>
+ * </ol>
*
* Standard features NOT available in this ResourceHandler:
- * - Support for ValueExpressions in resource files
+ * <ul>
+ * <li>Support for ValueExpressions in resource files</li>
+ * </ul>
+ *
+ * <p>Libraries handled by this ResourceHandler must be specified in
+ * META-INF/advanced-resources.xml in the following format:</p>
+ * <pre>
+ * <advanced-resources>
+ * <libraries>
+ * <library>library1</library>
+ * <library>library2</library>
+ * </libraries>
+ * </advanced-resources>
+ * </pre>
*
- * Libraries handled by this ResourceHandler must be specified in
- * META-INF/advanced-resources.xml in the following format:
- *
- * <advanced-resources>
- * <libraries>
- * <library>library1</library>
- * <library>library2</library>
- * </libraries>
- * </advanced-resources>
- *
- *
- * ATTENTION: This ResourceHandler only works with prefix mapping. Please make sure your application
+ * <p>ATTENTION: This ResourceHandler only works with prefix mapping. Please make sure your application
* uses prefix mapping ONLY (like e.g. /faces or /jsf) or at least provides the prefix mapping "/faces"
- * for the FacesServlet.
+ * for the FacesServlet.</p>
*
* @author Jakob Korherr
*/