You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by vo...@apache.org on 2023/12/01 20:39:55 UTC
(myfaces) branch 4.1.x updated (c1119fa4e -> 041d31e6f)
This is an automated email from the ASF dual-hosted git repository.
volosied pushed a change to branch 4.1.x
in repository https://gitbox.apache.org/repos/asf/myfaces.git
discard c1119fa4e Merge pull request #649 from volosied/MYFACES-4644-4.1
omit 2aef677e5 MYFACES-4644 (4.1): Enable extensionless requests for programmatic views
omit a6098fbc4 Make View#value Nonbinding
new 041d31e6f MYFACES-4644 (4.1): Enable extensionless requests for programmatic views
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (c1119fa4e)
\
N -- N -- N refs/heads/4.1.x (041d31e6f)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
(myfaces) 01/01: MYFACES-4644 (4.1): Enable extensionless requests for programmatic views
Posted by vo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
volosied pushed a commit to branch 4.1.x
in repository https://gitbox.apache.org/repos/asf/myfaces.git
commit 041d31e6f422f34531b1100679464f1097b17197
Author: Volodymyr Siedlecki <vo...@gmail.com>
AuthorDate: Tue Nov 28 16:09:04 2023 -0500
MYFACES-4644 (4.1): Enable extensionless requests for programmatic views
---
.../myfaces/application/ResourceHandlerImpl.java | 34 ++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/impl/src/main/java/org/apache/myfaces/application/ResourceHandlerImpl.java b/impl/src/main/java/org/apache/myfaces/application/ResourceHandlerImpl.java
index 19d82e94c..6f6c39a1b 100644
--- a/impl/src/main/java/org/apache/myfaces/application/ResourceHandlerImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/application/ResourceHandlerImpl.java
@@ -31,6 +31,10 @@ import org.apache.myfaces.util.ExternalContextUtils;
import org.apache.myfaces.util.lang.StringUtils;
import org.apache.myfaces.util.WebConfigParamUtils;
+import jakarta.enterprise.inject.Any;
+import jakarta.enterprise.inject.spi.Bean;
+import jakarta.enterprise.inject.spi.BeanManager;
+import jakarta.faces.annotation.View;
import jakarta.faces.application.Resource;
import jakarta.faces.application.ResourceHandler;
import jakarta.faces.application.ResourceWrapper;
@@ -40,6 +44,8 @@ import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -61,6 +67,7 @@ import jakarta.faces.application.ResourceVisitOption;
import jakarta.faces.application.ViewHandler;
import jakarta.faces.view.ViewDeclarationLanguage;
+import org.apache.myfaces.cdi.util.CDIUtils;
import org.apache.myfaces.config.webparameters.MyfacesConfig;
import org.apache.myfaces.core.api.shared.lang.Assert;
import org.apache.myfaces.core.api.shared.lang.LocaleUtils;
@@ -1697,8 +1704,31 @@ public class ResourceHandlerImpl extends ResourceHandler
Iterator it = new FilterInvalidSuffixViewResourceIterator(new ViewResourceIterator(facesContext,
getResourceHandlerSupport(), localePrefix, contracts,
contractPreferred, path, maxDepth, options), facesContext, _viewSuffixes);
-
- return StreamSupport.stream(Spliterators.spliteratorUnknownSize(it,Spliterator.DISTINCT), false);
+
+ return Stream.concat(StreamSupport.stream(Spliterators.spliteratorUnknownSize(it,Spliterator.DISTINCT),
+ false), getProgrammaticViewIds(facesContext));
+ }
+
+ private Stream<String> getProgrammaticViewIds(FacesContext facesContext)
+ {
+ ArrayList<String> views = new ArrayList<String>();
+ BeanManager beanManager = CDIUtils.getBeanManager(facesContext);
+ if(beanManager != null)
+ {
+ for(Bean<?> bean : beanManager.getBeans(Object.class, Any.Literal.INSTANCE))
+ {
+ for(Annotation anno :bean.getBeanClass().getAnnotations())
+ {
+ // ensure it is of type view (avoid cast errors such as jdk.proxy4.$Proxy17)
+ if(anno instanceof View)
+ {
+ View view = (View) anno;
+ views.add(view.value());
+ }
+ }
+ }
+ }
+ return views.stream();
}
private Set<String> loadSuffixes(ExternalContext context)