myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From we...@apache.org
Subject svn commit: r1414701 - /myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/resources/SourceResourceHandler.java
Date Wed, 28 Nov 2012 14:10:07 GMT
Author: werpu
Date: Wed Nov 28 14:10:06 2012
New Revision: 1414701

URL: http://svn.apache.org/viewvc?rev=1414701&view=rev
Log:
code beautifying

Modified:
    myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/resources/SourceResourceHandler.java

Modified: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/resources/SourceResourceHandler.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/resources/SourceResourceHandler.java?rev=1414701&r1=1414700&r2=1414701&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/resources/SourceResourceHandler.java
(original)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/resources/SourceResourceHandler.java
Wed Nov 28 14:10:06 2012
@@ -31,6 +31,9 @@ import java.util.List;
 /**
  * @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 @@ public class SourceResourceHandler exten
 
         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 @@ public class SourceResourceHandler exten
 
         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 @@ public class SourceResourceHandler exten
         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)
     {



Mime
View raw message