rmannibucau commented on code in PR #1278:
URL: https://github.com/apache/tomee/pull/1278#discussion_r1673593511


##########
tomee/tomee-mojarra/src/main/resources/META-INF/openwebbeans/openwebbeans.properties:
##########
@@ -0,0 +1,22 @@
+#
+# 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.
+
+configuration.ordinal=75
+
+# We need to workaround an integration issue between Mojarra and OWB right now
+# For more details see https://github.com/apache/openwebbeans/pull/89
+# and https://github.com/eclipse-ee4j/mojarra/issues/5457
+org.apache.webbeans.ignoredExtensions=com.sun.faces.cdi.CdiExtension

Review Comment:
   I'd rather not use it since the values are not merged so it means users 
can't rely on that anymore



##########
tomee/tomee-mojarra/src/main/resources/META-INF/services/jakarta.enterprise.inject.spi.Extension:
##########
@@ -0,0 +1 @@
+org.apache.tomee.mojarra.owb.OwbCompatibleCdiExtension

Review Comment:
   using the programmatic approach you can drop this file



##########
tomee/tomee-mojarra/src/main/java/org/apache/tomee/mojarra/owb/MojarraAfterBeanDiscoveryDecorator.java:
##########
@@ -0,0 +1,76 @@
+/**
+ * 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.tomee.mojarra.owb;
+
+import jakarta.enterprise.context.spi.Context;
+import jakarta.enterprise.inject.spi.AfterBeanDiscovery;
+import jakarta.enterprise.inject.spi.AnnotatedType;
+import jakarta.enterprise.inject.spi.Bean;
+import jakarta.enterprise.inject.spi.ObserverMethod;
+import jakarta.enterprise.inject.spi.configurator.BeanConfigurator;
+import jakarta.enterprise.inject.spi.configurator.ObserverMethodConfigurator;
+import org.apache.webbeans.config.WebBeansContext;
+
+public class MojarraAfterBeanDiscoveryDecorator implements AfterBeanDiscovery {
+    private final AfterBeanDiscovery delegate;
+    private final WebBeansContext webBeansContext;
+
+    public MojarraAfterBeanDiscoveryDecorator(final AfterBeanDiscovery 
delegate) {
+        this.delegate = delegate;
+        this.webBeansContext = WebBeansContext.currentInstance();

Review Comment:
   guess it is saner to pass the context programmatically so surely using a 
programmatic approach
   
   it would also enable to replace the extension properly without having to 
potentially override user conf or this conf to be lost if user overrides it
   
   I'd encourage you to maybe try something around 
https://github.com/apache/tomee/blob/e953d0665d207b730e3f21cc032f1cf75123b9c9/container/openejb-core/src/main/java/org/apache/openejb/cdi/OptimizedLoaderService.java#L86,
 in particular the `isFiltered` method which can replace the 
openwebbeans.properties in a better way IMHO.
   Modifying a little bit the logic you can also switch the extension:
   
   
   ```
           while (it.hasNext()) {
               if (it.hasNext()) {
                   if (isFiltered(extensionCopy, it.next())) {
                       it.remove();
                   }
               }
           }
   ```
   
   ->
   
   ```
           List<Extension> toAdd = null;
           while (it.hasNext()) {
               var next = it.next();
               var replacement = replace(next);
               if (replacement != null && !isFiltered(extensionCopy, 
replacement)) {
                   (toAdd == null ? toAdd = new ArrayList<>()  : 
toAdd).add(replacement);
               }
               if (isFiltered(extensionCopy, next)) {
                   it.remove();
               }
           }
           list.addAdd(toAdd);
   
   ....
   
       public Extension replace(final Extension current) { // + 
try/catch(e){/*ignore*/}
           return Objects.equals("....CdiExtension", 
current.getClass().getName()) ? 
current.getClass().getClassLoader().loadClass("....replacment").asSubClass(Extension.class).getConstructor().newInstance();
       }
   ```
   
   (in the spirit)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@tomee.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to