You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2022/12/24 13:31:17 UTC

[myfaces] branch main updated: Quarkus 3 support (#459)

This is an automated email from the ASF dual-hosted git repository.

tandraschko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/main by this push:
     new 6b9f8d9df Quarkus 3 support (#459)
6b9f8d9df is described below

commit 6b9f8d9dfde2375982e7eaaa80c7054140e003d5
Author: Melloware <me...@gmail.com>
AuthorDate: Sat Dec 24 08:31:12 2022 -0500

    Quarkus 3 support (#459)
---
 .../quarkus/deployment/MyFacesProcessor.java       |  2 +
 extensions/quarkus/showcase/pom.xml                |  2 +-
 .../showcase/QuarkusMyFacesShowcaseTest.java       |  2 +-
 .../myfaces/cdi/view/ViewScopeEventListener.java   | 37 +-------------
 .../cdi/view/ViewScopeEventListenerBridge.java     | 56 ++++++++++++++++++++++
 .../myfaces/cdi/view/ViewScopeExtension.java       |  2 +-
 pom.xml                                            |  2 -
 7 files changed, 63 insertions(+), 40 deletions(-)

diff --git a/extensions/quarkus/deployment/src/main/java/org/apache/myfaces/core/extensions/quarkus/deployment/MyFacesProcessor.java b/extensions/quarkus/deployment/src/main/java/org/apache/myfaces/core/extensions/quarkus/deployment/MyFacesProcessor.java
index 59c54218e..29f3d6a8c 100644
--- a/extensions/quarkus/deployment/src/main/java/org/apache/myfaces/core/extensions/quarkus/deployment/MyFacesProcessor.java
+++ b/extensions/quarkus/deployment/src/main/java/org/apache/myfaces/core/extensions/quarkus/deployment/MyFacesProcessor.java
@@ -115,6 +115,7 @@ import org.apache.myfaces.application.ApplicationImplEventManager;
 import org.apache.myfaces.application.viewstate.StateUtils;
 import org.apache.myfaces.cdi.util.BeanEntry;
 import org.apache.myfaces.cdi.view.ViewScopeContextualStorageHolder;
+import org.apache.myfaces.cdi.view.ViewScopeEventListenerBridge;
 import org.apache.myfaces.config.FacesConfigurator;
 import org.apache.myfaces.core.api.shared.lang.PropertyDescriptorUtils;
 import org.apache.myfaces.core.extensions.quarkus.runtime.spi.QuarkusFactoryFinderProvider;
@@ -153,6 +154,7 @@ class MyFacesProcessor
             FacesConfigBeanHolder.class,
             FacesDataModelManager.class,
             ViewScopeContextualStorageHolder.class,
+            ViewScopeEventListenerBridge.class,
             CdiAnnotationProviderExtension.class,
             WebsocketChannelTokenBuilder.class,
             WebsocketSessionManager.class,
diff --git a/extensions/quarkus/showcase/pom.xml b/extensions/quarkus/showcase/pom.xml
index 9335c2bc0..afd5db8b8 100644
--- a/extensions/quarkus/showcase/pom.xml
+++ b/extensions/quarkus/showcase/pom.xml
@@ -83,7 +83,7 @@
         <dependency>
             <groupId>net.sourceforge.htmlunit</groupId>
             <artifactId>htmlunit</artifactId>
-            <version>2.41.0</version>
+            <version>2.67.0</version>
             <scope>test</scope>
         </dependency>
         <dependency>
diff --git a/extensions/quarkus/showcase/src/test/java/org/apache/myfaces/core/extensions/quarkus/showcase/QuarkusMyFacesShowcaseTest.java b/extensions/quarkus/showcase/src/test/java/org/apache/myfaces/core/extensions/quarkus/showcase/QuarkusMyFacesShowcaseTest.java
index c9ac66ec7..5a3e20be7 100644
--- a/extensions/quarkus/showcase/src/test/java/org/apache/myfaces/core/extensions/quarkus/showcase/QuarkusMyFacesShowcaseTest.java
+++ b/extensions/quarkus/showcase/src/test/java/org/apache/myfaces/core/extensions/quarkus/showcase/QuarkusMyFacesShowcaseTest.java
@@ -69,7 +69,7 @@ public class QuarkusMyFacesShowcaseTest {
         final HtmlPage page = webClient.getPage(url + "/index.xhtml");
         final HtmlDivision datatable = (HtmlDivision) page.getElementById("form:carTable");
         assertThat(datatable).isNotNull();
-        assertThat(datatable.getByXPath("//tr[contains(@role,'row') and contains(@class,'ui-datatable-selectable')]"))
+        assertThat(datatable.getByXPath("//tr[contains(@class,'ui-datatable-selectable')]"))
                 .hasSize(10);
     }
 
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeEventListener.java b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeEventListener.java
index 50c9ec620..a7e468a49 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeEventListener.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeEventListener.java
@@ -18,33 +18,25 @@
  */
 package org.apache.myfaces.cdi.view;
 
-import jakarta.enterprise.context.ApplicationScoped;
-import jakarta.enterprise.context.Destroyed;
-import jakarta.enterprise.context.Initialized;
-import jakarta.enterprise.event.Event;
 import jakarta.enterprise.inject.spi.BeanManager;
 import jakarta.faces.component.UIViewRoot;
 import jakarta.faces.context.FacesContext;
 import jakarta.faces.event.AbortProcessingException;
-import jakarta.faces.event.PostConstructViewMapEvent;
-import jakarta.faces.event.PreDestroyViewMapEvent;
 import jakarta.faces.event.SystemEvent;
 import jakarta.faces.event.ViewMapListener;
-import jakarta.faces.view.ViewScoped;
-import jakarta.inject.Inject;
 import org.apache.myfaces.cdi.util.CDIUtils;
 import org.apache.myfaces.util.ExternalSpecifications;
 import org.apache.myfaces.util.lang.Lazy;
 
 public class ViewScopeEventListener implements ViewMapListener
 {
-    private Lazy<Bridge> bridge = new Lazy<>(() ->
+    private Lazy<ViewScopeEventListenerBridge> bridge = new Lazy<>(() ->
     {
         FacesContext facesContext = FacesContext.getCurrentInstance();
         if (ExternalSpecifications.isCDIAvailable(facesContext.getExternalContext()))
         {
             BeanManager beanManager = CDIUtils.getBeanManager(facesContext);
-            return CDIUtils.get(beanManager, Bridge.class);
+            return CDIUtils.get(beanManager, ViewScopeEventListenerBridge.class);
         }
         return null;
     });
@@ -63,29 +55,4 @@ public class ViewScopeEventListener implements ViewMapListener
             bridge.get().processEvent(event);
         }
     }
-
-    @ApplicationScoped
-    public static class Bridge
-    {
-        @Inject
-        @Initialized(ViewScoped.class)
-        private Event<UIViewRoot> viewScopeInitializedEvent;
-
-        @Inject
-        @Destroyed(ViewScoped.class)
-        private Event<UIViewRoot> viewScopeDestroyedEvent;
-
-        public void processEvent(SystemEvent event) throws AbortProcessingException
-        {
-            if (event instanceof PostConstructViewMapEvent)
-            {
-                viewScopeInitializedEvent.fire((UIViewRoot) event.getSource());
-            }
-
-            if (event instanceof PreDestroyViewMapEvent)
-            {
-                viewScopeDestroyedEvent.fire((UIViewRoot) event.getSource());
-            }
-        }
-    }
 }
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeEventListenerBridge.java b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeEventListenerBridge.java
new file mode 100644
index 000000000..b5dd02c1d
--- /dev/null
+++ b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeEventListenerBridge.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.cdi.view;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.context.Destroyed;
+import jakarta.enterprise.context.Initialized;
+import jakarta.enterprise.event.Event;
+import jakarta.faces.component.UIViewRoot;
+import jakarta.faces.event.AbortProcessingException;
+import jakarta.faces.event.PostConstructViewMapEvent;
+import jakarta.faces.event.PreDestroyViewMapEvent;
+import jakarta.faces.event.SystemEvent;
+import jakarta.faces.view.ViewScoped;
+import jakarta.inject.Inject;
+
+@ApplicationScoped
+public class ViewScopeEventListenerBridge
+{
+    @Inject
+    @Initialized(ViewScoped.class)
+    private Event<UIViewRoot> viewScopeInitializedEvent;
+
+    @Inject
+    @Destroyed(ViewScoped.class)
+    private Event<UIViewRoot> viewScopeDestroyedEvent;
+
+    public void processEvent(SystemEvent event) throws AbortProcessingException
+    {
+        if (event instanceof PostConstructViewMapEvent)
+        {
+            viewScopeInitializedEvent.fire((UIViewRoot) event.getSource());
+        }
+
+        if (event instanceof PreDestroyViewMapEvent)
+        {
+            viewScopeDestroyedEvent.fire((UIViewRoot) event.getSource());
+        }
+    }
+}
diff --git a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeExtension.java b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeExtension.java
index 242efada2..1aca53286 100644
--- a/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeExtension.java
+++ b/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeExtension.java
@@ -43,7 +43,7 @@ public class ViewScopeExtension implements Extension
         AnnotatedType bean = beanManager.createAnnotatedType(ViewScopeContextualStorageHolder.class);
         event.addAnnotatedType(bean, bean.getJavaClass().getName());
 
-        bean = beanManager.createAnnotatedType(ViewScopeEventListener.Bridge.class);
+        bean = beanManager.createAnnotatedType(ViewScopeEventListenerBridge.class);
         event.addAnnotatedType(bean, bean.getJavaClass().getName());
     }
     
diff --git a/pom.xml b/pom.xml
index 46de22253..afa7a151e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -56,9 +56,7 @@
         <module>impl</module>
         <module>bundle</module>
         <module>integration-tests</module>
-        <!--
         <module>extensions</module>
-        -->
     </modules>
 
     <build>