From 9566c88623b3851c10585550803d5d27bb6dea73 Mon Sep 17 00:00:00 2001 From: Eclipse Mojarra Bot Date: Tue, 7 May 2024 14:13:52 +0000 Subject: [PATCH 01/16] Prepare release org.glassfish:mojarra-parent:4.1.0 --- action/pom.xml | 2 +- cdi/pom.xml | 2 +- impl/pom.xml | 2 +- pom.xml | 2 +- rest/pom.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/action/pom.xml b/action/pom.xml index 895aeae617..371cdf2b55 100644 --- a/action/pom.xml +++ b/action/pom.xml @@ -22,7 +22,7 @@ org.glassfish mojarra-parent - 4.1.0-SNAPSHOT + 4.1.0 org.eclipse.mojarra diff --git a/cdi/pom.xml b/cdi/pom.xml index e660e12e2a..511205fb2b 100644 --- a/cdi/pom.xml +++ b/cdi/pom.xml @@ -22,7 +22,7 @@ org.glassfish mojarra-parent - 4.1.0-SNAPSHOT + 4.1.0 org.eclipse.mojarra diff --git a/impl/pom.xml b/impl/pom.xml index 6aac2895b5..0b5e833362 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -29,7 +29,7 @@ org.glassfish mojarra-parent - 4.1.0-SNAPSHOT + 4.1.0 jakarta.faces diff --git a/pom.xml b/pom.xml index adecbfe027..9efd5ff372 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.glassfish mojarra-parent - 4.1.0-SNAPSHOT + 4.1.0 pom Mojarra ${project.version} - Project diff --git a/rest/pom.xml b/rest/pom.xml index 8c9db65e86..3870c4dcc3 100644 --- a/rest/pom.xml +++ b/rest/pom.xml @@ -22,7 +22,7 @@ org.glassfish mojarra-parent - 4.1.0-SNAPSHOT + 4.1.0 org.eclipse.mojarra From 5ef2c016a8f1d56a5a7864128d6ea5cd98bb0af8 Mon Sep 17 00:00:00 2001 From: Eclipse Mojarra Bot Date: Tue, 7 May 2024 14:21:05 +0000 Subject: [PATCH 02/16] Prepare next development cycle for 4.1.1-SNAPSHOT --- action/pom.xml | 2 +- cdi/pom.xml | 2 +- impl/pom.xml | 2 +- pom.xml | 2 +- rest/pom.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/action/pom.xml b/action/pom.xml index 371cdf2b55..c19ac762ee 100644 --- a/action/pom.xml +++ b/action/pom.xml @@ -22,7 +22,7 @@ org.glassfish mojarra-parent - 4.1.0 + 4.1.1-SNAPSHOT org.eclipse.mojarra diff --git a/cdi/pom.xml b/cdi/pom.xml index 511205fb2b..ede3ea7598 100644 --- a/cdi/pom.xml +++ b/cdi/pom.xml @@ -22,7 +22,7 @@ org.glassfish mojarra-parent - 4.1.0 + 4.1.1-SNAPSHOT org.eclipse.mojarra diff --git a/impl/pom.xml b/impl/pom.xml index 0b5e833362..8ddd3b189b 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -29,7 +29,7 @@ org.glassfish mojarra-parent - 4.1.0 + 4.1.1-SNAPSHOT jakarta.faces diff --git a/pom.xml b/pom.xml index 9efd5ff372..9535399f84 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.glassfish mojarra-parent - 4.1.0 + 4.1.1-SNAPSHOT pom Mojarra ${project.version} - Project diff --git a/rest/pom.xml b/rest/pom.xml index 3870c4dcc3..ab83b5b2e4 100644 --- a/rest/pom.xml +++ b/rest/pom.xml @@ -22,7 +22,7 @@ org.glassfish mojarra-parent - 4.1.0 + 4.1.1-SNAPSHOT org.eclipse.mojarra From 37dbd24374ebc9ac93b5174fdfd390abf59240e0 Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Sat, 18 May 2024 11:07:57 -0400 Subject: [PATCH 03/16] Fix https://github.com/jakartaee/faces/issues/1906 the taglib should not accept 'var' attribute of UISelectItems as a ValueExpression --- .../com/sun/faces/metadata/taglib/faces.core.taglib.xml | 2 -- .../com/sun/faces/metadata/taglib/faces.html.taglib.xml | 1 - 2 files changed, 3 deletions(-) diff --git a/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.core.taglib.xml b/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.core.taglib.xml index 4b628ea517..443df3f774 100644 --- a/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.core.taglib.xml +++ b/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.core.taglib.xml @@ -1409,7 +1409,6 @@ of POJOs. ]]> var false - java.lang.String @@ -1490,7 +1489,6 @@ of POJOs. so that it may be referred to in EL for the value of other attributes of any nested component. ]]> var - java.lang.String var false - java.lang.String From cefcf72942e5c0ee067c97d8c5e33302aca972ea Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Mon, 20 May 2024 06:56:41 -0400 Subject: [PATCH 04/16] Fix https://github.com/jakartaee/faces/issues/1906; scanned remaining occurrences whereby setValueExpression() throws IllegalArgumentException --- .../com/sun/faces/metadata/taglib/faces.core.taglib.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.core.taglib.xml b/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.core.taglib.xml index 443df3f774..db866ecf66 100644 --- a/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.core.taglib.xml +++ b/impl/src/main/resources/com/sun/faces/metadata/taglib/faces.core.taglib.xml @@ -2904,7 +2904,6 @@ public class BackingBean implements PasswordHolder, Cloneable { ]]> channel true - java.lang.String @@ -2921,7 +2920,6 @@ public class BackingBean implements PasswordHolder, Cloneable { ]]> scope false - java.lang.String From ac7d778c66324552ceba93237ca99236496d7006 Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Fri, 31 May 2024 10:40:05 -0400 Subject: [PATCH 05/16] https://github.com/eclipse-ee4j/mojarra/issues/5451 remove JAX-WS dependency as it has been removed from Jakarta EE 11 --- impl/pom.xml | 8 -- .../DelegatedWebServiceRefScanner.java | 68 --------------- .../annotation/WebServiceRefHandler.java | 80 ----------------- .../annotation/WebServiceRefScanner.java | 87 ------------------- 4 files changed, 243 deletions(-) delete mode 100644 impl/src/main/java/com/sun/faces/application/annotation/DelegatedWebServiceRefScanner.java delete mode 100644 impl/src/main/java/com/sun/faces/application/annotation/WebServiceRefHandler.java delete mode 100644 impl/src/main/java/com/sun/faces/application/annotation/WebServiceRefScanner.java diff --git a/impl/pom.xml b/impl/pom.xml index 6aac2895b5..24a4893160 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -130,14 +130,6 @@ true - - jakarta.xml.ws - jakarta.xml.ws-api - 4.0.2 - provided - true - - jakarta.annotation jakarta.annotation-api diff --git a/impl/src/main/java/com/sun/faces/application/annotation/DelegatedWebServiceRefScanner.java b/impl/src/main/java/com/sun/faces/application/annotation/DelegatedWebServiceRefScanner.java deleted file mode 100644 index 40ea487fa3..0000000000 --- a/impl/src/main/java/com/sun/faces/application/annotation/DelegatedWebServiceRefScanner.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0, which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception, which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - */ - -package com.sun.faces.application.annotation; - -import java.lang.annotation.Annotation; - -import jakarta.xml.ws.WebServiceRef; - -/** - * Scanner implementation responsible for {@link WebServiceRef} annotations. - * - *

- * Note this will delegate down to the WebServiceRefScanner so we can fail gracefully when JavaEE is not available. - *

- */ -class DelegatedWebServiceRefScanner implements Scanner { - - private Scanner delegate; - - public DelegatedWebServiceRefScanner() { - try { - delegate = new WebServiceRefScanner(); - } catch (Throwable throwable) { - throwable.printStackTrace(System.err); - } - } - - /** - * Delegate to the actual WebServiceRef scanner. - * - * @return the annotation. - */ - @Override - public Class getAnnotation() { - if (delegate != null) { - return delegate.getAnnotation(); - } - return null; - } - - /** - * Delegate to the actual EBJ scanner. - * - * @param clazz the class. - * @return the runtime annotation handler. - */ - @Override - public RuntimeAnnotationHandler scan(Class clazz) { - if (delegate != null) { - return delegate.scan(clazz); - } - return null; - } -} diff --git a/impl/src/main/java/com/sun/faces/application/annotation/WebServiceRefHandler.java b/impl/src/main/java/com/sun/faces/application/annotation/WebServiceRefHandler.java deleted file mode 100644 index ba0aaa9334..0000000000 --- a/impl/src/main/java/com/sun/faces/application/annotation/WebServiceRefHandler.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0, which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception, which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - */ - -package com.sun.faces.application.annotation; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import jakarta.faces.context.FacesContext; -import jakarta.xml.ws.WebServiceRef; - -/** - * {@link RuntimeAnnotationHandler} responsible for processing {@link WebServiceRef} annotations. - */ -class WebServiceRefHandler extends JndiHandler implements RuntimeAnnotationHandler { - - private final Field[] fields; - private final WebServiceRef[] fieldAnnotations; - private final Method[] methods; - private final WebServiceRef[] methodAnnotations; - - public WebServiceRefHandler(Field[] fields, WebServiceRef[] fieldAnnotations, Method[] methods, WebServiceRef[] methodAnnotations) { - this.fields = fields; - this.fieldAnnotations = fieldAnnotations; - this.methods = methods; - this.methodAnnotations = methodAnnotations; - } - - @SuppressWarnings({ "UnusedDeclaration" }) - @Override - public void apply(FacesContext ctx, Object... params) { - Object object = params[0]; - for (int i = 0; i < fields.length; i++) { - applyToField(ctx, fields[0], fieldAnnotations[0], object); - } - - for (int i = 0; i < methods.length; i++) { - applyToMethod(ctx, methods[i], methodAnnotations[i], object); - } - } - - private void applyToField(FacesContext facesContext, Field field, WebServiceRef ref, Object instance) { - Object value = null; - /* - * if (ref.lookup() != null && !"".equals(ref.lookup().trim())) { value = lookup(facesContext, ref.lookup()); } else - */ - if (ref.name() != null && !"".equals(ref.name().trim())) { - value = lookup(facesContext, JAVA_COMP_ENV + ref.name()); - } else { - value = lookup(facesContext, field.getName()); - } - setField(facesContext, field, instance, value); - } - - private void applyToMethod(FacesContext facesContext, Method method, WebServiceRef ref, Object instance) { - if (method.getName().startsWith("set")) { - Object value = null; - /* - * if (ref.lookup() != null && !"".equals(ref.lookup().trim())) { value = lookup(facesContext, ref.lookup()); } else - */ - if (ref.name() != null && !"".equals(ref.name().trim())) { - value = lookup(facesContext, JAVA_COMP_ENV + ref.name()); - } - invokeMethod(facesContext, method, instance, value); - } - } -} diff --git a/impl/src/main/java/com/sun/faces/application/annotation/WebServiceRefScanner.java b/impl/src/main/java/com/sun/faces/application/annotation/WebServiceRefScanner.java deleted file mode 100644 index d8414963b6..0000000000 --- a/impl/src/main/java/com/sun/faces/application/annotation/WebServiceRefScanner.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0, which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception, which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - */ - -package com.sun.faces.application.annotation; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.ArrayList; - -import com.sun.faces.util.Util; - -import jakarta.xml.ws.WebServiceRef; - -/** - * Scanner implementation responsible for {@link WebServiceRef} annotations. - */ -class WebServiceRefScanner implements Scanner { - - /** - * Get the annotation we handle. - * - * @return the annotation we handle. - */ - @Override - public Class getAnnotation() { - return WebServiceRef.class; - } - - /** - * Scan the specified class for the given annotation. - * - * @param clazz the class. - * @return the runtime annotation handler. - * @todo Make sure we get all the fields, handle method and class based injection, handle WebServiceRefs. - */ - @Override - public RuntimeAnnotationHandler scan(Class clazz) { - Util.notNull("clazz", clazz); - WebServiceRefHandler handler = null; - - ArrayList classAnnotations = new ArrayList<>(); - WebServiceRef classAnnotation = clazz.getAnnotation(WebServiceRef.class); - if (classAnnotation != null) { - classAnnotations.add(classAnnotation); - } - ArrayList fieldAnnotations = new ArrayList<>(); - ArrayList fields = new ArrayList<>(); - - for (Field field : clazz.getDeclaredFields()) { - WebServiceRef fieldAnnotation = field.getAnnotation(WebServiceRef.class); - if (fieldAnnotation != null) { - fieldAnnotations.add(fieldAnnotation); - fields.add(field); - } - } - - ArrayList methodAnnotations = new ArrayList<>(); - ArrayList methods = new ArrayList<>(); - for (Method method : clazz.getDeclaredMethods()) { - WebServiceRef methodAnnotation = method.getAnnotation(WebServiceRef.class); - if (methodAnnotation != null) { - methodAnnotations.add(methodAnnotation); - methods.add(method); - } - } - - if (!classAnnotations.isEmpty() || !fieldAnnotations.isEmpty()) { - handler = new WebServiceRefHandler(fields.toArray(new Field[0]), fieldAnnotations.toArray(new WebServiceRef[0]), - methods.toArray(new Method[0]), methodAnnotations.toArray(new WebServiceRef[0])); - } - return handler; - } -} From b3bbc96c8a7d86f490ac234018b34ddfbda8f872 Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Fri, 31 May 2024 14:00:15 -0400 Subject: [PATCH 06/16] Fixed compilation error in unit test after removal of JAX-WS, apparently it transitively pulled a JAXB dependency for nothing https://github.com/eclipse-ee4j/mojarra/issues/5451 --- .../java/com/sun/faces/util/ByteArrayGuardAESCTRTest.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/impl/src/test/java/com/sun/faces/util/ByteArrayGuardAESCTRTest.java b/impl/src/test/java/com/sun/faces/util/ByteArrayGuardAESCTRTest.java index d4740f76b6..018b1c2047 100644 --- a/impl/src/test/java/com/sun/faces/util/ByteArrayGuardAESCTRTest.java +++ b/impl/src/test/java/com/sun/faces/util/ByteArrayGuardAESCTRTest.java @@ -21,12 +21,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import java.security.InvalidKeyException; +import java.util.Base64; import org.junit.jupiter.api.Test; -import jakarta.xml.bind.DatatypeConverter; - - public class ByteArrayGuardAESCTRTest { @Test @@ -49,7 +47,7 @@ public void testDecryptValueWithoutIvBytes() throws InvalidKeyException { ByteArrayGuardAESCTR sut = new ByteArrayGuardAESCTR(); String value = "noIV"; - byte[] bytes = DatatypeConverter.parseBase64Binary(value); + byte[] bytes = Base64.getDecoder().decode(value); assertTrue(bytes.length < 16); assertThrows(InvalidKeyException.class, () -> sut.decrypt(value)); From d2420bf80db4e2d373f41b7f460b6e5e8540a476 Mon Sep 17 00:00:00 2001 From: Eclipse Mojarra Bot Date: Tue, 25 Jun 2024 10:18:41 +0000 Subject: [PATCH 07/16] Prepare release org.glassfish:mojarra-parent:4.1.1 --- action/pom.xml | 2 +- cdi/pom.xml | 2 +- impl/pom.xml | 2 +- pom.xml | 2 +- rest/pom.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/action/pom.xml b/action/pom.xml index c19ac762ee..414a96fca8 100644 --- a/action/pom.xml +++ b/action/pom.xml @@ -22,7 +22,7 @@ org.glassfish mojarra-parent - 4.1.1-SNAPSHOT + 4.1.1 org.eclipse.mojarra diff --git a/cdi/pom.xml b/cdi/pom.xml index ede3ea7598..c7453268b8 100644 --- a/cdi/pom.xml +++ b/cdi/pom.xml @@ -22,7 +22,7 @@ org.glassfish mojarra-parent - 4.1.1-SNAPSHOT + 4.1.1 org.eclipse.mojarra diff --git a/impl/pom.xml b/impl/pom.xml index 8a1f6a3bbd..d3020e9378 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -29,7 +29,7 @@ org.glassfish mojarra-parent - 4.1.1-SNAPSHOT + 4.1.1 jakarta.faces diff --git a/pom.xml b/pom.xml index 9535399f84..cf564ff6f4 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.glassfish mojarra-parent - 4.1.1-SNAPSHOT + 4.1.1 pom Mojarra ${project.version} - Project diff --git a/rest/pom.xml b/rest/pom.xml index ab83b5b2e4..a47c33af28 100644 --- a/rest/pom.xml +++ b/rest/pom.xml @@ -22,7 +22,7 @@ org.glassfish mojarra-parent - 4.1.1-SNAPSHOT + 4.1.1 org.eclipse.mojarra From 3c4cc3ab427f07ab683fed7fafaec2c64e66fb64 Mon Sep 17 00:00:00 2001 From: Eclipse Mojarra Bot Date: Tue, 25 Jun 2024 10:21:40 +0000 Subject: [PATCH 08/16] Prepare next development cycle for 4.1.2-SNAPSHOT --- action/pom.xml | 2 +- cdi/pom.xml | 2 +- impl/pom.xml | 2 +- pom.xml | 2 +- rest/pom.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/action/pom.xml b/action/pom.xml index 414a96fca8..2766f61168 100644 --- a/action/pom.xml +++ b/action/pom.xml @@ -22,7 +22,7 @@ org.glassfish mojarra-parent - 4.1.1 + 4.1.2-SNAPSHOT org.eclipse.mojarra diff --git a/cdi/pom.xml b/cdi/pom.xml index c7453268b8..0774e40320 100644 --- a/cdi/pom.xml +++ b/cdi/pom.xml @@ -22,7 +22,7 @@ org.glassfish mojarra-parent - 4.1.1 + 4.1.2-SNAPSHOT org.eclipse.mojarra diff --git a/impl/pom.xml b/impl/pom.xml index d3020e9378..3b0746b97e 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -29,7 +29,7 @@ org.glassfish mojarra-parent - 4.1.1 + 4.1.2-SNAPSHOT jakarta.faces diff --git a/pom.xml b/pom.xml index cf564ff6f4..0d585b72ed 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.glassfish mojarra-parent - 4.1.1 + 4.1.2-SNAPSHOT pom Mojarra ${project.version} - Project diff --git a/rest/pom.xml b/rest/pom.xml index a47c33af28..213ef7b479 100644 --- a/rest/pom.xml +++ b/rest/pom.xml @@ -22,7 +22,7 @@ org.glassfish mojarra-parent - 4.1.1 + 4.1.2-SNAPSHOT org.eclipse.mojarra From c87207f38dacc57939631a280c4d4c0b6f6bb727 Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Sat, 13 Jul 2024 11:47:37 -0400 Subject: [PATCH 09/16] Fix 5457: revert removal of getBeanClass on Faces artifact producers; adjust it to check if Weld is used and if so return CdiExtension.class --- .../sun/faces/cdi/ApplicationMapProducer.java | 12 ++++-- .../java/com/sun/faces/cdi/CdiExtension.java | 38 +++++++++---------- .../java/com/sun/faces/cdi/CdiProducer.java | 15 +++++++- .../main/java/com/sun/faces/cdi/CdiUtils.java | 7 ++++ .../com/sun/faces/cdi/ComponentProducer.java | 8 +++- .../faces/cdi/CompositeComponentProducer.java | 8 +++- .../cdi/DataModelClassesMapProducer.java | 11 ++++-- .../faces/cdi/ExternalContextProducer.java | 10 +++-- .../sun/faces/cdi/FacesContextProducer.java | 10 +++-- .../java/com/sun/faces/cdi/FlashProducer.java | 9 +++-- .../com/sun/faces/cdi/FlowMapProducer.java | 12 ++++-- .../com/sun/faces/cdi/HeaderMapProducer.java | 12 ++++-- .../faces/cdi/HeaderValuesMapProducer.java | 12 ++++-- .../faces/cdi/InitParameterMapProducer.java | 12 ++++-- .../faces/cdi/ManagedPropertyProducer.java | 6 ++- .../faces/cdi/RequestCookieMapProducer.java | 12 ++++-- .../com/sun/faces/cdi/RequestMapProducer.java | 12 ++++-- .../cdi/RequestParameterMapProducer.java | 12 ++++-- .../RequestParameterValuesMapProducer.java | 12 ++++-- .../faces/cdi/ResourceHandlerProducer.java | 12 ++++-- .../com/sun/faces/cdi/SessionMapProducer.java | 12 ++++-- .../com/sun/faces/cdi/ViewMapProducer.java | 12 ++++-- .../java/com/sun/faces/cdi/ViewProducer.java | 10 +++-- .../sun/faces/context/FacesContextImpl.java | 3 +- 24 files changed, 190 insertions(+), 89 deletions(-) diff --git a/impl/src/main/java/com/sun/faces/cdi/ApplicationMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/ApplicationMapProducer.java index 067ebed8e7..256f0fa998 100644 --- a/impl/src/main/java/com/sun/faces/cdi/ApplicationMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/ApplicationMapProducer.java @@ -20,6 +20,7 @@ import java.util.Map; import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.spi.BeanManager; import jakarta.faces.annotation.ApplicationMap; import jakarta.faces.context.ExternalContext; import jakarta.faces.context.FacesContext; @@ -40,10 +41,13 @@ public class ApplicationMapProducer extends CdiProducer> { */ private static final long serialVersionUID = 1L; - public ApplicationMapProducer() { - super.name("applicationScope").scope(ApplicationScoped.class).qualifiers(ApplicationMap.Literal.INSTANCE) - .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, Object.class }), Map.class, Object.class) - .create(e -> FacesContext.getCurrentInstance().getExternalContext().getApplicationMap()); + public ApplicationMapProducer(BeanManager beanManager) { + super.name("applicationScope") + .scope(ApplicationScoped.class) + .qualifiers(ApplicationMap.Literal.INSTANCE) + .beanClass(beanManager, Map.class) + .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, Object.class }), Map.class, Object.class) + .create(e -> FacesContext.getCurrentInstance().getExternalContext().getApplicationMap()); } } diff --git a/impl/src/main/java/com/sun/faces/cdi/CdiExtension.java b/impl/src/main/java/com/sun/faces/cdi/CdiExtension.java index aeae4a8869..a228870ce2 100644 --- a/impl/src/main/java/com/sun/faces/cdi/CdiExtension.java +++ b/impl/src/main/java/com/sun/faces/cdi/CdiExtension.java @@ -180,27 +180,27 @@ public void afterBeanDiscovery(@Observes AfterBeanDiscovery afterBeanDiscovery, // but this is not detectable as ServletContext is not necessarily available at this moment. afterBeanDiscovery.addBean(new ApplicationProducer()); - afterBeanDiscovery.addBean(new ApplicationMapProducer()); - afterBeanDiscovery.addBean(new CompositeComponentProducer()); - afterBeanDiscovery.addBean(new ComponentProducer()); - afterBeanDiscovery.addBean(new FlashProducer()); - afterBeanDiscovery.addBean(new FlowMapProducer()); - afterBeanDiscovery.addBean(new HeaderMapProducer()); - afterBeanDiscovery.addBean(new HeaderValuesMapProducer()); - afterBeanDiscovery.addBean(new InitParameterMapProducer()); - afterBeanDiscovery.addBean(new RequestParameterMapProducer()); - afterBeanDiscovery.addBean(new RequestParameterValuesMapProducer()); + afterBeanDiscovery.addBean(new ApplicationMapProducer(beanManager)); + afterBeanDiscovery.addBean(new CompositeComponentProducer(beanManager)); + afterBeanDiscovery.addBean(new ComponentProducer(beanManager)); + afterBeanDiscovery.addBean(new FlashProducer(beanManager)); + afterBeanDiscovery.addBean(new FlowMapProducer(beanManager)); + afterBeanDiscovery.addBean(new HeaderMapProducer(beanManager)); + afterBeanDiscovery.addBean(new HeaderValuesMapProducer(beanManager)); + afterBeanDiscovery.addBean(new InitParameterMapProducer(beanManager)); + afterBeanDiscovery.addBean(new RequestParameterMapProducer(beanManager)); + afterBeanDiscovery.addBean(new RequestParameterValuesMapProducer(beanManager)); afterBeanDiscovery.addBean(new RequestProducer()); - afterBeanDiscovery.addBean(new RequestMapProducer()); - afterBeanDiscovery.addBean(new ResourceHandlerProducer()); - afterBeanDiscovery.addBean(new ExternalContextProducer()); - afterBeanDiscovery.addBean(new FacesContextProducer()); - afterBeanDiscovery.addBean(new RequestCookieMapProducer()); + afterBeanDiscovery.addBean(new RequestMapProducer(beanManager)); + afterBeanDiscovery.addBean(new ResourceHandlerProducer(beanManager)); + afterBeanDiscovery.addBean(new ExternalContextProducer(beanManager)); + afterBeanDiscovery.addBean(new FacesContextProducer(beanManager)); + afterBeanDiscovery.addBean(new RequestCookieMapProducer(beanManager)); afterBeanDiscovery.addBean(new SessionProducer()); - afterBeanDiscovery.addBean(new SessionMapProducer()); - afterBeanDiscovery.addBean(new ViewMapProducer()); - afterBeanDiscovery.addBean(new ViewProducer()); - afterBeanDiscovery.addBean(new DataModelClassesMapProducer()); + afterBeanDiscovery.addBean(new SessionMapProducer(beanManager)); + afterBeanDiscovery.addBean(new ViewMapProducer(beanManager)); + afterBeanDiscovery.addBean(new ViewProducer(beanManager)); + afterBeanDiscovery.addBean(new DataModelClassesMapProducer(beanManager)); for (Type type : managedPropertyTargetTypes) { afterBeanDiscovery.addBean(new ManagedPropertyProducer(type, beanManager)); diff --git a/impl/src/main/java/com/sun/faces/cdi/CdiProducer.java b/impl/src/main/java/com/sun/faces/cdi/CdiProducer.java index 41eb33c21e..dd0ec15d40 100644 --- a/impl/src/main/java/com/sun/faces/cdi/CdiProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/CdiProducer.java @@ -31,6 +31,7 @@ import jakarta.enterprise.context.Dependent; import jakarta.enterprise.context.spi.CreationalContext; import jakarta.enterprise.inject.spi.Bean; +import jakarta.enterprise.inject.spi.BeanManager; import jakarta.enterprise.inject.spi.InjectionPoint; import jakarta.enterprise.inject.spi.PassivationCapable; import jakarta.faces.context.FacesContext; @@ -49,8 +50,7 @@ abstract class CdiProducer implements Bean, PassivationCapable, Serializab private String id = this.getClass().getName(); private String name; - // for synthetic beans, the beanClass defaults to the extension that registers them - private Class beanClass = CdiExtension.class; + private Class beanClass = Object.class; private Set types = singleton(Object.class); private Set qualifiers = unmodifiableSet(asSet(new DefaultAnnotationLiteral(), new AnyAnnotationLiteral())); private Class scope = Dependent.class; @@ -165,8 +165,19 @@ protected CdiProducer create(Function, T> create) { return this; } + protected CdiProducer beanClass(BeanManager beanManager, Class beanClass) { + if (CdiUtils.isWeld(beanManager)) { + this.beanClass = CdiExtension.class; // See #5457 and #5157 + } else { + this.beanClass = beanClass; + } + + return this; + } + protected CdiProducer types(Type... types) { this.types = asSet(types); + this.types.add(getClass()); // Add producer class as well so it can at least be filtered from BeanManager#getBeans(). return this; } diff --git a/impl/src/main/java/com/sun/faces/cdi/CdiUtils.java b/impl/src/main/java/com/sun/faces/cdi/CdiUtils.java index a79cd59eb9..a6e12a9046 100644 --- a/impl/src/main/java/com/sun/faces/cdi/CdiUtils.java +++ b/impl/src/main/java/com/sun/faces/cdi/CdiUtils.java @@ -421,4 +421,11 @@ public static boolean isScopeActive(Class scope) { } } + /** + * Returns true if Weld is used as CDI impl. + */ + public static boolean isWeld(BeanManager beanManager) { + return beanManager.getClass().getPackageName().startsWith("org.jboss.weld."); + } + } diff --git a/impl/src/main/java/com/sun/faces/cdi/ComponentProducer.java b/impl/src/main/java/com/sun/faces/cdi/ComponentProducer.java index 846b26580a..caa798934e 100644 --- a/impl/src/main/java/com/sun/faces/cdi/ComponentProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/ComponentProducer.java @@ -18,6 +18,7 @@ import static jakarta.faces.component.UIComponent.getCurrentComponent; +import jakarta.enterprise.inject.spi.BeanManager; import jakarta.faces.component.UIComponent; import jakarta.faces.context.FacesContext; @@ -36,8 +37,11 @@ public class ComponentProducer extends CdiProducer { */ private static final long serialVersionUID = 1L; - public ComponentProducer() { - super.name("component").types(UIComponent.class).create(e -> getCurrentComponent(FacesContext.getCurrentInstance())); + public ComponentProducer(BeanManager beanManager) { + super.name("component") + .beanClass(beanManager, UIComponent.class) + .types(UIComponent.class) + .create(e -> getCurrentComponent(FacesContext.getCurrentInstance())); } } diff --git a/impl/src/main/java/com/sun/faces/cdi/CompositeComponentProducer.java b/impl/src/main/java/com/sun/faces/cdi/CompositeComponentProducer.java index abb63a9420..03c4c8f782 100644 --- a/impl/src/main/java/com/sun/faces/cdi/CompositeComponentProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/CompositeComponentProducer.java @@ -20,6 +20,7 @@ import static jakarta.faces.component.UIComponent.getCurrentCompositeComponent; import static jakarta.faces.context.FacesContext.getCurrentInstance; +import jakarta.enterprise.inject.spi.BeanManager; import jakarta.faces.component.UIComponent; import jakarta.faces.context.FacesContext; @@ -37,8 +38,11 @@ public class CompositeComponentProducer extends CdiProducer { */ private static final long serialVersionUID = 1L; - public CompositeComponentProducer() { - super.name("cc").types(UIComponent.class).create(e -> { + public CompositeComponentProducer(BeanManager beanManager) { + super.name("cc") + .beanClass(beanManager, UIComponent.class) + .types(UIComponent.class) + .create(e -> { FacesContext context = getCurrentInstance(); diff --git a/impl/src/main/java/com/sun/faces/cdi/DataModelClassesMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/DataModelClassesMapProducer.java index 3d1ffe8377..3b865e8575 100644 --- a/impl/src/main/java/com/sun/faces/cdi/DataModelClassesMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/DataModelClassesMapProducer.java @@ -19,6 +19,7 @@ import java.util.Map; import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.spi.BeanManager; import jakarta.enterprise.inject.spi.CDI; import jakarta.faces.model.DataModel; @@ -43,9 +44,13 @@ public class DataModelClassesMapProducer extends CdiProducer, Class */ private static final long serialVersionUID = 1L; - public DataModelClassesMapProducer() { - super.name("comSunFacesDataModelClassesMap").scope(ApplicationScoped.class).qualifiers(new DataModelClassesAnnotationLiteral()) - .types(Map.class, Object.class).create(e -> CDI.current().select(CdiExtension.class).get().getForClassToDataModelClass()); + public DataModelClassesMapProducer(BeanManager beanManager) { + super.name("comSunFacesDataModelClassesMap") + .scope(ApplicationScoped.class) + .qualifiers(new DataModelClassesAnnotationLiteral()) + .beanClass(beanManager, Map.class) + .types(Map.class, Object.class) + .create(e -> CDI.current().select(CdiExtension.class).get().getForClassToDataModelClass()); } } diff --git a/impl/src/main/java/com/sun/faces/cdi/ExternalContextProducer.java b/impl/src/main/java/com/sun/faces/cdi/ExternalContextProducer.java index 7b16111b09..88da55bae3 100644 --- a/impl/src/main/java/com/sun/faces/cdi/ExternalContextProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/ExternalContextProducer.java @@ -17,6 +17,7 @@ package com.sun.faces.cdi; import jakarta.enterprise.context.RequestScoped; +import jakarta.enterprise.inject.spi.BeanManager; import jakarta.faces.context.ExternalContext; import jakarta.faces.context.FacesContext; @@ -36,9 +37,12 @@ public class ExternalContextProducer extends CdiProducer { */ private static final long serialVersionUID = 1L; - public ExternalContextProducer() { - super.name("externalContext").scope(RequestScoped.class).types(ExternalContext.class) - .create(e -> FacesContext.getCurrentInstance().getExternalContext()); + public ExternalContextProducer(BeanManager beanManager) { + super.name("externalContext") + .scope(RequestScoped.class) + .beanClass(beanManager, ExternalContext.class) + .types(ExternalContext.class) + .create(e -> FacesContext.getCurrentInstance().getExternalContext()); } } diff --git a/impl/src/main/java/com/sun/faces/cdi/FacesContextProducer.java b/impl/src/main/java/com/sun/faces/cdi/FacesContextProducer.java index 3036c918b6..e1da4d343d 100644 --- a/impl/src/main/java/com/sun/faces/cdi/FacesContextProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/FacesContextProducer.java @@ -17,6 +17,7 @@ package com.sun.faces.cdi; import jakarta.enterprise.context.RequestScoped; +import jakarta.enterprise.inject.spi.BeanManager; import jakarta.faces.context.FacesContext; /** @@ -35,9 +36,12 @@ public class FacesContextProducer extends CdiProducer { */ private static final long serialVersionUID = 1L; - public FacesContextProducer() { - super.name("facesContext").scope(RequestScoped.class).types(FacesContext.class) - .create(e -> FacesContext.getCurrentInstance()); + public FacesContextProducer(BeanManager beanManager) { + super.name("facesContext") + .scope(RequestScoped.class) + .beanClass(beanManager, FacesContext.class) + .types(FacesContext.class) + .create(e -> FacesContext.getCurrentInstance()); } } diff --git a/impl/src/main/java/com/sun/faces/cdi/FlashProducer.java b/impl/src/main/java/com/sun/faces/cdi/FlashProducer.java index b24fd70a2d..85d5711235 100644 --- a/impl/src/main/java/com/sun/faces/cdi/FlashProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/FlashProducer.java @@ -20,6 +20,7 @@ import java.util.Map; import jakarta.enterprise.context.RequestScoped; +import jakarta.enterprise.inject.spi.BeanManager; import jakarta.faces.context.FacesContext; import jakarta.faces.context.Flash; @@ -40,10 +41,12 @@ public class FlashProducer extends CdiProducer { private static class Dummy { } - public FlashProducer() { + public FlashProducer(BeanManager beanManager) { super.name("flash") - .types(Flash.class, new ParameterizedTypeImpl(Map.class, new Type[] { Dummy.class, Dummy.class }), Object.class).scope(RequestScoped.class) - .create(e -> FacesContext.getCurrentInstance().getExternalContext().getFlash()); + .beanClass(beanManager, Flash.class) + .types(Flash.class, new ParameterizedTypeImpl(Map.class, new Type[] { Dummy.class, Dummy.class }), Object.class) + .scope(RequestScoped.class) + .create(e -> FacesContext.getCurrentInstance().getExternalContext().getFlash()); } } diff --git a/impl/src/main/java/com/sun/faces/cdi/FlowMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/FlowMapProducer.java index 2022650114..a821c3e2bf 100644 --- a/impl/src/main/java/com/sun/faces/cdi/FlowMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/FlowMapProducer.java @@ -19,6 +19,7 @@ import java.lang.reflect.Type; import java.util.Map; +import jakarta.enterprise.inject.spi.BeanManager; import jakarta.faces.annotation.FlowMap; import jakarta.faces.application.Application; import jakarta.faces.context.FacesContext; @@ -41,10 +42,13 @@ public class FlowMapProducer extends CdiProducer> { */ private static final long serialVersionUID = 1L; - public FlowMapProducer() { - super.name("flowScope").scope(FlowScoped.class).qualifiers(FlowMap.Literal.INSTANCE) - .types(new ParameterizedTypeImpl(Map.class, new Type[] { Object.class, Object.class }), Map.class, Object.class) - .create(e -> FacesContext.getCurrentInstance().getApplication().getFlowHandler().getCurrentFlowScope()); + public FlowMapProducer(BeanManager beanManager) { + super.name("flowScope") + .scope(FlowScoped.class) + .qualifiers(FlowMap.Literal.INSTANCE) + .beanClass(beanManager, Map.class) + .types(new ParameterizedTypeImpl(Map.class, new Type[] { Object.class, Object.class }), Map.class, Object.class) + .create(e -> FacesContext.getCurrentInstance().getApplication().getFlowHandler().getCurrentFlowScope()); } } diff --git a/impl/src/main/java/com/sun/faces/cdi/HeaderMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/HeaderMapProducer.java index 02957d07ed..803f99c956 100644 --- a/impl/src/main/java/com/sun/faces/cdi/HeaderMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/HeaderMapProducer.java @@ -20,6 +20,7 @@ import java.util.Map; import jakarta.enterprise.context.RequestScoped; +import jakarta.enterprise.inject.spi.BeanManager; import jakarta.faces.annotation.HeaderMap; import jakarta.faces.context.ExternalContext; import jakarta.faces.context.FacesContext; @@ -39,10 +40,13 @@ public class HeaderMapProducer extends CdiProducer> { */ private static final long serialVersionUID = 1L; - public HeaderMapProducer() { - super.name("header").scope(RequestScoped.class).qualifiers(HeaderMap.Literal.INSTANCE) - .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, String.class }), Map.class, Object.class) - .create(e -> FacesContext.getCurrentInstance().getExternalContext().getRequestHeaderMap()); + public HeaderMapProducer(BeanManager beanManager) { + super.name("header") + .scope(RequestScoped.class) + .qualifiers(HeaderMap.Literal.INSTANCE) + .beanClass(beanManager, Map.class) + .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, String.class }), Map.class, Object.class) + .create(e -> FacesContext.getCurrentInstance().getExternalContext().getRequestHeaderMap()); } } diff --git a/impl/src/main/java/com/sun/faces/cdi/HeaderValuesMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/HeaderValuesMapProducer.java index bd4e3f4f55..ff0366395a 100644 --- a/impl/src/main/java/com/sun/faces/cdi/HeaderValuesMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/HeaderValuesMapProducer.java @@ -20,6 +20,7 @@ import java.util.Map; import jakarta.enterprise.context.RequestScoped; +import jakarta.enterprise.inject.spi.BeanManager; import jakarta.faces.annotation.HeaderValuesMap; import jakarta.faces.context.ExternalContext; import jakarta.faces.context.FacesContext; @@ -39,10 +40,13 @@ public class HeaderValuesMapProducer extends CdiProducer> */ private static final long serialVersionUID = 1L; - public HeaderValuesMapProducer() { - super.name("headerValues").scope(RequestScoped.class).qualifiers(HeaderValuesMap.Literal.INSTANCE) - .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, String[].class }), Map.class, Object.class) - .create(e -> FacesContext.getCurrentInstance().getExternalContext().getRequestHeaderValuesMap()); + public HeaderValuesMapProducer(BeanManager beanManager) { + super.name("headerValues") + .scope(RequestScoped.class) + .qualifiers(HeaderValuesMap.Literal.INSTANCE) + .beanClass(beanManager, Map.class) + .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, String[].class }), Map.class, Object.class) + .create(e -> FacesContext.getCurrentInstance().getExternalContext().getRequestHeaderValuesMap()); } } diff --git a/impl/src/main/java/com/sun/faces/cdi/InitParameterMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/InitParameterMapProducer.java index 39b23aa313..6977625aa4 100644 --- a/impl/src/main/java/com/sun/faces/cdi/InitParameterMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/InitParameterMapProducer.java @@ -20,6 +20,7 @@ import java.util.Map; import jakarta.enterprise.context.RequestScoped; +import jakarta.enterprise.inject.spi.BeanManager; import jakarta.faces.annotation.InitParameterMap; import jakarta.faces.context.ExternalContext; import jakarta.faces.context.FacesContext; @@ -39,10 +40,13 @@ public class InitParameterMapProducer extends CdiProducer> { */ private static final long serialVersionUID = 1L; - public InitParameterMapProducer() { - super.name("initParam").scope(RequestScoped.class).qualifiers(InitParameterMap.Literal.INSTANCE) - .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, String.class }), Map.class, Object.class) - .create(e -> FacesContext.getCurrentInstance().getExternalContext().getInitParameterMap()); + public InitParameterMapProducer(BeanManager beanManager) { + super.name("initParam") + .scope(RequestScoped.class) + .qualifiers(InitParameterMap.Literal.INSTANCE) + .beanClass(beanManager, Map.class) + .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, String.class }), Map.class, Object.class) + .create(e -> FacesContext.getCurrentInstance().getExternalContext().getInitParameterMap()); } } diff --git a/impl/src/main/java/com/sun/faces/cdi/ManagedPropertyProducer.java b/impl/src/main/java/com/sun/faces/cdi/ManagedPropertyProducer.java index 8727008de3..1fd544dcfd 100644 --- a/impl/src/main/java/com/sun/faces/cdi/ManagedPropertyProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/ManagedPropertyProducer.java @@ -44,7 +44,11 @@ public class ManagedPropertyProducer extends CdiProducer { private Class expectedClass; public ManagedPropertyProducer(Type type, BeanManager beanManager) { - super.types(type).qualifiers(ManagedProperty.Literal.INSTANCE).addToId(type).create(creationalContext -> { + super.qualifiers(ManagedProperty.Literal.INSTANCE) + .beanClass(beanManager, ManagedPropertyProducer.class) + .types(type) + .addToId(type) + .create(creationalContext -> { // TODO: handle no InjectionPoint available String expression = getCurrentInjectionPoint(beanManager, creationalContext).getAnnotated().getAnnotation(ManagedProperty.class).value(); diff --git a/impl/src/main/java/com/sun/faces/cdi/RequestCookieMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/RequestCookieMapProducer.java index 1bcfb16175..269051cd99 100644 --- a/impl/src/main/java/com/sun/faces/cdi/RequestCookieMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/RequestCookieMapProducer.java @@ -20,6 +20,7 @@ import java.util.Map; import jakarta.enterprise.context.RequestScoped; +import jakarta.enterprise.inject.spi.BeanManager; import jakarta.faces.annotation.RequestCookieMap; import jakarta.faces.context.ExternalContext; import jakarta.faces.context.FacesContext; @@ -40,10 +41,13 @@ public class RequestCookieMapProducer extends CdiProducer> { */ private static final long serialVersionUID = 1L; - public RequestCookieMapProducer() { - super.name("cookie").scope(RequestScoped.class).qualifiers(RequestCookieMap.Literal.INSTANCE) - .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, Object.class }), Map.class, Object.class) - .create(e -> FacesContext.getCurrentInstance().getExternalContext().getRequestCookieMap()); + public RequestCookieMapProducer(BeanManager beanManager) { + super.name("cookie") + .scope(RequestScoped.class) + .qualifiers(RequestCookieMap.Literal.INSTANCE) + .beanClass(beanManager, Map.class) + .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, Object.class }), Map.class, Object.class) + .create(e -> FacesContext.getCurrentInstance().getExternalContext().getRequestCookieMap()); } } diff --git a/impl/src/main/java/com/sun/faces/cdi/RequestMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/RequestMapProducer.java index fa22f3eda0..119c70afb4 100644 --- a/impl/src/main/java/com/sun/faces/cdi/RequestMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/RequestMapProducer.java @@ -20,6 +20,7 @@ import java.util.Map; import jakarta.enterprise.context.RequestScoped; +import jakarta.enterprise.inject.spi.BeanManager; import jakarta.faces.annotation.RequestMap; import jakarta.faces.context.ExternalContext; import jakarta.faces.context.FacesContext; @@ -39,10 +40,13 @@ public class RequestMapProducer extends CdiProducer> { */ private static final long serialVersionUID = 1L; - public RequestMapProducer() { - super.name("requestScope").scope(RequestScoped.class).qualifiers(RequestMap.Literal.INSTANCE) - .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, Object.class }), Map.class, Object.class) - .create(e -> FacesContext.getCurrentInstance().getExternalContext().getRequestMap()); + public RequestMapProducer(BeanManager beanManager) { + super.name("requestScope") + .scope(RequestScoped.class) + .qualifiers(RequestMap.Literal.INSTANCE) + .beanClass(beanManager, Map.class) + .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, Object.class }), Map.class, Object.class) + .create(e -> FacesContext.getCurrentInstance().getExternalContext().getRequestMap()); } } diff --git a/impl/src/main/java/com/sun/faces/cdi/RequestParameterMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/RequestParameterMapProducer.java index 3fb3935237..5184bb539b 100644 --- a/impl/src/main/java/com/sun/faces/cdi/RequestParameterMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/RequestParameterMapProducer.java @@ -20,6 +20,7 @@ import java.util.Map; import jakarta.enterprise.context.RequestScoped; +import jakarta.enterprise.inject.spi.BeanManager; import jakarta.faces.annotation.RequestParameterMap; import jakarta.faces.context.ExternalContext; import jakarta.faces.context.FacesContext; @@ -40,10 +41,13 @@ public class RequestParameterMapProducer extends CdiProducer */ private static final long serialVersionUID = 1L; - public RequestParameterMapProducer() { - super.name("param").scope(RequestScoped.class).qualifiers(RequestParameterMap.Literal.INSTANCE) - .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, String.class }), Map.class, Object.class) - .create(e -> FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap()); + public RequestParameterMapProducer(BeanManager beanManager) { + super.name("param") + .scope(RequestScoped.class) + .qualifiers(RequestParameterMap.Literal.INSTANCE) + .beanClass(beanManager, Map.class) + .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, String.class }), Map.class, Object.class) + .create(e -> FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap()); } } diff --git a/impl/src/main/java/com/sun/faces/cdi/RequestParameterValuesMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/RequestParameterValuesMapProducer.java index 8b85846da9..674722f5c9 100644 --- a/impl/src/main/java/com/sun/faces/cdi/RequestParameterValuesMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/RequestParameterValuesMapProducer.java @@ -20,6 +20,7 @@ import java.util.Map; import jakarta.enterprise.context.RequestScoped; +import jakarta.enterprise.inject.spi.BeanManager; import jakarta.faces.annotation.RequestParameterValuesMap; import jakarta.faces.context.ExternalContext; import jakarta.faces.context.FacesContext; @@ -40,10 +41,13 @@ public class RequestParameterValuesMapProducer extends CdiProducer FacesContext.getCurrentInstance().getExternalContext().getRequestParameterValuesMap()); + public RequestParameterValuesMapProducer(BeanManager beanManager) { + super.name("paramValues") + .scope(RequestScoped.class) + .qualifiers(RequestParameterValuesMap.Literal.INSTANCE) + .beanClass(beanManager, Map.class) + .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, String[].class }), Map.class, Object.class) + .create(e -> FacesContext.getCurrentInstance().getExternalContext().getRequestParameterValuesMap()); } } diff --git a/impl/src/main/java/com/sun/faces/cdi/ResourceHandlerProducer.java b/impl/src/main/java/com/sun/faces/cdi/ResourceHandlerProducer.java index ba974a3c17..527cd91b4b 100644 --- a/impl/src/main/java/com/sun/faces/cdi/ResourceHandlerProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/ResourceHandlerProducer.java @@ -16,7 +16,10 @@ package com.sun.faces.cdi; +import java.util.Map; + import jakarta.enterprise.context.RequestScoped; +import jakarta.enterprise.inject.spi.BeanManager; import jakarta.faces.application.Application; import jakarta.faces.application.ResourceHandler; import jakarta.faces.context.FacesContext; @@ -38,9 +41,12 @@ public class ResourceHandlerProducer extends CdiProducer { */ private static final long serialVersionUID = 1L; - public ResourceHandlerProducer() { - super.name("resource").scope(RequestScoped.class).types(ResourceHandler.class) - .create(e -> FacesContext.getCurrentInstance().getApplication().getResourceHandler()); + public ResourceHandlerProducer(BeanManager beanManager) { + super.name("resource") + .scope(RequestScoped.class) + .beanClass(beanManager, ResourceHandler.class) + .types(ResourceHandler.class) + .create(e -> FacesContext.getCurrentInstance().getApplication().getResourceHandler()); } } diff --git a/impl/src/main/java/com/sun/faces/cdi/SessionMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/SessionMapProducer.java index 74f1f1831e..39da03254e 100644 --- a/impl/src/main/java/com/sun/faces/cdi/SessionMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/SessionMapProducer.java @@ -20,6 +20,7 @@ import java.util.Map; import jakarta.enterprise.context.RequestScoped; +import jakarta.enterprise.inject.spi.BeanManager; import jakarta.faces.annotation.SessionMap; import jakarta.faces.context.ExternalContext; import jakarta.faces.context.FacesContext; @@ -39,10 +40,13 @@ public class SessionMapProducer extends CdiProducer> { */ private static final long serialVersionUID = 1L; - public SessionMapProducer() { - super.name("sessionScope").scope(RequestScoped.class).qualifiers(SessionMap.Literal.INSTANCE) - .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, Object.class }), Map.class, Object.class) - .create(e -> FacesContext.getCurrentInstance().getExternalContext().getSessionMap()); + public SessionMapProducer(BeanManager beanManager) { + super.name("sessionScope") + .scope(RequestScoped.class) + .qualifiers(SessionMap.Literal.INSTANCE) + .beanClass(beanManager, Map.class) + .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, Object.class }), Map.class, Object.class) + .create(e -> FacesContext.getCurrentInstance().getExternalContext().getSessionMap()); } } diff --git a/impl/src/main/java/com/sun/faces/cdi/ViewMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/ViewMapProducer.java index b5c1ed3f26..430342c51e 100644 --- a/impl/src/main/java/com/sun/faces/cdi/ViewMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/ViewMapProducer.java @@ -20,6 +20,7 @@ import java.util.Map; import jakarta.enterprise.context.RequestScoped; +import jakarta.enterprise.inject.spi.BeanManager; import jakarta.faces.annotation.ViewMap; import jakarta.faces.component.UIViewRoot; import jakarta.faces.context.FacesContext; @@ -40,10 +41,13 @@ public class ViewMapProducer extends CdiProducer> { */ private static final long serialVersionUID = 1L; - public ViewMapProducer() { - super.name("viewScope").scope(RequestScoped.class).qualifiers(ViewMap.Literal.INSTANCE) - .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, Object.class }), Map.class, Object.class) - .create(e -> FacesContext.getCurrentInstance().getViewRoot().getViewMap()); + public ViewMapProducer(BeanManager beanManager) { + super.name("viewScope") + .scope(RequestScoped.class) + .qualifiers(ViewMap.Literal.INSTANCE) + .beanClass(beanManager, Map.class) + .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, Object.class }), Map.class, Object.class) + .create(e -> FacesContext.getCurrentInstance().getViewRoot().getViewMap()); } } diff --git a/impl/src/main/java/com/sun/faces/cdi/ViewProducer.java b/impl/src/main/java/com/sun/faces/cdi/ViewProducer.java index fd3516f56f..d4450a9501 100644 --- a/impl/src/main/java/com/sun/faces/cdi/ViewProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/ViewProducer.java @@ -17,6 +17,7 @@ package com.sun.faces.cdi; import jakarta.enterprise.context.RequestScoped; +import jakarta.enterprise.inject.spi.BeanManager; import jakarta.faces.component.UIViewRoot; import jakarta.faces.context.FacesContext; @@ -35,9 +36,12 @@ public class ViewProducer extends CdiProducer { */ private static final long serialVersionUID = 1L; - public ViewProducer() { - super.name("view").scope(RequestScoped.class).types(UIViewRoot.class) - .create(e -> FacesContext.getCurrentInstance().getViewRoot()); + public ViewProducer(BeanManager beanManager) { + super.name("view") + .scope(RequestScoped.class) + .beanClass(beanManager, UIViewRoot.class) + .types(UIViewRoot.class) + .create(e -> FacesContext.getCurrentInstance().getViewRoot()); } } diff --git a/impl/src/main/java/com/sun/faces/context/FacesContextImpl.java b/impl/src/main/java/com/sun/faces/context/FacesContextImpl.java index 64657f1b46..5ba2728ef7 100644 --- a/impl/src/main/java/com/sun/faces/context/FacesContextImpl.java +++ b/impl/src/main/java/com/sun/faces/context/FacesContextImpl.java @@ -31,6 +31,7 @@ import java.util.logging.Logger; import com.sun.faces.cdi.CdiExtension; +import com.sun.faces.cdi.FacesContextProducer; import com.sun.faces.el.ELContextImpl; import com.sun.faces.renderkit.RenderKitUtils; import com.sun.faces.util.FacesLogger; @@ -560,7 +561,7 @@ public void release() { DEFAULT_FACES_CONTEXT.remove(); // Destroy our instance produced by FacesContextProducer. - Set> beans = beanManager.getBeans(FacesContext.class).stream().filter(bean -> CdiExtension.class.isAssignableFrom(bean.getBeanClass())).collect(toSet()); + Set> beans = beanManager.getBeans(FacesContext.class).stream().filter(bean -> bean.getTypes().contains(FacesContextProducer.class)).collect(toSet()); Bean bean = beanManager.resolve(beans); ((AlterableContext) beanManager.getContext(bean.getScope())).destroy(bean); } From 291f154e2312e112eef03e62fcba1cd417ae0bc7 Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Sat, 13 Jul 2024 11:50:39 -0400 Subject: [PATCH 10/16] tabs2spaces --- .../com/sun/faces/cdi/ApplicationMapProducer.java | 6 +++--- .../src/main/java/com/sun/faces/cdi/CdiProducer.java | 12 ++++++------ .../java/com/sun/faces/cdi/ComponentProducer.java | 6 +++--- .../sun/faces/cdi/CompositeComponentProducer.java | 6 +++--- .../sun/faces/cdi/DataModelClassesMapProducer.java | 12 ++++++------ .../com/sun/faces/cdi/ExternalContextProducer.java | 6 +++--- .../java/com/sun/faces/cdi/FacesContextProducer.java | 6 +++--- .../main/java/com/sun/faces/cdi/FlashProducer.java | 2 +- .../main/java/com/sun/faces/cdi/FlowMapProducer.java | 6 +++--- .../java/com/sun/faces/cdi/HeaderMapProducer.java | 6 +++--- .../com/sun/faces/cdi/HeaderValuesMapProducer.java | 8 ++++---- .../com/sun/faces/cdi/InitParameterMapProducer.java | 10 +++++----- .../com/sun/faces/cdi/ManagedPropertyProducer.java | 8 ++++---- .../com/sun/faces/cdi/RequestCookieMapProducer.java | 8 ++++---- .../java/com/sun/faces/cdi/RequestMapProducer.java | 6 +++--- .../sun/faces/cdi/RequestParameterMapProducer.java | 6 +++--- .../faces/cdi/RequestParameterValuesMapProducer.java | 8 ++++---- .../com/sun/faces/cdi/ResourceHandlerProducer.java | 8 ++++---- .../java/com/sun/faces/cdi/SessionMapProducer.java | 6 +++--- .../main/java/com/sun/faces/cdi/ViewMapProducer.java | 6 +++--- .../main/java/com/sun/faces/cdi/ViewProducer.java | 6 +++--- 21 files changed, 74 insertions(+), 74 deletions(-) diff --git a/impl/src/main/java/com/sun/faces/cdi/ApplicationMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/ApplicationMapProducer.java index 256f0fa998..6d2c7849bb 100644 --- a/impl/src/main/java/com/sun/faces/cdi/ApplicationMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/ApplicationMapProducer.java @@ -43,9 +43,9 @@ public class ApplicationMapProducer extends CdiProducer> { public ApplicationMapProducer(BeanManager beanManager) { super.name("applicationScope") - .scope(ApplicationScoped.class) - .qualifiers(ApplicationMap.Literal.INSTANCE) - .beanClass(beanManager, Map.class) + .scope(ApplicationScoped.class) + .qualifiers(ApplicationMap.Literal.INSTANCE) + .beanClass(beanManager, Map.class) .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, Object.class }), Map.class, Object.class) .create(e -> FacesContext.getCurrentInstance().getExternalContext().getApplicationMap()); } diff --git a/impl/src/main/java/com/sun/faces/cdi/CdiProducer.java b/impl/src/main/java/com/sun/faces/cdi/CdiProducer.java index dd0ec15d40..400f5f1a50 100644 --- a/impl/src/main/java/com/sun/faces/cdi/CdiProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/CdiProducer.java @@ -166,13 +166,13 @@ protected CdiProducer create(Function, T> create) { } protected CdiProducer beanClass(BeanManager beanManager, Class beanClass) { - if (CdiUtils.isWeld(beanManager)) { - this.beanClass = CdiExtension.class; // See #5457 and #5157 - } else { - this.beanClass = beanClass; - } + if (CdiUtils.isWeld(beanManager)) { + this.beanClass = CdiExtension.class; // See #5457 and #5157 + } else { + this.beanClass = beanClass; + } - return this; + return this; } protected CdiProducer types(Type... types) { diff --git a/impl/src/main/java/com/sun/faces/cdi/ComponentProducer.java b/impl/src/main/java/com/sun/faces/cdi/ComponentProducer.java index caa798934e..6afc69833e 100644 --- a/impl/src/main/java/com/sun/faces/cdi/ComponentProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/ComponentProducer.java @@ -39,9 +39,9 @@ public class ComponentProducer extends CdiProducer { public ComponentProducer(BeanManager beanManager) { super.name("component") - .beanClass(beanManager, UIComponent.class) - .types(UIComponent.class) - .create(e -> getCurrentComponent(FacesContext.getCurrentInstance())); + .beanClass(beanManager, UIComponent.class) + .types(UIComponent.class) + .create(e -> getCurrentComponent(FacesContext.getCurrentInstance())); } } diff --git a/impl/src/main/java/com/sun/faces/cdi/CompositeComponentProducer.java b/impl/src/main/java/com/sun/faces/cdi/CompositeComponentProducer.java index 03c4c8f782..c132762dee 100644 --- a/impl/src/main/java/com/sun/faces/cdi/CompositeComponentProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/CompositeComponentProducer.java @@ -40,9 +40,9 @@ public class CompositeComponentProducer extends CdiProducer { public CompositeComponentProducer(BeanManager beanManager) { super.name("cc") - .beanClass(beanManager, UIComponent.class) - .types(UIComponent.class) - .create(e -> { + .beanClass(beanManager, UIComponent.class) + .types(UIComponent.class) + .create(e -> { FacesContext context = getCurrentInstance(); diff --git a/impl/src/main/java/com/sun/faces/cdi/DataModelClassesMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/DataModelClassesMapProducer.java index 3b865e8575..1077f345d3 100644 --- a/impl/src/main/java/com/sun/faces/cdi/DataModelClassesMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/DataModelClassesMapProducer.java @@ -45,12 +45,12 @@ public class DataModelClassesMapProducer extends CdiProducer, Class private static final long serialVersionUID = 1L; public DataModelClassesMapProducer(BeanManager beanManager) { - super.name("comSunFacesDataModelClassesMap") - .scope(ApplicationScoped.class) - .qualifiers(new DataModelClassesAnnotationLiteral()) - .beanClass(beanManager, Map.class) - .types(Map.class, Object.class) - .create(e -> CDI.current().select(CdiExtension.class).get().getForClassToDataModelClass()); + super.name("comSunFacesDataModelClassesMap") + .scope(ApplicationScoped.class) + .qualifiers(new DataModelClassesAnnotationLiteral()) + .beanClass(beanManager, Map.class) + .types(Map.class, Object.class) + .create(e -> CDI.current().select(CdiExtension.class).get().getForClassToDataModelClass()); } } diff --git a/impl/src/main/java/com/sun/faces/cdi/ExternalContextProducer.java b/impl/src/main/java/com/sun/faces/cdi/ExternalContextProducer.java index 88da55bae3..8cf4519274 100644 --- a/impl/src/main/java/com/sun/faces/cdi/ExternalContextProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/ExternalContextProducer.java @@ -39,9 +39,9 @@ public class ExternalContextProducer extends CdiProducer { public ExternalContextProducer(BeanManager beanManager) { super.name("externalContext") - .scope(RequestScoped.class) - .beanClass(beanManager, ExternalContext.class) - .types(ExternalContext.class) + .scope(RequestScoped.class) + .beanClass(beanManager, ExternalContext.class) + .types(ExternalContext.class) .create(e -> FacesContext.getCurrentInstance().getExternalContext()); } diff --git a/impl/src/main/java/com/sun/faces/cdi/FacesContextProducer.java b/impl/src/main/java/com/sun/faces/cdi/FacesContextProducer.java index e1da4d343d..033f3c7ca2 100644 --- a/impl/src/main/java/com/sun/faces/cdi/FacesContextProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/FacesContextProducer.java @@ -38,9 +38,9 @@ public class FacesContextProducer extends CdiProducer { public FacesContextProducer(BeanManager beanManager) { super.name("facesContext") - .scope(RequestScoped.class) - .beanClass(beanManager, FacesContext.class) - .types(FacesContext.class) + .scope(RequestScoped.class) + .beanClass(beanManager, FacesContext.class) + .types(FacesContext.class) .create(e -> FacesContext.getCurrentInstance()); } diff --git a/impl/src/main/java/com/sun/faces/cdi/FlashProducer.java b/impl/src/main/java/com/sun/faces/cdi/FlashProducer.java index 85d5711235..db8dc4b9b9 100644 --- a/impl/src/main/java/com/sun/faces/cdi/FlashProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/FlashProducer.java @@ -43,7 +43,7 @@ private static class Dummy { public FlashProducer(BeanManager beanManager) { super.name("flash") - .beanClass(beanManager, Flash.class) + .beanClass(beanManager, Flash.class) .types(Flash.class, new ParameterizedTypeImpl(Map.class, new Type[] { Dummy.class, Dummy.class }), Object.class) .scope(RequestScoped.class) .create(e -> FacesContext.getCurrentInstance().getExternalContext().getFlash()); diff --git a/impl/src/main/java/com/sun/faces/cdi/FlowMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/FlowMapProducer.java index a821c3e2bf..8064e9d044 100644 --- a/impl/src/main/java/com/sun/faces/cdi/FlowMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/FlowMapProducer.java @@ -44,9 +44,9 @@ public class FlowMapProducer extends CdiProducer> { public FlowMapProducer(BeanManager beanManager) { super.name("flowScope") - .scope(FlowScoped.class) - .qualifiers(FlowMap.Literal.INSTANCE) - .beanClass(beanManager, Map.class) + .scope(FlowScoped.class) + .qualifiers(FlowMap.Literal.INSTANCE) + .beanClass(beanManager, Map.class) .types(new ParameterizedTypeImpl(Map.class, new Type[] { Object.class, Object.class }), Map.class, Object.class) .create(e -> FacesContext.getCurrentInstance().getApplication().getFlowHandler().getCurrentFlowScope()); } diff --git a/impl/src/main/java/com/sun/faces/cdi/HeaderMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/HeaderMapProducer.java index 803f99c956..392ac95727 100644 --- a/impl/src/main/java/com/sun/faces/cdi/HeaderMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/HeaderMapProducer.java @@ -42,9 +42,9 @@ public class HeaderMapProducer extends CdiProducer> { public HeaderMapProducer(BeanManager beanManager) { super.name("header") - .scope(RequestScoped.class) - .qualifiers(HeaderMap.Literal.INSTANCE) - .beanClass(beanManager, Map.class) + .scope(RequestScoped.class) + .qualifiers(HeaderMap.Literal.INSTANCE) + .beanClass(beanManager, Map.class) .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, String.class }), Map.class, Object.class) .create(e -> FacesContext.getCurrentInstance().getExternalContext().getRequestHeaderMap()); } diff --git a/impl/src/main/java/com/sun/faces/cdi/HeaderValuesMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/HeaderValuesMapProducer.java index ff0366395a..131c725070 100644 --- a/impl/src/main/java/com/sun/faces/cdi/HeaderValuesMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/HeaderValuesMapProducer.java @@ -42,11 +42,11 @@ public class HeaderValuesMapProducer extends CdiProducer> public HeaderValuesMapProducer(BeanManager beanManager) { super.name("headerValues") - .scope(RequestScoped.class) - .qualifiers(HeaderValuesMap.Literal.INSTANCE) - .beanClass(beanManager, Map.class) + .scope(RequestScoped.class) + .qualifiers(HeaderValuesMap.Literal.INSTANCE) + .beanClass(beanManager, Map.class) .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, String[].class }), Map.class, Object.class) - .create(e -> FacesContext.getCurrentInstance().getExternalContext().getRequestHeaderValuesMap()); + .create(e -> FacesContext.getCurrentInstance().getExternalContext().getRequestHeaderValuesMap()); } } diff --git a/impl/src/main/java/com/sun/faces/cdi/InitParameterMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/InitParameterMapProducer.java index 6977625aa4..e9173915bf 100644 --- a/impl/src/main/java/com/sun/faces/cdi/InitParameterMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/InitParameterMapProducer.java @@ -42,11 +42,11 @@ public class InitParameterMapProducer extends CdiProducer> { public InitParameterMapProducer(BeanManager beanManager) { super.name("initParam") - .scope(RequestScoped.class) - .qualifiers(InitParameterMap.Literal.INSTANCE) - .beanClass(beanManager, Map.class) - .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, String.class }), Map.class, Object.class) - .create(e -> FacesContext.getCurrentInstance().getExternalContext().getInitParameterMap()); + .scope(RequestScoped.class) + .qualifiers(InitParameterMap.Literal.INSTANCE) + .beanClass(beanManager, Map.class) + .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, String.class }), Map.class, Object.class) + .create(e -> FacesContext.getCurrentInstance().getExternalContext().getInitParameterMap()); } } diff --git a/impl/src/main/java/com/sun/faces/cdi/ManagedPropertyProducer.java b/impl/src/main/java/com/sun/faces/cdi/ManagedPropertyProducer.java index 1fd544dcfd..b303d8056b 100644 --- a/impl/src/main/java/com/sun/faces/cdi/ManagedPropertyProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/ManagedPropertyProducer.java @@ -45,10 +45,10 @@ public class ManagedPropertyProducer extends CdiProducer { public ManagedPropertyProducer(Type type, BeanManager beanManager) { super.qualifiers(ManagedProperty.Literal.INSTANCE) - .beanClass(beanManager, ManagedPropertyProducer.class) - .types(type) - .addToId(type) - .create(creationalContext -> { + .beanClass(beanManager, ManagedPropertyProducer.class) + .types(type) + .addToId(type) + .create(creationalContext -> { // TODO: handle no InjectionPoint available String expression = getCurrentInjectionPoint(beanManager, creationalContext).getAnnotated().getAnnotation(ManagedProperty.class).value(); diff --git a/impl/src/main/java/com/sun/faces/cdi/RequestCookieMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/RequestCookieMapProducer.java index 269051cd99..3deb538bfb 100644 --- a/impl/src/main/java/com/sun/faces/cdi/RequestCookieMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/RequestCookieMapProducer.java @@ -43,10 +43,10 @@ public class RequestCookieMapProducer extends CdiProducer> { public RequestCookieMapProducer(BeanManager beanManager) { super.name("cookie") - .scope(RequestScoped.class) - .qualifiers(RequestCookieMap.Literal.INSTANCE) - .beanClass(beanManager, Map.class) - .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, Object.class }), Map.class, Object.class) + .scope(RequestScoped.class) + .qualifiers(RequestCookieMap.Literal.INSTANCE) + .beanClass(beanManager, Map.class) + .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, Object.class }), Map.class, Object.class) .create(e -> FacesContext.getCurrentInstance().getExternalContext().getRequestCookieMap()); } diff --git a/impl/src/main/java/com/sun/faces/cdi/RequestMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/RequestMapProducer.java index 119c70afb4..a1b0d28db8 100644 --- a/impl/src/main/java/com/sun/faces/cdi/RequestMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/RequestMapProducer.java @@ -42,9 +42,9 @@ public class RequestMapProducer extends CdiProducer> { public RequestMapProducer(BeanManager beanManager) { super.name("requestScope") - .scope(RequestScoped.class) - .qualifiers(RequestMap.Literal.INSTANCE) - .beanClass(beanManager, Map.class) + .scope(RequestScoped.class) + .qualifiers(RequestMap.Literal.INSTANCE) + .beanClass(beanManager, Map.class) .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, Object.class }), Map.class, Object.class) .create(e -> FacesContext.getCurrentInstance().getExternalContext().getRequestMap()); } diff --git a/impl/src/main/java/com/sun/faces/cdi/RequestParameterMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/RequestParameterMapProducer.java index 5184bb539b..61692237f1 100644 --- a/impl/src/main/java/com/sun/faces/cdi/RequestParameterMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/RequestParameterMapProducer.java @@ -43,9 +43,9 @@ public class RequestParameterMapProducer extends CdiProducer public RequestParameterMapProducer(BeanManager beanManager) { super.name("param") - .scope(RequestScoped.class) - .qualifiers(RequestParameterMap.Literal.INSTANCE) - .beanClass(beanManager, Map.class) + .scope(RequestScoped.class) + .qualifiers(RequestParameterMap.Literal.INSTANCE) + .beanClass(beanManager, Map.class) .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, String.class }), Map.class, Object.class) .create(e -> FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap()); } diff --git a/impl/src/main/java/com/sun/faces/cdi/RequestParameterValuesMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/RequestParameterValuesMapProducer.java index 674722f5c9..afe61b1597 100644 --- a/impl/src/main/java/com/sun/faces/cdi/RequestParameterValuesMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/RequestParameterValuesMapProducer.java @@ -43,10 +43,10 @@ public class RequestParameterValuesMapProducer extends CdiProducer FacesContext.getCurrentInstance().getExternalContext().getRequestParameterValuesMap()); } diff --git a/impl/src/main/java/com/sun/faces/cdi/ResourceHandlerProducer.java b/impl/src/main/java/com/sun/faces/cdi/ResourceHandlerProducer.java index 527cd91b4b..880c819a56 100644 --- a/impl/src/main/java/com/sun/faces/cdi/ResourceHandlerProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/ResourceHandlerProducer.java @@ -43,10 +43,10 @@ public class ResourceHandlerProducer extends CdiProducer { public ResourceHandlerProducer(BeanManager beanManager) { super.name("resource") - .scope(RequestScoped.class) - .beanClass(beanManager, ResourceHandler.class) - .types(ResourceHandler.class) - .create(e -> FacesContext.getCurrentInstance().getApplication().getResourceHandler()); + .scope(RequestScoped.class) + .beanClass(beanManager, ResourceHandler.class) + .types(ResourceHandler.class) + .create(e -> FacesContext.getCurrentInstance().getApplication().getResourceHandler()); } } diff --git a/impl/src/main/java/com/sun/faces/cdi/SessionMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/SessionMapProducer.java index 39da03254e..091c07df76 100644 --- a/impl/src/main/java/com/sun/faces/cdi/SessionMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/SessionMapProducer.java @@ -42,9 +42,9 @@ public class SessionMapProducer extends CdiProducer> { public SessionMapProducer(BeanManager beanManager) { super.name("sessionScope") - .scope(RequestScoped.class) - .qualifiers(SessionMap.Literal.INSTANCE) - .beanClass(beanManager, Map.class) + .scope(RequestScoped.class) + .qualifiers(SessionMap.Literal.INSTANCE) + .beanClass(beanManager, Map.class) .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, Object.class }), Map.class, Object.class) .create(e -> FacesContext.getCurrentInstance().getExternalContext().getSessionMap()); } diff --git a/impl/src/main/java/com/sun/faces/cdi/ViewMapProducer.java b/impl/src/main/java/com/sun/faces/cdi/ViewMapProducer.java index 430342c51e..060115d149 100644 --- a/impl/src/main/java/com/sun/faces/cdi/ViewMapProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/ViewMapProducer.java @@ -43,9 +43,9 @@ public class ViewMapProducer extends CdiProducer> { public ViewMapProducer(BeanManager beanManager) { super.name("viewScope") - .scope(RequestScoped.class) - .qualifiers(ViewMap.Literal.INSTANCE) - .beanClass(beanManager, Map.class) + .scope(RequestScoped.class) + .qualifiers(ViewMap.Literal.INSTANCE) + .beanClass(beanManager, Map.class) .types(new ParameterizedTypeImpl(Map.class, new Type[] { String.class, Object.class }), Map.class, Object.class) .create(e -> FacesContext.getCurrentInstance().getViewRoot().getViewMap()); } diff --git a/impl/src/main/java/com/sun/faces/cdi/ViewProducer.java b/impl/src/main/java/com/sun/faces/cdi/ViewProducer.java index d4450a9501..a631fb9ea1 100644 --- a/impl/src/main/java/com/sun/faces/cdi/ViewProducer.java +++ b/impl/src/main/java/com/sun/faces/cdi/ViewProducer.java @@ -38,9 +38,9 @@ public class ViewProducer extends CdiProducer { public ViewProducer(BeanManager beanManager) { super.name("view") - .scope(RequestScoped.class) - .beanClass(beanManager, UIViewRoot.class) - .types(UIViewRoot.class) + .scope(RequestScoped.class) + .beanClass(beanManager, UIViewRoot.class) + .types(UIViewRoot.class) .create(e -> FacesContext.getCurrentInstance().getViewRoot()); } From ff7c122309ade66de9192b63c5dbc0d1249027ed Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Fri, 26 Jul 2024 09:04:44 -0400 Subject: [PATCH 11/16] Fix #5464 xml escaping when writing attributes --- .../main/java/com/sun/faces/util/HtmlUtils.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/impl/src/main/java/com/sun/faces/util/HtmlUtils.java b/impl/src/main/java/com/sun/faces/util/HtmlUtils.java index 0815690a3d..98e4a5779f 100644 --- a/impl/src/main/java/com/sun/faces/util/HtmlUtils.java +++ b/impl/src/main/java/com/sun/faces/util/HtmlUtils.java @@ -217,6 +217,10 @@ static public void writeAttribute(Writer out, boolean escapeUnicode, boolean esc // UNICODE entities: encode as needed buffIndex = _writeDecRef(out, buff, buffIndex, buffLength, ch); } else { + if (forXml && !isAllowedXmlCharacter(ch)) { + continue; + } + buffIndex = addToBuffer(out, buff, buffIndex, buffLength, ch); } } @@ -302,6 +306,10 @@ static public void writeAttribute(Writer out, boolean escapeUnicode, boolean esc // UNICODE entities: encode as needed buffIndex = _writeDecRef(out, buff, buffIndex, buffLength, ch); } else { + if (forXml && !isAllowedXmlCharacter(ch)) { + continue; + } + buffIndex = addToBuffer(out, buff, buffIndex, buffLength, ch); } } @@ -316,6 +324,11 @@ static private boolean isPrintableControlChar(int ch, boolean forXml) { } + static private boolean isAllowedXmlCharacter(int ch) { + // See https://www.w3.org/TR/xml/#charsets Character Range + return ch < 0x20 ? isPrintableControlChar(ch, true) : ch <= 0xD7FF || ch >= 0xE000 && ch <= 0xFFFD; + } + /** * Writes a character as a decimal escape. Hex escapes are smaller than the decimal version, but Netscape didn't support * hex escapes until 4.7.4. @@ -550,8 +563,7 @@ static public void writeUnescapedTextForXML(Writer out, String text) throws IOEx for (int i = 0; i < length; i++) { final char ch = text.charAt(i); - if (ch < 0x20 ? isPrintableControlChar(ch, true) : ch <= 0xD7FF || ch >= 0xE000 && ch <= 0xFFFD) { - // Only those chars are allowed in XML. https://www.w3.org/TR/xml/#charsets Character Range + if (isAllowedXmlCharacter(ch)) { out.write(ch); } } From ecd652c6064b40908d3e51117d6587aba059f614 Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Sat, 27 Jul 2024 16:46:29 -0400 Subject: [PATCH 12/16] Fix #5460: regression after fixing #5417: the composite component attribute default value wasn't anymore available when explicitly calling getAttributes().get(name) rather than relying on statehelper -- this has been fixed --- .../applicationimpl/InstanceFactory.java | 19 ------------- .../faces/component/UIComponentBase.java | 28 ++++++++++++++++++- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/impl/src/main/java/com/sun/faces/application/applicationimpl/InstanceFactory.java b/impl/src/main/java/com/sun/faces/application/applicationimpl/InstanceFactory.java index fc19300977..ef1256c981 100644 --- a/impl/src/main/java/com/sun/faces/application/applicationimpl/InstanceFactory.java +++ b/impl/src/main/java/com/sun/faces/application/applicationimpl/InstanceFactory.java @@ -828,25 +828,6 @@ private void pushDeclaredDefaultValuesToAttributesMap(FacesContext context, Bean } } - /** - * Helper method to convert a value to a type as defined in PropertyDescriptor(s) - * - * @param name - * @param value - * @param propertyDescriptors - * @return value - */ - private Object convertValueToTypeIfNecessary(String name, Object value, PropertyDescriptor[] propertyDescriptors, ExpressionFactory expressionFactory) { - for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { - if (propertyDescriptor.getName().equals(name)) { - value = expressionFactory.coerceToType(value, propertyDescriptor.getPropertyType()); - break; - } - } - - return value; - } - /** *

* To enable EL Coercion to use Faces Custom converters, this method will call diff --git a/impl/src/main/java/jakarta/faces/component/UIComponentBase.java b/impl/src/main/java/jakarta/faces/component/UIComponentBase.java index 69a1ed7835..6f51537e46 100644 --- a/impl/src/main/java/jakarta/faces/component/UIComponentBase.java +++ b/impl/src/main/java/jakarta/faces/component/UIComponentBase.java @@ -31,6 +31,7 @@ import static java.util.Collections.unmodifiableList; import static java.util.logging.Level.FINE; +import java.beans.BeanInfo; import java.beans.IntrospectionException; import java.beans.PropertyDescriptor; import java.io.IOException; @@ -1978,10 +1979,35 @@ public Object get(Object keyObj) { } } } - + if (result == null && attributes != null && isCompositeComponent(component)) { + result = getCompositeComponentAttributeDefaultValue(key, attributes); + } return result; } + private Object getCompositeComponentAttributeDefaultValue(String name, Map attributes) { + var metadata = (BeanInfo) attributes.get(UIComponent.BEANINFO_KEY); + + if (metadata != null) { + for (var propertyDescriptor : metadata.getPropertyDescriptors()) { + if (propertyDescriptor.getName().equals(name)) { + var defaultValue = propertyDescriptor.getValue("default"); + + if (defaultValue != null) { + if (defaultValue instanceof ValueExpression) { + defaultValue = ((ValueExpression) defaultValue).getValue(component.getFacesContext().getELContext()); + } + + var expressionFactory = component.getFacesContext().getApplication().getExpressionFactory(); + return expressionFactory.coerceToType(defaultValue, propertyDescriptor.getPropertyType()); + } + } + } + } + + return null; + } + @Override public Object put(String keyValue, Object value) { if (keyValue == null) { From 985220da05a2d0a34d36e530bbe512e1d06c7225 Mon Sep 17 00:00:00 2001 From: Bauke Scholtz Date: Sun, 28 Jul 2024 14:11:19 -0400 Subject: [PATCH 13/16] Add unit test for #5464 --- .../java/com/sun/faces/util/HtmlUtils.java | 2 +- .../com/sun/faces/util/HtmlUtilsTest.java | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 impl/src/test/java/com/sun/faces/util/HtmlUtilsTest.java diff --git a/impl/src/main/java/com/sun/faces/util/HtmlUtils.java b/impl/src/main/java/com/sun/faces/util/HtmlUtils.java index 98e4a5779f..8018751faf 100644 --- a/impl/src/main/java/com/sun/faces/util/HtmlUtils.java +++ b/impl/src/main/java/com/sun/faces/util/HtmlUtils.java @@ -324,7 +324,7 @@ static private boolean isPrintableControlChar(int ch, boolean forXml) { } - static private boolean isAllowedXmlCharacter(int ch) { + public static boolean isAllowedXmlCharacter(int ch) { // See https://www.w3.org/TR/xml/#charsets Character Range return ch < 0x20 ? isPrintableControlChar(ch, true) : ch <= 0xD7FF || ch >= 0xE000 && ch <= 0xFFFD; } diff --git a/impl/src/test/java/com/sun/faces/util/HtmlUtilsTest.java b/impl/src/test/java/com/sun/faces/util/HtmlUtilsTest.java new file mode 100644 index 0000000000..7939d6ffca --- /dev/null +++ b/impl/src/test/java/com/sun/faces/util/HtmlUtilsTest.java @@ -0,0 +1,48 @@ +package com.sun.faces.util; + +import static com.sun.faces.util.HtmlUtils.isAllowedXmlCharacter; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +class HtmlUtilsTest { + + /** + * https://github.com/eclipse-ee4j/mojarra/issues/4516 + * https://github.com/eclipse-ee4j/mojarra/issues/5464 + */ + @Test + void testAllowedXmlCharacter() { + for (int c = 0x0000; c <= 0x0008; c++) { + assertFalse(isAllowedXmlCharacter(c)); + } + + assertTrue(isAllowedXmlCharacter(0x0009)); + assertTrue(isAllowedXmlCharacter(0x000A)); + + assertFalse(isAllowedXmlCharacter(0x000B)); + assertFalse(isAllowedXmlCharacter(0x000C)); + + assertTrue(isAllowedXmlCharacter(0x000D)); + + for (int c = 0x000E; c <= 0x0019; c++) { + assertFalse(isAllowedXmlCharacter(c)); + } + + for (int c = 0x0020; c <= 0xD7FF; c++) { + assertTrue(isAllowedXmlCharacter(c)); + } + + for (int c = 0xD800; c <= 0xDFFF; c++) { + assertFalse(isAllowedXmlCharacter(c)); + } + + for (int c = 0xE000; c <= 0xFFFD; c++) { + assertTrue(isAllowedXmlCharacter(c)); + } + + assertFalse(isAllowedXmlCharacter(0xFFFE)); + assertFalse(isAllowedXmlCharacter(0xFFFF)); + } +} From 81abc81d16c336570d18e5a8da70069629b5ae4d Mon Sep 17 00:00:00 2001 From: Cody Lerum Date: Tue, 30 Jul 2024 13:35:08 +0100 Subject: [PATCH 14/16] move logic to within the try catch --- .../java/com/sun/faces/context/flash/ELFlash.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/impl/src/main/java/com/sun/faces/context/flash/ELFlash.java b/impl/src/main/java/com/sun/faces/context/flash/ELFlash.java index c653e4627d..721c8be739 100644 --- a/impl/src/main/java/com/sun/faces/context/flash/ELFlash.java +++ b/impl/src/main/java/com/sun/faces/context/flash/ELFlash.java @@ -1311,22 +1311,19 @@ void expireNext_MovePreviousToNext() { */ void decode(FacesContext context, ELFlash flash, Cookie cookie) throws InvalidKeyException { - String temp; - String value; - String urlDecodedValue = URLDecoder.decode(cookie.getValue(), UTF_8); - value = guard.decrypt(urlDecodedValue); - try { + String urlDecodedValue = URLDecoder.decode(cookie.getValue(), UTF_8); + String value = guard.decrypt(urlDecodedValue); int i = value.indexOf("_"); // IMPORTANT: what was "next" when the cookie was // encoded is now "previous". Therefore decode "next" first. - temp = value.substring(0, i++); - + String temp = value.substring(0, i++); if (0 < temp.length()) { nextRequestFlashInfo = new FlashInfo(); nextRequestFlashInfo.decode(temp); } + // invariant we must always have something after the _ previousRequestFlashInfo = new FlashInfo(); previousRequestFlashInfo.decode(value.substring(i)); From 4cf12d7a87b6ad8b3f3e2be4dda7db4bf1ac51ee Mon Sep 17 00:00:00 2001 From: Cody Lerum Date: Tue, 30 Jul 2024 13:46:08 +0100 Subject: [PATCH 15/16] define value the try catch --- impl/src/main/java/com/sun/faces/context/flash/ELFlash.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/impl/src/main/java/com/sun/faces/context/flash/ELFlash.java b/impl/src/main/java/com/sun/faces/context/flash/ELFlash.java index 721c8be739..bcd58fcbf1 100644 --- a/impl/src/main/java/com/sun/faces/context/flash/ELFlash.java +++ b/impl/src/main/java/com/sun/faces/context/flash/ELFlash.java @@ -1311,9 +1311,10 @@ void expireNext_MovePreviousToNext() { */ void decode(FacesContext context, ELFlash flash, Cookie cookie) throws InvalidKeyException { + String value; try { String urlDecodedValue = URLDecoder.decode(cookie.getValue(), UTF_8); - String value = guard.decrypt(urlDecodedValue); + value = guard.decrypt(urlDecodedValue); int i = value.indexOf("_"); // IMPORTANT: what was "next" when the cookie was From 4c739651fab79288814ec2407cda44c33b4cd18d Mon Sep 17 00:00:00 2001 From: Cody Lerum Date: Tue, 30 Jul 2024 13:48:53 +0100 Subject: [PATCH 16/16] initially initialize value to null --- impl/src/main/java/com/sun/faces/context/flash/ELFlash.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/impl/src/main/java/com/sun/faces/context/flash/ELFlash.java b/impl/src/main/java/com/sun/faces/context/flash/ELFlash.java index bcd58fcbf1..cb16c895d7 100644 --- a/impl/src/main/java/com/sun/faces/context/flash/ELFlash.java +++ b/impl/src/main/java/com/sun/faces/context/flash/ELFlash.java @@ -1311,7 +1311,7 @@ void expireNext_MovePreviousToNext() { */ void decode(FacesContext context, ELFlash flash, Cookie cookie) throws InvalidKeyException { - String value; + String value = null; try { String urlDecodedValue = URLDecoder.decode(cookie.getValue(), UTF_8); value = guard.decrypt(urlDecodedValue);