Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Myfaces 4644 5.0 #650

Merged
merged 2 commits into from
Dec 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
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;
Expand All @@ -40,6 +44,8 @@
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;
Expand All @@ -61,6 +67,7 @@
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;
Expand Down Expand Up @@ -1697,8 +1704,31 @@ public Stream<String> getViewResources(FacesContext facesContext,
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)
Expand Down