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 2011/09/13 20:08:07 UTC
svn commit: r1170277 - in
/myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler:
ExtendedDefaultResourceHandlerSupport.java ExtendedResourceHandlerImpl.java
filter/
Author: lu4242
Date: Tue Sep 13 18:08:07 2011
New Revision: 1170277
URL: http://svn.apache.org/viewvc?rev=1170277&view=rev
Log:
remove filter config
Modified:
myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/ExtendedDefaultResourceHandlerSupport.java
myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/ExtendedResourceHandlerImpl.java
myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/filter/
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/ExtendedDefaultResourceHandlerSupport.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/ExtendedDefaultResourceHandlerSupport.java?rev=1170277&r1=1170276&r2=1170277&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/ExtendedDefaultResourceHandlerSupport.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/ExtendedDefaultResourceHandlerSupport.java Tue Sep 13 18:08:07 2011
@@ -32,7 +32,6 @@ import org.apache.myfaces.buildtools.mav
import org.apache.myfaces.commons.resourcehandler.application.FacesServletMapping;
import org.apache.myfaces.commons.resourcehandler.config.MyFacesResourceHandlerConfigParser;
import org.apache.myfaces.commons.resourcehandler.config.element.MyFacesResourcesConfig;
-import org.apache.myfaces.commons.resourcehandler.filter.ExtendedResourceHandlerFilter;
import org.apache.myfaces.commons.resourcehandler.resource.BaseResourceHandlerSupport;
import org.apache.myfaces.commons.resourcehandler.resource.ClassLoaderResourceLoader;
import org.apache.myfaces.commons.resourcehandler.resource.ExternalContextResourceLoader;
@@ -208,72 +207,53 @@ public class ExtendedDefaultResourceHand
{
ExternalContext externalContext = facesContext.getExternalContext();
String resourceBasePath = null;
- if (facesContext.getAttributes().containsKey(ExtendedResourceHandlerFilter.EXTENDED_RESOURCE_HANDLER_FILTER_REQUEST))
+
+ //Calculate the mapping from the current request information
+ FacesServletMapping mapping = calculateFacesServletMapping(
+ externalContext.getRequestServletPath(),
+ externalContext.getRequestPathInfo());
+ //FacesServletMapping mapping = getFacesServletMapping(facesContext);
+
+ if (mapping != null)
{
- //This is a filter request, so if virtualPath is not set, no mapping is used
- String virtualPath = WebConfigParamUtils.getStringInitParameter(
- facesContext.getExternalContext(),
- ExtendedResourceHandlerFilter.INIT_PARAM_RESOURCE_HANDLER_VIRTUAL_PATH);
-
- if (virtualPath != null)
+ if (mapping.isExtensionMapping())
{
- resourceBasePath = externalContext.getRequestServletPath().substring(virtualPath.length());
+ // Mapping using a suffix. In this case we have to strip
+ // the suffix. If we have a url like:
+ // http://localhost:8080/testjsf20/javax.faces.resource/imagen.jpg.jsf?ln=dojo
+ //
+ // The servlet path is /javax.faces.resource/imagen.jpg.jsf
+ //
+ // For obtain the resource name we have to remove the .jsf suffix and
+ // the prefix ResourceHandler.RESOURCE_IDENTIFIER
+ resourceBasePath = externalContext.getRequestServletPath();
+ int stripPoint = resourceBasePath.lastIndexOf('.');
+ if (stripPoint > 0)
+ {
+ resourceBasePath = resourceBasePath.substring(0, stripPoint);
+ }
}
else
{
- resourceBasePath = externalContext.getRequestServletPath();
+ // Mapping using prefix. In this case we have to strip
+ // the prefix used for mapping. If we have a url like:
+ // http://localhost:8080/testjsf20/faces/javax.faces.resource/imagen.jpg?ln=dojo
+ //
+ // The servlet path is /faces
+ // and the path info is /javax.faces.resource/imagen.jpg
+ //
+ // For obtain the resource name we have to remove the /faces prefix and
+ // then the prefix ResourceHandler.RESOURCE_IDENTIFIER
+ resourceBasePath = externalContext.getRequestPathInfo();
}
return resourceBasePath;
}
else
{
- //Calculate the mapping from the current request information
- FacesServletMapping mapping = calculateFacesServletMapping(
- externalContext.getRequestServletPath(),
- externalContext.getRequestPathInfo());
- //FacesServletMapping mapping = getFacesServletMapping(facesContext);
-
- if (mapping != null)
- {
- if (mapping.isExtensionMapping())
- {
- // Mapping using a suffix. In this case we have to strip
- // the suffix. If we have a url like:
- // http://localhost:8080/testjsf20/javax.faces.resource/imagen.jpg.jsf?ln=dojo
- //
- // The servlet path is /javax.faces.resource/imagen.jpg.jsf
- //
- // For obtain the resource name we have to remove the .jsf suffix and
- // the prefix ResourceHandler.RESOURCE_IDENTIFIER
- resourceBasePath = externalContext.getRequestServletPath();
- int stripPoint = resourceBasePath.lastIndexOf('.');
- if (stripPoint > 0)
- {
- resourceBasePath = resourceBasePath.substring(0, stripPoint);
- }
- }
- else
- {
- // Mapping using prefix. In this case we have to strip
- // the prefix used for mapping. If we have a url like:
- // http://localhost:8080/testjsf20/faces/javax.faces.resource/imagen.jpg?ln=dojo
- //
- // The servlet path is /faces
- // and the path info is /javax.faces.resource/imagen.jpg
- //
- // For obtain the resource name we have to remove the /faces prefix and
- // then the prefix ResourceHandler.RESOURCE_IDENTIFIER
- resourceBasePath = externalContext.getRequestPathInfo();
- }
- return resourceBasePath;
- }
- else
- {
- //If no mapping is detected, just return the
- //information follows the servlet path but before
- //the query string
- return externalContext.getRequestPathInfo();
- }
+ //If no mapping is detected, just return the
+ //information follows the servlet path but before
+ //the query string
+ return externalContext.getRequestPathInfo();
}
}
@@ -287,95 +267,29 @@ public class ExtendedDefaultResourceHand
{
ExternalContext externalContext = context.getExternalContext();
- //1. Check if virtualPath has been set and if that so, use it without ask questions
- String virtualPath = WebConfigParamUtils.getStringInitParameter(
- context.getExternalContext(),
- ExtendedResourceHandlerFilter.INIT_PARAM_RESOURCE_HANDLER_VIRTUAL_PATH);
+ FacesServletMapping calculatedMapping = calculateFacesServletMapping(
+ externalContext.getRequestServletPath(),
+ externalContext.getRequestPathInfo());
- if (virtualPath != null)
+ if (!calculatedMapping.isPrefixMapping())
{
- mapping = FacesServletMapping.createPrefixMapping(virtualPath);
- }
- else
- {
- FacesServletMapping calculatedMapping = calculateFacesServletMapping(
- externalContext.getRequestServletPath(),
- externalContext.getRequestPathInfo());
+ // Scan the current configuration if there is a FacesServlet and if that so,
+ // retrieve the first prefix mapping and use it.
+ getWebConfigProvider().update(context);
+
+ WebRegistration webRegistration = getWebConfigProvider().getWebRegistration(context);
- if (!calculatedMapping.isPrefixMapping())
+ String prefix = getFacesServletPrefixMapping(context, webRegistration);
+
+ if (prefix != null)
{
- // Scan the current configuration if there is a FacesServlet and if that so,
- // retrieve the first prefix mapping and use it.
- getWebConfigProvider().update(context);
-
- WebRegistration webRegistration = getWebConfigProvider().getWebRegistration(context);
-
- String prefix = getFacesServletPrefixMapping(context, webRegistration);
-
- if (prefix != null)
- {
- mapping = FacesServletMapping.createPrefixMapping(prefix);
- }
- else
- {
- //Check filter mode
- String filterMode = WebConfigParamUtils.getStringInitParameter(externalContext,
- ExtendedResourceHandlerFilter.INIT_PARAM_USE_EXTENDED_RESOURCE_FILTER,
- ExtendedResourceHandlerFilter.INIT_PARAM_USE_EXTENDED_RESOURCE_FILTER_DEFAULT);
- boolean filterInitialized = externalContext.getApplicationMap().containsKey(
- ExtendedResourceHandlerFilter.EXTENDED_RESOURCE_HANDLER_FILTER_CALLED);
-
- //If filter mode is on
- if ( ("check".equalsIgnoreCase(filterMode) && filterInitialized) || "true".equalsIgnoreCase(filterMode))
- {
- //Assume /javax.faces.resource is mapped, so and empty prefix mapping should be used.
- mapping = FacesServletMapping.createPrefixMapping("");
- }
- else
- {
- if (context.isProjectStage(ProjectStage.Development))
- {
- Log log = LogFactory.getLog(ExtendedDefaultResourceHandlerSupport.class);
- if (log.isWarnEnabled())
- {
- log.warn("No prefix mapping or filter for ExtendedResourceHandlerImpl has been detected. ");
- }
- }
- // No filter configured, use calculated mapping instead.
- mapping = calculatedMapping;
- }
- }
+ mapping = FacesServletMapping.createPrefixMapping(prefix);
}
- }
-
- /*
- String filterMode = WebConfigParamUtils.getStringInitParameter(externalContext,
- ExtendedResourceHandlerFilter.INIT_PARAM_USE_EXTENDED_RESOURCE_FILTER,
- ExtendedResourceHandlerFilter.INIT_PARAM_USE_EXTENDED_RESOURCE_FILTER_DEFAULT);
- if ( ("check".equalsIgnoreCase(filterMode) &&
- externalContext.getApplicationMap().containsKey(ExtendedResourceHandlerFilter.EXTENDED_RESOURCE_HANDLER_FILTER_CALLED)) ||
- "true".equalsIgnoreCase(filterMode))
- {
- //Use virtualPath as valid prefix mapping
- //String virtualPath = WebConfigParamUtils.getStringInitParameter(
- virtualPath = WebConfigParamUtils.getStringInitParameter(
- context.getExternalContext(),
- ExtendedResourceHandlerFilter.INIT_PARAM_RESOURCE_HANDLER_VIRTUAL_PATH,
- ExtendedResourceHandlerFilter.INIT_PARAM_RESOURCE_VIRTUAL_PATH_DEFAULT);
-
- if (!virtualPath.endsWith(ResourceHandler.RESOURCE_IDENTIFIER))
+ else
{
- throw new FacesException("org.apache.myfaces.RESOURCE_HANDLER_VIRTUAL_PATH web config param must end with /javax.faces.resource");
+ mapping = calculatedMapping;
}
-
- mapping = FacesServletMapping.createPrefixMapping(virtualPath.substring(0, virtualPath.length()-ResourceHandler.RESOURCE_IDENTIFIER.length()));
}
- else
- {
- // No filter configured, use FacesServlet instead.
- mapping = calculateFacesServletMapping(externalContext.getRequestServletPath(),
- externalContext.getRequestPathInfo());
- }*/
attributes.put(CACHED_SERVLET_MAPPING, mapping);
}
Modified: myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/ExtendedResourceHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/ExtendedResourceHandlerImpl.java?rev=1170277&r1=1170276&r2=1170277&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/ExtendedResourceHandlerImpl.java (original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-resourcehandler/src/main/java/org/apache/myfaces/commons/resourcehandler/ExtendedResourceHandlerImpl.java Tue Sep 13 18:08:07 2011
@@ -40,7 +40,6 @@ import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletResponse;
import org.apache.myfaces.commons.resourcehandler.config.element.Library;
-import org.apache.myfaces.commons.resourcehandler.filter.ExtendedResourceHandlerFilter;
import org.apache.myfaces.commons.resourcehandler.resource.ResourceHandlerCache;
import org.apache.myfaces.commons.resourcehandler.resource.ResourceHandlerCache.ResourceValue;
import org.apache.myfaces.commons.resourcehandler.resource.ResourceLoader;
@@ -57,8 +56,6 @@ import org.apache.myfaces.commons.util.S
*/
public class ExtendedResourceHandlerImpl extends ResourceHandlerWrapper
{
-
- private static final String IS_RESOURCE_REQUEST = "org.apache.myfaces.commons.IS_RESOURCE_REQUEST";
private static final String RESOURCE_LOCALE = "org.apache.myfaces.commons.RESOURCE_LOCALE";
@@ -562,49 +559,6 @@ public class ExtendedResourceHandlerImpl
return count;
}
- @Override
- public boolean isResourceRequest(FacesContext facesContext)
- {
- if (facesContext.getAttributes().containsKey(ExtendedResourceHandlerFilter.EXTENDED_RESOURCE_HANDLER_FILTER_REQUEST))
- {
- // Since this method could be called many times we save it
- //on request map so the first time is calculated it remains
- //alive until the end of the request
- Boolean value = (Boolean) facesContext.getAttributes().get(IS_RESOURCE_REQUEST);
-
- if (value != null && value)
- {
- //return the saved value
- return value;
- }
- else
- {
- String resourceBasePath = getResourceHandlerSupport()
- .calculateResourceBasePath(facesContext);
-
- if (resourceBasePath != null
- && resourceBasePath.startsWith(ResourceHandler.RESOURCE_IDENTIFIER))
- {
- facesContext.getAttributes().put(IS_RESOURCE_REQUEST, Boolean.TRUE);
- return true;
- }
- else
- {
- facesContext.getAttributes().put(IS_RESOURCE_REQUEST, Boolean.FALSE);
- return false;
- }
- }
- }
- else
- {
- //return super.isResourceRequest(facesContext);
- //Since it is necessary to calculate the base path and we are in a filter request, it is not possible to delegate this call,
- //because other ResourceHandler implementation assume this request comes from the servlet. Later, if the servlet is a target
- //to this request, it will be processed there.
- return super.isResourceRequest(facesContext);
- }
- }
-
protected String getLocalePrefixForLocateResource()
{
String localePrefix = null;