Merge branch 'main' into fault-tolerance
diff --git a/boms/tomee-microprofile/pom.xml b/boms/tomee-microprofile/pom.xml
index bd14af1..914ac20 100644
--- a/boms/tomee-microprofile/pom.xml
+++ b/boms/tomee-microprofile/pom.xml
@@ -388,8 +388,42 @@
</dependency>
<dependency>
<groupId>io.smallrye</groupId>
+ <artifactId>smallrye-fault-tolerance-api</artifactId>
+ <version>6.0.0-RC4</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.smallrye</groupId>
+ <artifactId>smallrye-fault-tolerance-autoconfig-core</artifactId>
+ <version>6.0.0-RC4</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.smallrye</groupId>
<artifactId>smallrye-fault-tolerance-core</artifactId>
- <version>6.0.0</version>
+
+ <version>6.0.0-RC4</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.smallrye</groupId>
+ <artifactId>smallrye-fault-tolerance</artifactId>
+ <version>6.0.0-RC4</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
diff --git a/boms/tomee-plume/pom.xml b/boms/tomee-plume/pom.xml
index c938931..632c776 100644
--- a/boms/tomee-plume/pom.xml
+++ b/boms/tomee-plume/pom.xml
@@ -399,8 +399,41 @@
</dependency>
<dependency>
<groupId>io.smallrye</groupId>
+ <artifactId>smallrye-fault-tolerance-api</artifactId>
+ <version>6.0.0-RC4</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.smallrye</groupId>
+ <artifactId>smallrye-fault-tolerance-autoconfig-core</artifactId>
+ <version>6.0.0-RC4</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.smallrye</groupId>
<artifactId>smallrye-fault-tolerance-core</artifactId>
- <version>6.0.0</version>
+ <version>6.0.0-RC4</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.smallrye</groupId>
+ <artifactId>smallrye-fault-tolerance</artifactId>
+ <version>6.0.0-RC4</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
diff --git a/boms/tomee-plus/pom.xml b/boms/tomee-plus/pom.xml
index c0c9823..78ea5a5 100644
--- a/boms/tomee-plus/pom.xml
+++ b/boms/tomee-plus/pom.xml
@@ -410,8 +410,41 @@
</dependency>
<dependency>
<groupId>io.smallrye</groupId>
+ <artifactId>smallrye-fault-tolerance-api</artifactId>
+ <version>6.0.0-RC4</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.smallrye</groupId>
+ <artifactId>smallrye-fault-tolerance-autoconfig-core</artifactId>
+ <version>6.0.0-RC4</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.smallrye</groupId>
<artifactId>smallrye-fault-tolerance-core</artifactId>
- <version>6.0.0</version>
+ <version>6.0.0-RC4</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.smallrye</groupId>
+ <artifactId>smallrye-fault-tolerance</artifactId>
+ <version>6.0.0-RC4</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
diff --git a/pom.xml b/pom.xml
index 92d4b59..f8963bd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -229,7 +229,8 @@
<microprofile.fault-tolerance.version>4.0</microprofile.fault-tolerance.version>
<microprofile.fault-tolerance.tck.version>4.0</microprofile.fault-tolerance.tck.version>
- <microprofile.fault-tolerance.impl.version>6.0.0</microprofile.fault-tolerance.impl.version>
+ <microprofile.fault-tolerance.impl.version>6.0.0-RC4</microprofile.fault-tolerance.impl.version>
+
<microprofile.health.version>4.0</microprofile.health.version>
<microprofile.health.tck.version>4.0</microprofile.health.tck.version>
diff --git a/tck/microprofile-tck/fault-tolerance/pom.xml b/tck/microprofile-tck/fault-tolerance/pom.xml
index 766bdfd..2ebad16 100644
--- a/tck/microprofile-tck/fault-tolerance/pom.xml
+++ b/tck/microprofile-tck/fault-tolerance/pom.xml
@@ -84,16 +84,9 @@
<dependencies>
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>microprofile-fault-tolerance-api-shade</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>org.eclipse.microprofile.fault-tolerance</groupId>
- <artifactId>microprofile-fault-tolerance-api</artifactId>
- </exclusion>
- </exclusions>
+ <groupId>org.eclipse.microprofile.fault-tolerance</groupId>
+ <artifactId>microprofile-fault-tolerance-api</artifactId>
+ <version>${microprofile.fault-tolerance.version}</version>
</dependency>
<dependency>
diff --git a/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/LoggingTestListener.java b/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/LoggingTestListener.java
new file mode 100644
index 0000000..bf2abd9
--- /dev/null
+++ b/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/LoggingTestListener.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2017 Red Hat, Inc, and individual contributors.
+ *
+ * Licensed 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.microprofile.tck.fault.tolerance;
+
+import org.testng.ITestContext;
+import org.testng.ITestListener;
+import org.testng.ITestResult;
+
+
+public class LoggingTestListener implements ITestListener {
+
+ @Override
+ public void onTestStart(ITestResult result) {
+ System.out.println("Starting " + result.getTestClass().getName() + "#" + result.getMethod().getMethodName());
+ }
+
+ @Override
+ public void onTestSuccess(ITestResult result) {
+ System.out.println("Succeeded " + result.getTestClass().getName() + "#" + result.getMethod().getMethodName());
+ }
+
+ @Override
+ public void onTestFailure(ITestResult result) {
+ System.out.println("Failed " + result.getTestClass().getName() + "#" + result.getMethod().getMethodName());
+ }
+
+ @Override
+ public void onTestSkipped(ITestResult result) {
+ System.out.println("Skipped " + result.getTestClass().getName() + "#" + result.getMethod().getMethodName());
+ }
+
+ @Override
+ public void onTestFailedButWithinSuccessPercentage(ITestResult result) {
+ }
+
+ @Override
+ public void onStart(ITestContext context) {
+ }
+
+ @Override
+ public void onFinish(ITestContext context) {
+ }
+}
diff --git a/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/MicroProfileFaultToleranceDeploymentProcessor.java b/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/MicroProfileFaultToleranceDeploymentProcessor.java
new file mode 100644
index 0000000..77c7913
--- /dev/null
+++ b/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/MicroProfileFaultToleranceDeploymentProcessor.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2017 Red Hat, Inc, and individual contributors.
+ *
+ * Licensed 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.microprofile.tck.fault.tolerance;
+
+import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor;
+import org.jboss.arquillian.test.spi.TestClass;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.container.ClassContainer;
+import org.jboss.shrinkwrap.api.container.LibraryContainer;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+
+import java.util.logging.Logger;
+
+public class MicroProfileFaultToleranceDeploymentProcessor implements ApplicationArchiveProcessor {
+
+ private static final Logger LOGGER = Logger.getLogger(MicroProfileFaultToleranceDeploymentProcessor.class.getName());
+
+ @Override
+ public void process(Archive<?> applicationArchive, TestClass testClass) {
+ if (!(applicationArchive instanceof ClassContainer)) {
+ LOGGER.warning("Unable to add additional classes - not a class/resource container: " + applicationArchive);
+ return;
+ }
+ ClassContainer<?> classContainer = (ClassContainer<?>) applicationArchive;
+
+ if (applicationArchive instanceof LibraryContainer) {
+ JavaArchive additionalBeanArchive = ShrinkWrap.create(JavaArchive.class);
+ additionalBeanArchive.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+ ((LibraryContainer<?>) applicationArchive).addAsLibrary(additionalBeanArchive);
+ } else {
+ classContainer.addAsResource(EmptyAsset.INSTANCE, "META-INF/beans.xml");
+ }
+
+ if (!applicationArchive.contains("META-INF/beans.xml")) {
+ applicationArchive.add(EmptyAsset.INSTANCE, "META-INF/beans.xml");
+ }
+ }
+}
diff --git a/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/MicroProfileFaultToleranceExtension.java b/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/MicroProfileFaultToleranceExtension.java
new file mode 100644
index 0000000..ec2d53d
--- /dev/null
+++ b/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/MicroProfileFaultToleranceExtension.java
@@ -0,0 +1,30 @@
+/*
+ * 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.microprofile.tck.fault.tolerance;
+
+import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor;
+import org.jboss.arquillian.core.spi.LoadableExtension;
+
+public class MicroProfileFaultToleranceExtension implements LoadableExtension {
+
+ @Override
+ public void register(ExtensionBuilder builder) {
+ builder.service(ApplicationArchiveProcessor.class, MicroProfileFaultToleranceDeploymentProcessor.class);
+ builder.service(ApplicationArchiveProcessor.class, RetryTckOnMac.class);
+ }
+
+}
diff --git a/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/RetryTckOnMac.java b/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/RetryTckOnMac.java
new file mode 100644
index 0000000..73fe71d
--- /dev/null
+++ b/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/RetryTckOnMac.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.tomee.microprofile.tck.fault.tolerance;
+
+import org.eclipse.microprofile.fault.tolerance.tck.RetryTest;
+import org.eclipse.microprofile.fault.tolerance.tck.config.ConfigAnnotationAsset;
+import org.eclipse.microprofile.fault.tolerance.tck.retry.clientserver.RetryClassLevelClientForMaxRetries;
+import org.eclipse.microprofile.faulttolerance.Retry;
+import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor;
+import org.jboss.arquillian.test.spi.TestClass;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+
+import java.util.Locale;
+
+/**
+ * Copied from SmallRye Fault Tolerance
+ */
+public class RetryTckOnMac implements ApplicationArchiveProcessor {
+ // TODO
+ // The `RetryTest.testClassLevelRetryMaxDuration` TCK test often fails in CI on the macOS machines.
+ // This is because the test doesn't properly scale delays and timeouts, unlike majority of the tests
+ // in the TCK, and `Thread.sleep(100)` often takes roughly 200 millis on the macOS machines in CI.
+ // Here, we work around that problem by reducing jitter on the affected method to 0, thereby significantly
+ // reducing the impact of the `Thread.sleep()` slowdown.
+
+ @Override
+ public void process(Archive<?> applicationArchive, TestClass testClass) {
+ if (isMac() && RetryTest.class.getName().equals(testClass.getName())) {
+ ConfigAnnotationAsset config = (ConfigAnnotationAsset) applicationArchive
+ .getAsType(JavaArchive.class, "/WEB-INF/lib/ftRetry.jar")
+ .get("/META-INF/microprofile-config.properties")
+ .getAsset();
+ config.set(RetryClassLevelClientForMaxRetries.class, "serviceB", Retry.class, "jitter", "0");
+ }
+ }
+
+ private boolean isMac() {
+ String os = System.getProperty("os.name", "unknown").toLowerCase(Locale.ROOT);
+ return os.contains("mac") || os.contains("darwin");
+ }
+}
diff --git a/tck/microprofile-tck/fault-tolerance/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension b/tck/microprofile-tck/fault-tolerance/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
new file mode 100644
index 0000000..b468993
--- /dev/null
+++ b/tck/microprofile-tck/fault-tolerance/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
@@ -0,0 +1 @@
+org.apache.tomee.microprofile.tck.fault.tolerance.MicroProfileFaultToleranceExtension
\ No newline at end of file
diff --git a/tck/microprofile-tck/fault-tolerance/src/test/resources/arquillian.xml b/tck/microprofile-tck/fault-tolerance/src/test/resources/arquillian.xml
index 9fc654b..da140a6 100644
--- a/tck/microprofile-tck/fault-tolerance/src/test/resources/arquillian.xml
+++ b/tck/microprofile-tck/fault-tolerance/src/test/resources/arquillian.xml
@@ -26,6 +26,7 @@
<property name="httpPort">-1</property>
<property name="ajpPort">-1</property>
<property name="stopPort">-1</property>
+ <property name="debug">false</property>
<property name="classifier">microprofile</property>
<property name="conf">src/test/conf</property>
<property name="dir">target/tomee</property>
diff --git a/tck/microprofile-tck/fault-tolerance/tck-dev.xml b/tck/microprofile-tck/fault-tolerance/tck-dev.xml
new file mode 100644
index 0000000..2576293
--- /dev/null
+++ b/tck/microprofile-tck/fault-tolerance/tck-dev.xml
@@ -0,0 +1,30 @@
+<!--
+ 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.
+ -->
+<suite name="microprofile-fault-tolerance-TCK" verbose="2" configfailurepolicy="continue" >
+
+ <test name="microprofile-fault-tolerance TCK">
+ <packages>
+ <package name="org.eclipse.microprofile.fault.tolerance.tck.*">
+ </package>
+ </packages>
+<!--
+ <classes>
+ <class name="org.eclipse.microprofile.fault.tolerance.tck.CircuitBreakerLateSuccessTest"></class>
+ </classes>
+-->
+ </test>
+</suite>
\ No newline at end of file
diff --git a/tck/microprofile-tck/pom.xml b/tck/microprofile-tck/pom.xml
index da59e09..ea598ab 100644
--- a/tck/microprofile-tck/pom.xml
+++ b/tck/microprofile-tck/pom.xml
@@ -36,9 +36,9 @@
<module>metrics</module>
<module>rest-client</module>
<module>openapi</module>
+ <module>fault-tolerance</module>
<!--
<module>opentracing</module>
- <module>fault-tolerance</module>
-->
</modules>
</project>
diff --git a/tomee/tomee-microprofile/mp-common/pom.xml b/tomee/tomee-microprofile/mp-common/pom.xml
index 9d1b8ff..03bf4df 100644
--- a/tomee/tomee-microprofile/mp-common/pom.xml
+++ b/tomee/tomee-microprofile/mp-common/pom.xml
@@ -101,7 +101,7 @@
<dependency>
<groupId>io.smallrye</groupId>
- <artifactId>smallrye-fault-tolerance-core</artifactId>
+ <artifactId>smallrye-fault-tolerance</artifactId>
<version>${microprofile.fault-tolerance.impl.version}</version>
<exclusions>
<exclusion>
diff --git a/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/TomEEMicroProfileListener.java b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/TomEEMicroProfileListener.java
index 4b3502a..23a1920 100644
--- a/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/TomEEMicroProfileListener.java
+++ b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/TomEEMicroProfileListener.java
@@ -56,6 +56,7 @@
"io.smallrye.config.inject.ConfigExtension",
"io.smallrye.metrics.setup.MetricCdiInjectionExtension",
"io.smallrye.opentracing.SmallRyeTracingDynamicFeature",
+ "io.smallrye.faulttolerance.FaultToleranceExtension",
};
@SuppressWarnings("Duplicates")
diff --git a/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/faulttolerance/MPFaultToleranceCDIExtension.java b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/faulttolerance/MPFaultToleranceCDIExtension.java
new file mode 100644
index 0000000..e110a9c
--- /dev/null
+++ b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/faulttolerance/MPFaultToleranceCDIExtension.java
@@ -0,0 +1,89 @@
+/*
+ * 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.microprofile.faulttolerance;
+
+import io.smallrye.faulttolerance.FaultToleranceBinding;
+import jakarta.enterprise.event.Observes;
+import jakarta.enterprise.inject.spi.Annotated;
+import jakarta.enterprise.inject.spi.AnnotatedMethod;
+import jakarta.enterprise.inject.spi.BeanManager;
+import jakarta.enterprise.inject.spi.Extension;
+import jakarta.enterprise.inject.spi.ProcessAnnotatedType;
+import org.eclipse.microprofile.faulttolerance.Asynchronous;
+import org.eclipse.microprofile.faulttolerance.Bulkhead;
+import org.eclipse.microprofile.faulttolerance.CircuitBreaker;
+import org.eclipse.microprofile.faulttolerance.Fallback;
+import org.eclipse.microprofile.faulttolerance.Retry;
+import org.eclipse.microprofile.faulttolerance.Timeout;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * This class is more a hack than an actual peace of integration code for SmallRye Fault Tolerance. It addresses an issue
+ * in SmallRye because it's relying on a Weld behavior as opposed to a specified CDI feature.
+ */
+public class MPFaultToleranceCDIExtension implements Extension {
+
+ private List<Class> faultToleranceAnnotations = Arrays.asList(
+ CircuitBreaker.class,
+ Retry.class,
+ Timeout.class,
+ Asynchronous.class,
+ Fallback.class, // this one can only be on methods
+ Bulkhead.class);
+
+ /**
+ * Observer to a CDI lifecycle event to correctly add the interceptor binding to the actual bean. The SmallRye
+ * extension adds the interceptor binding to the interceptor binding.
+ *
+ * This will go threw classes annotations and add the FaultToleranceBinding on the type if it has one of the known
+ * fault tolerance annotations. In case, fault tolerance annotations are applied on some methods of a class, we
+ * also look for annotations on methods.
+ *
+ * As soon as we find at least one annotation, either on the class or one of the method, we add the interceptor
+ * binding.
+ *
+ * @param pat CDI lifecycle callback payload
+ * @param <X> Type of the Injection to observe
+ */
+ <X> void addFaultToleranceInterceptorBinding(@Observes final ProcessAnnotatedType<X> pat, final BeanManager bm) {
+
+ // check fault tolerance annotations on classes
+ if (hasFaultToleranceAnnotations(pat.getAnnotatedType())) {
+ pat.configureAnnotatedType().add(FaultToleranceBinding.Literal.INSTANCE);
+ return;
+ }
+
+ // if not on the class, it may be per method
+ for (AnnotatedMethod<? super X> m : pat.getAnnotatedType().getMethods()) {
+ if (hasFaultToleranceAnnotations(m)) {
+ pat.configureAnnotatedType().add(FaultToleranceBinding.Literal.INSTANCE);
+ return;
+ }
+ }
+ }
+
+ private boolean hasFaultToleranceAnnotations(final Annotated annotated) {
+ for (Class annotation : faultToleranceAnnotations) {
+ if (annotated.isAnnotationPresent(annotation)) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/tomee/tomee-microprofile/mp-common/src/main/resources/META-INF/services/jakarta.enterprise.inject.spi.Extension b/tomee/tomee-microprofile/mp-common/src/main/resources/META-INF/services/jakarta.enterprise.inject.spi.Extension
index aa442ca..f8e0f66 100644
--- a/tomee/tomee-microprofile/mp-common/src/main/resources/META-INF/services/jakarta.enterprise.inject.spi.Extension
+++ b/tomee/tomee-microprofile/mp-common/src/main/resources/META-INF/services/jakarta.enterprise.inject.spi.Extension
@@ -1,4 +1,6 @@
org.apache.tomee.microprofile.health.MPHealthCDIExtension
org.apache.tomee.microprofile.metrics.MPMetricsCDIExtension
org.apache.tomee.microprofile.opentracing.MPOpenTracingCDIExtension
+org.apache.tomee.microprofile.faulttolerance.MPFaultToleranceCDIExtension
+