You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2019/05/02 08:26:23 UTC
[myfaces] branch master updated: MYFACES-4289
This is an automated email from the ASF dual-hosted git repository.
tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git
The following commit(s) were added to refs/heads/master by this push:
new ce332a6 MYFACES-4289
ce332a6 is described below
commit ce332a6150524245d151cfc35155fd161ac32b72
Author: Thomas Andraschko <ta...@apache.org>
AuthorDate: Thu May 2 10:26:16 2019 +0200
MYFACES-4289
---
.../application/FacesServletMappingUtils.java | 69 +++++++++++++++-------
1 file changed, 48 insertions(+), 21 deletions(-)
diff --git a/impl/src/main/java/org/apache/myfaces/application/FacesServletMappingUtils.java b/impl/src/main/java/org/apache/myfaces/application/FacesServletMappingUtils.java
index c6e0393..ade978e 100644
--- a/impl/src/main/java/org/apache/myfaces/application/FacesServletMappingUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/application/FacesServletMappingUtils.java
@@ -185,38 +185,65 @@ public class FacesServletMappingUtils
{
try
{
- ServletRegistration facesServletRegistration = getFacesServletRegistration(
- facesContext, servletContext);
- if (facesServletRegistration != null)
+ Map<String, ? extends ServletRegistration> servletRegistrations = servletContext.getServletRegistrations();
+ if (servletRegistrations != null)
{
FacesServletMapping facesExtensionMapping = null;
FacesServletMapping facesPrefixMapping = null;
FacesServletMapping facesExactMapping = null;
- try
+ ServletRegistration facesServletRegistration = getFacesServletRegistration(
+ facesContext, servletContext);
+
+ for (ServletRegistration servletRegistration : servletRegistrations.values())
{
- String[] mappings = getFacesServletMappings(facesContext, servletContext);
- for (String mapping : mappings)
+ try
{
- if (isExtensionMapping(mapping))
+ if (facesServletRegistration.getClassName().equals(servletRegistration.getClassName()))
{
- facesExtensionMapping = FacesServletMapping.createExtensionMapping(
- extractExtension(mapping));
+ // get the cached one
+ String[] mappings = getFacesServletMappings(facesContext, servletContext);
+ for (String mapping : mappings)
+ {
+ if (isExtensionMapping(mapping))
+ {
+ facesExtensionMapping = FacesServletMapping.createExtensionMapping(
+ extractExtension(mapping));
+ }
+ else if (isPrefixMapping(mapping))
+ {
+ facesPrefixMapping = FacesServletMapping.createPrefixMapping(
+ extractPrefix(mapping));
+ }
+ else if (allowExactMatch && mapping.startsWith("/") && mapping.equals(servletPath))
+ {
+ facesExactMapping = FacesServletMapping.createExactMapping(servletPath);
+ }
+ }
}
- else if (isPrefixMapping(mapping))
+ else
{
- facesPrefixMapping = FacesServletMapping.createPrefixMapping(
- extractPrefix(mapping));
- }
- else if (allowExactMatch && mapping.startsWith("/") && mapping.equals(servletPath))
- {
- facesExactMapping = FacesServletMapping.createExactMapping(servletPath);
- }
+ Collection<String> mappings = servletRegistration.getMappings();
+ //This is not a FacesServlet mapping.
+ //It could be a non-faces request, we need to look for exact mapping to servletPath
+ //this happens with richfaces resources
+ for (String mapping : mappings)
+ {
+ if (mapping.startsWith("/") && mapping.endsWith("/*"))
+ {
+ mapping = mapping.substring(0, mapping.length()-2);
+ }
+ if (mapping.equals(servletPath))
+ {
+ return FacesServletMapping.createPrefixMapping(mapping);
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ //No op
}
- }
- catch (Exception ex)
- {
- //No op
}
// Choose exact mapping if preferred.