code beautifying
git-svn-id: https://svn.apache.org/repos/asf/myfaces/extensions/scripting/trunk@1414701 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/resources/SourceResourceHandler.java b/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/resources/SourceResourceHandler.java
index 9215c15..66d36fd 100644
--- a/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/resources/SourceResourceHandler.java
+++ b/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/resources/SourceResourceHandler.java
@@ -31,6 +31,9 @@
/**
* @author Werner Punz (latest modification by $Author$)
* @version $Revision$ $Date$
+ *
+ * A simplified source resource handler which loads resources
+ * from a given directory which is not the webapp directory
*/
public class SourceResourceHandler extends ResourceHandlerWrapper
@@ -52,17 +55,17 @@
for (String resourceRoot : resourceRoots)
{
- File resourceFile = new File(resourceRoot + "/resources/" + libraryName + "/" + resourceName);
+ File resourceFile = new File(buildStdResourceDir(resourceName, libraryName, resourceRoot));
if (resourceFile.exists())
{
return new SourceResource(libraryName, resourceName, resourceFile);
}
- resourceFile = new File(resourceRoot + "/META-INF/resources/" + libraryName + "/" + resourceName);
+ resourceFile = new File(buildMetaInfResourceDir(resourceName, libraryName, resourceRoot));
if (resourceFile.exists())
{
return new SourceResource(libraryName, resourceName, resourceFile);
}
- resourceFile = new File(resourceRoot + "/" + libraryName + "/" + resourceName);
+ resourceFile = new File(buildRootResourceDir(resourceName, libraryName, resourceRoot));
if (resourceFile.exists())
{
return new SourceResource(libraryName, resourceName, resourceFile);
@@ -81,17 +84,17 @@
for (String resourceRoot : resourceRoots)
{
- File resourceFile = new File(resourceRoot + "/resources/" + libraryName + "/" + resourceName);
+ File resourceFile = new File(buildStdResourceDir(resourceName, libraryName, resourceRoot));
if (resourceFile.exists())
{
return new SourceResource(libraryName, resourceName, resourceFile);
}
- resourceFile = new File(resourceRoot + "/META_INF/resources/" + libraryName + "/" + resourceName);
+ resourceFile = new File(buildMetaInfResourceDir(resourceName, libraryName, resourceRoot));
if (resourceFile.exists())
{
return new SourceResource(libraryName, resourceName, resourceFile);
}
- resourceFile = new File(resourceRoot + "/" + libraryName + "/" + resourceName);
+ resourceFile = new File(buildRootResourceDir(resourceName, libraryName, resourceRoot));
if (resourceFile.exists())
{
return new SourceResource(libraryName, resourceName, resourceFile);
@@ -101,6 +104,21 @@
return _wrapped.createResource(resourceName, libraryName);
}
+ private String buildMetaInfResourceDir(String resourceName, String libraryName, String resourceRoot)
+ {
+ return resourceRoot + "/META-INF/resources/" + libraryName + "/" + resourceName;
+ }
+
+ private String buildStdResourceDir(String resourceName, String libraryName, String resourceRoot)
+ {
+ return resourceRoot + "/resources/" + libraryName + "/" + resourceName;
+ }
+
+ private String buildRootResourceDir(String resourceName, String libraryName, String resourceRoot)
+ {
+ return resourceRoot + "/" + libraryName + "/" + resourceName;
+ }
+
@Override
public boolean isResourceRequest(FacesContext context)
{