You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2017/04/06 23:33:15 UTC
svn commit: r1790487 -
/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/resource/RootExternalContextResourceLoader.java
Author: lu4242
Date: Thu Apr 6 23:33:14 2017
New Revision: 1790487
URL: http://svn.apache.org/viewvc?rev=1790487&view=rev
Log:
MYFACES-4105 Implement extensionless mapping of views (hide /resources directory from iteration)
Modified:
myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/resource/RootExternalContextResourceLoader.java
Modified: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/resource/RootExternalContextResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/resource/RootExternalContextResourceLoader.java?rev=1790487&r1=1790486&r2=1790487&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/resource/RootExternalContextResourceLoader.java (original)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/resource/RootExternalContextResourceLoader.java Thu Apr 6 23:33:14 2017
@@ -44,7 +44,11 @@ public class RootExternalContextResource
{
private static final String CONTRACTS = "contracts";
+ private static final String RESOURCES = "resources";
+
private String contractsDirectory = null;
+
+ private String resourcesDirectory = null;
public RootExternalContextResourceLoader()
{
@@ -53,13 +57,17 @@ public class RootExternalContextResource
contractsDirectory = WebConfigParamUtils.getStringInitParameter(facesContext.getExternalContext(),
ResourceHandler.WEBAPP_CONTRACTS_DIRECTORY_PARAM_NAME, CONTRACTS);
contractsDirectory = contractsDirectory.startsWith("/") ? contractsDirectory : '/'+contractsDirectory;
+
+ resourcesDirectory = WebConfigParamUtils.getStringInitParameter(facesContext.getExternalContext(),
+ ResourceHandler.WEBAPP_RESOURCES_DIRECTORY_PARAM_NAME, RESOURCES);
+ resourcesDirectory = resourcesDirectory.startsWith("/") ? resourcesDirectory : '/'+resourcesDirectory;
}
protected Set<String> getResourcePaths(String path)
{
String correctedPath = path.startsWith("/") ? path : '/' + path;
- if (correctedPath.startsWith(contractsDirectory))
+ if (correctedPath.startsWith(contractsDirectory) || correctedPath.startsWith(resourcesDirectory))
{
// Resources under this directory should be accesed by other ContractResourceLoader
return Collections.emptySet();
@@ -85,7 +93,8 @@ public class RootExternalContextResource
try
{
String correctedResourceId = resourceId.startsWith("/") ? resourceId : "/"+resourceId;
- if (correctedResourceId.startsWith(contractsDirectory))
+ if (correctedResourceId.startsWith(contractsDirectory) ||
+ correctedResourceId.startsWith(resourcesDirectory))
{
return null;
}
@@ -118,7 +127,7 @@ public class RootExternalContextResource
{
String resourceId = resourceMeta.getResourceIdentifier();
String correctedResourceId = resourceId.startsWith("/") ? resourceId : "/"+resourceId;
- if (correctedResourceId.startsWith(contractsDirectory))
+ if (correctedResourceId.startsWith(contractsDirectory) || correctedResourceId.startsWith(resourcesDirectory))
{
return null;
}
@@ -152,23 +161,26 @@ public class RootExternalContextResource
return new RootExternalContextResourceLoaderIterator(
new ExternalContextResourceLoaderIterator(facesContext, basePath, maxDepth, options),
- contractsDirectory);
+ this.contractsDirectory, this.resourcesDirectory);
}
private static class RootExternalContextResourceLoaderIterator extends SkipMatchIterator<String>
{
private String contractsDirectory;
+ private String resourcesDirectory;
- public RootExternalContextResourceLoaderIterator(Iterator delegate, String contractsDirectory)
+ public RootExternalContextResourceLoaderIterator(Iterator delegate, String contractsDirectory,
+ String resourcesDirectory)
{
super(delegate);
this.contractsDirectory = contractsDirectory;
+ this.resourcesDirectory = resourcesDirectory;
}
@Override
protected boolean match(String instance)
{
- return instance.startsWith(contractsDirectory);
+ return instance.startsWith(contractsDirectory) || instance.startsWith(resourcesDirectory);
}
}
}