diff --git a/.github/workflows/ci-actions.yml b/.github/workflows/ci-actions.yml
index f9bc89125f7..e2848c14345 100644
--- a/.github/workflows/ci-actions.yml
+++ b/.github/workflows/ci-actions.yml
@@ -35,7 +35,7 @@ jobs:
- name: Get Date
id: get-date
run: |
- echo "::set-output name=date::$(/bin/date -u "+%Y-%m")"
+ echo "date=$(/bin/date -u '+%Y-%m')" >> "$GITHUB_OUTPUT"
shell: bash
- name: Cache Maven Repository
id: cache-maven
@@ -360,7 +360,7 @@ jobs:
# Weld Examples build and test, only JDK 17
examples-tests:
- name: "Weld Examples build and test - JDK 17}"
+ name: "Weld Examples build and test - JDK 17"
runs-on: ubuntu-latest
needs: initial-build
timeout-minutes: 120
@@ -416,7 +416,7 @@ jobs:
if: failure()
with:
name: server-log-examples
- path: 'test-reports.tgz'
+ path: 'server-log.tgz'
# CDI TCK for SE environment
CDI-TCK-SE:
diff --git a/README.md b/README.md
index 7304316cf0c..a408fd9eb0b 100644
--- a/README.md
+++ b/README.md
@@ -6,16 +6,16 @@ Weld
[](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22weld-core-impl%22)
[](http://www.apache.org/licenses/LICENSE-2.0.html)
-Weld is the reference implementation of CDI: Contexts and Dependency Injection for the Java EE Platform which is the Java standard for dependency injection and contextual lifecycle management and one of the most important and popular parts of the Java EE platform.
+Weld is the reference implementation of Jakarta Contexts and Dependency Injection (CDI), the Java standard for dependency injection and contextual lifecycle management.
-Weld is integrated into many Java EE application servers such as WildFly, JBoss Enterprise Application Platform, GlassFish, Oracle WebLogic and others. Weld can also be used in a Servlet-only environment (Tomcat, Jetty) or plain Java SE environment.
+Weld can run in Jakarta EE application servers, Servlet containers (such as Tomcat and Jetty), and plain Java SE applications.
See http://weld.cdi-spec.org for more details.
Building Weld
-------------
-To build Weld simply run
+To build Weld, use Java 17 or newer and run
> $ mvn clean install
diff --git a/bom/pom.xml b/bom/pom.xml
index 08d71359e0e..ab42268b872 100644
--- a/bom/pom.xml
+++ b/bom/pom.xml
@@ -30,9 +30,8 @@
- 7.0.CR1
+ 7.0.CR23.2.8
- 1.7.0https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/
https://repository.jboss.org/nexus/content/repositories/snapshots/
diff --git a/bundles/osgi/pom.xml b/bundles/osgi/pom.xml
index 247652246db..34c4a3f12c5 100644
--- a/bundles/osgi/pom.xml
+++ b/bundles/osgi/pom.xml
@@ -371,7 +371,7 @@
scm:git:git@github.com:weld/core.gitscm:git:git@github.com:weld/core.gitscm:git:git@github.com:weld/core.git
- 6.0.0-SNAPSHOT
+ HEAD
diff --git a/docs/reference/src/main/asciidoc/configure.asciidoc b/docs/reference/src/main/asciidoc/configure.asciidoc
index e8fe45c1e61..7001e10cea6 100644
--- a/docs/reference/src/main/asciidoc/configure.asciidoc
+++ b/docs/reference/src/main/asciidoc/configure.asciidoc
@@ -294,7 +294,7 @@ The following properties can be used to restrict the set of beans Weld is going
|=======================================================================
|Configuration key |Default value |Description
|`org.jboss.weld.bootstrap.unusedBeans.excludeType` |`ALL`| A regular expression. A bean whose `Bean#getBeanClass()` matches this pattern is never removed. Two special values are considered. `ALL` (default value) means that all beans are excluded. `NONE` means no beans are excluded.
-|`org.jboss.weld.bootstrap.unusedBeans.excludeAnnotation` |`javax\\.ws\\.rs.*`| A regular expression. A bean is not removed if the corresponding `AnnotatedType`, or any member, is annotated with an annotation which matches this pattern. By default, a type annotated with any JAX-RS annotation is excluded from removal.
+|`org.jboss.weld.bootstrap.unusedBeans.excludeAnnotation` |`jakarta\\.ws\\.rs.*`| A regular expression. A bean is not removed if the corresponding `AnnotatedType`, or any member, is annotated with an annotation which matches this pattern. By default, a type annotated with any JAX-RS annotation is excluded from removal.
|=======================================================================
[[legacy-empty-beans-xml]]
@@ -530,3 +530,25 @@ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/
-----------------------------------------------------------------------------------------------------------
+
+[[async_handler_selection]]
+=== Selecting asynchronous invocation handlers
+
+CDI provides asynchronous invocation handlers for `CompletionStage`, `CompletableFuture`, and `Flow.Publisher`.
+Additional handlers are discovered through the `AsyncHandler.ReturnType` and `AsyncHandler.ParameterType` service-provider files.
+If more than one handler is registered for the same async type, including a collision with a built-in handler, deployment fails by default.
+
+Use `org.jboss.weld.invokable.asyncHandlers` to select a handler explicitly.
+Its value is a comma-separated list of `asyncType=handlerClass` mappings using binary class names (`$` for nested classes).
+For example, in `weld.properties`:
+
+[source,properties]
+----
+org.jboss.weld.invokable.asyncHandlers=java.util.concurrent.CompletionStage=com.example.MyStageHandler
+----
+
+The selected handler must be registered through its service-provider file (or be a built-in handler) and declare the configured async type.
+Other handlers for that type are ignored when selecting the handler.
+An absent provider, a mismatched async type, a malformed mapping, or repeated mappings for the same async type cause deployment to fail.
+The default value is an empty string, meaning that no explicit selections are made.
+As with other Weld configuration properties, the value may also be supplied through a system property or external configuration.
diff --git a/docs/reference/src/main/asciidoc/environments.asciidoc b/docs/reference/src/main/asciidoc/environments.asciidoc
index f7ce57a6ad2..a82dc2b8a4b 100644
--- a/docs/reference/src/main/asciidoc/environments.asciidoc
+++ b/docs/reference/src/main/asciidoc/environments.asciidoc
@@ -266,7 +266,7 @@ While this works most of the time, there are few rare cases, when it might be ne
* `org.jboss.weld.environment.tomcat.TomcatContainer`
* `org.jboss.weld.environment.jetty.JettyContainer`
* `org.jboss.weld.environment.undertow.UndertowContainer`
-* or any custom `org.jboss.weld.environment.Container` implementation
+* or any custom `org.jboss.weld.environment.servlet.Container` implementation
[[weld-se]]
diff --git a/docs/reference/src/main/asciidoc/extend.asciidoc b/docs/reference/src/main/asciidoc/extend.asciidoc
index 3066a1b88ca..d60b0cab9ea 100644
--- a/docs/reference/src/main/asciidoc/extend.asciidoc
+++ b/docs/reference/src/main/asciidoc/extend.asciidoc
@@ -277,10 +277,10 @@ AnnotatedType type = beanManager.createAnnotatedType(Som
//The extension uses an InjectionTarget to delegate instantiation, dependency injection
//and lifecycle callbacks to the CDI container
-InjectionTarget it = beanManager.createInjectionTarget(type);
+InjectionTarget it = beanManager.getInjectionTargetFactory(type).createInjectionTarget(null);
//each instance needs its own CDI CreationalContext
-CreationalContext ctx = beanManager.createCreationalContext(null);
+CreationalContext ctx = beanManager.createCreationalContext(null);
//instantiate the framework component and inject its dependencies
SomeFrameworkComponent instance = it.produce(ctx); //call the constructor
@@ -317,6 +317,9 @@ public interface BeanAttributes {
public String getName();
public Set> getStereotypes();
public boolean isAlternative();
+ public default boolean isReserve() { return false; }
+ public default boolean isEager() { return false; }
+ public default boolean isAutoClose() { return false; }
}
------------------------------------------------------------
@@ -328,7 +331,6 @@ everything the container needs to manage instances of a certain bean.
public interface Bean extends Contextual, BeanAttributes {
public Class> getBeanClass();
public Set getInjectionPoints();
- public boolean isNullable();
}
-------------------------------------------------------------------
diff --git a/docs/reference/src/main/asciidoc/injection.asciidoc b/docs/reference/src/main/asciidoc/injection.asciidoc
index 2d608e7fee0..4a0a2e50331 100644
--- a/docs/reference/src/main/asciidoc/injection.asciidoc
+++ b/docs/reference/src/main/asciidoc/injection.asciidoc
@@ -575,61 +575,36 @@ Since CDI 2.0, most annotations from `jakarta.enterprise` package have their `An
Therefore, in order to programmatically obtain (for instance) `@Any` annotation, you can simply do `Any.Literal.INSTANCE`.
====
-==== Enhanced version of `jakarta.enterprise.inject.Instance`
-
-Weld also provides `org.jboss.weld.inject.WeldInstance` - an enhanced version of `jakarta.enterprise.inject.Instance`.
-There are three additional methods.
-The first one - `getHandler()` - allows to obtain a contextual reference handler which not only holds the contextual reference but also allows to inspect the metadata of the relevant bean and to destroy the underlying contextual instance.
-Moreover, the handler implements `AutoCloseable`:
+`Instance.getHandle()` returns an `Instance.Handle`, which provides access to the contextual reference through `get()`, bean metadata through `getBean()`, and explicit destruction through `destroy()`.
+Handles also implement `AutoCloseable` and can be used in a try-with-resources statement:
[source.JAVA, java]
----------------------------------------------------------------------------------
-import org.jboss.weld.inject.WeldInstance;
+import jakarta.enterprise.inject.Instance;
class Foo {
@Inject
- WeldInstance instance;
+ Instance instance;
void doWork() {
- try (Handler barHandler = instance.getHandler()) {
- barHandler.get().doBusiness();
- // Note that Bar will be automatically destroyed at the end of the try-with-resources statement
+ try (Instance.Handle handle = instance.getHandle()) {
+ handle.get().doBusiness();
}
- Handler barHandler = instance.getHandler()
- barHandler.get().doBusiness();
- // Calls Instance.destroy()
- barHandler.destroy();
}
}
----------------------------------------------------------------------------------
-The next method - `handlers()` - returns an `Iterable` which allows to iterate over handlers for all the beans that have the required type and required qualifiers and are eligible for injection.
-This might be useful if you need more control inside the loop:
+`Instance.handles()` and `Instance.handlesStream()` provide iteration and streaming over handles for all matching beans.
+These are standard CDI APIs and do not require a dependency on the Weld API.
-[source.JAVA, java]
-----------------------------------------------------------------------------------
-@ApplicationScoped
-class OrderService {
+==== Enhanced version of `jakarta.enterprise.inject.Instance`
- @Inject
- @Any
- WeldInstance instance;
-
- void create(Order order) {
- for (Handler handler : instance.handlers()) {
- handler.get().process(order);
- if (Dependent.class.equals(handler.getBean().getScope()) {
- // Destroy only dependent processors
- handler.destroy();
- }
- }
- }
- }
-----------------------------------------------------------------------------------
+Weld provides `org.jboss.weld.inject.WeldInstance`, which extends `Instance` with selection by `java.lang.reflect.Type` and `getHandlePriorityComparator()`.
+The comparator sorts handles by descending bean priority and can be passed to `handlesStream().sorted(instance.getHandlePriorityComparator())`.
-Third method is a twist on the `select()` method, but it accepts `java.lang.reflect.Type` as parameter and optionally qualifier(s).
+Weld's additional `select()` overload accepts `java.lang.reflect.Type` as a parameter and optionally qualifier(s).
This allows for generic selection of instances which can be handy while dealing with third party beans through extensions.
However, in order to stay type-safe, this method has a limitation - it can only be invoked on `WeldInstance
@@ -298,6 +301,18 @@
pom
+
+ jakarta.validation
+ jakarta.validation-api
+ ${validation.api.version}
+
+
+
+ jakarta.ws.rs
+ jakarta.ws.rs-api
+ ${jaxrs.api.version}
+
+
org.jboss.weldweld-core-impl
diff --git a/porting-package/pom.xml b/porting-package/pom.xml
index f666c3699d6..26fecfbbb51 100644
--- a/porting-package/pom.xml
+++ b/porting-package/pom.xml
@@ -53,12 +53,6 @@
-
- org.jboss.spec.javax.servlet
- jboss-servlet-api_4.0_spec
- 2.0.0.Final
-
-
diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/bootstrap/unusedbeans/rest/JakartaRestUnusedBeanTest.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/bootstrap/unusedbeans/rest/JakartaRestUnusedBeanTest.java
new file mode 100644
index 00000000000..765d704f55c
--- /dev/null
+++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/bootstrap/unusedbeans/rest/JakartaRestUnusedBeanTest.java
@@ -0,0 +1,74 @@
+package org.jboss.weld.tests.bootstrap.unusedbeans.rest;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Map;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.inject.spi.BeanManager;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.Path;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.BeanArchive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.weld.bootstrap.api.Service;
+import org.jboss.weld.config.ConfigurationKey;
+import org.jboss.weld.configuration.spi.ExternalConfiguration;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(Arquillian.class)
+public class JakartaRestUnusedBeanTest {
+ @Deployment
+ public static Archive> deploy() {
+ // WildFly supplies its own ExternalConfiguration, so set excludeType through weld.properties.
+ // CleanupConfiguration enables integrator-only optimized cleanup for the embedded runner;
+ // WildFly already enables it in its own configuration.
+ return ShrinkWrap.create(BeanArchive.class)
+ .addClasses(JakartaRestUnusedBeanTest.class.getDeclaredClasses())
+ .addAsServiceProvider(Service.class, CleanupConfiguration.class)
+ .addAsResource(new StringAsset(ConfigurationKey.UNUSED_BEANS_EXCLUDE_TYPE.get() + "="
+ + ConfigurationKey.UnusedBeans.NONE), "weld.properties");
+ }
+
+ @Inject
+ BeanManager manager;
+
+ @Test
+ public void defaultAnnotationPatternProtectsJakartaRestBeans() {
+ assertEquals(1, manager.getBeans(RestResource.class).size());
+ assertEquals(1, manager.getBeans(RestMethod.class).size());
+ assertEquals(0, manager.getBeans(Unused.class).size());
+ }
+
+ @ApplicationScoped
+ @Path("/resource")
+ public static class RestResource {
+ }
+
+ @ApplicationScoped
+ public static class RestMethod {
+ @GET
+ public String get() {
+ return "value";
+ }
+ }
+
+ @ApplicationScoped
+ public static class Unused {
+ }
+
+ public static class CleanupConfiguration implements ExternalConfiguration {
+ public Map getConfigurationProperties() {
+ return Map.of(ConfigurationKey.ALLOW_OPTIMIZED_CLEANUP.get(), true);
+ }
+
+ public void cleanup() {
+ }
+ }
+}
diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/instance/enhanced/InstanceHandleTest.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/instance/enhanced/InstanceHandleTest.java
index 13fe4d8c803..9c8e93a51e5 100644
--- a/tests-arquillian/src/test/java/org/jboss/weld/tests/instance/enhanced/InstanceHandleTest.java
+++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/instance/enhanced/InstanceHandleTest.java
@@ -49,7 +49,7 @@ public static Archive> createTestArchive() {
return ShrinkWrap.create(BeanArchive.class, Utils.getDeploymentNameAsHash(InstanceHandleTest.class))
.addClasses(Alpha.class, Bravo.class, Client.class, FirstProcessor.class, Processor.class,
SecondProcessor.class, Juicy.class)
- .addPackage(WeldInstanceTest.class.getPackage())
+ .addPackage(InstanceHandleTest.class.getPackage())
.addClass(ActionSequence.class);
}
diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/instance/enhanced/WeldClient.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/instance/enhanced/WeldClient.java
deleted file mode 100644
index 79eb974be51..00000000000
--- a/tests-arquillian/src/test/java/org/jboss/weld/tests/instance/enhanced/WeldClient.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2016, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of 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.jboss.weld.tests.instance.enhanced;
-
-import java.math.BigDecimal;
-
-import jakarta.enterprise.context.Dependent;
-import jakarta.inject.Inject;
-
-import org.jboss.weld.inject.WeldInstance;
-
-/**
- * A version of {@link Client} that uses {@link WeldInstance} interface
- *
- * @author Matej Novotny
- */
-@Dependent
-public class WeldClient {
-
- @Inject
- WeldInstance alphaInstance;
-
- @Inject
- WeldInstance instance;
-
- @Inject
- @Juicy
- WeldInstance bigDecimalInstance;
-
- WeldInstance getAlphaInstance() {
- return alphaInstance;
- }
-
- WeldInstance getBigDecimalInstance() {
- return bigDecimalInstance;
- }
-
- WeldInstance getInstance() {
- return instance;
- }
-}
diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/instance/enhanced/WeldInstanceTest.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/instance/enhanced/WeldInstanceTest.java
deleted file mode 100644
index a18de5eef09..00000000000
--- a/tests-arquillian/src/test/java/org/jboss/weld/tests/instance/enhanced/WeldInstanceTest.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2016, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of 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.jboss.weld.tests.instance.enhanced;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Iterator;
-import java.util.List;
-
-import jakarta.enterprise.context.Dependent;
-import jakarta.enterprise.inject.spi.Bean;
-import jakarta.enterprise.inject.spi.BeanManager;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.BeanArchive;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.weld.inject.WeldInstance;
-import org.jboss.weld.inject.WeldInstance.Handler;
-import org.jboss.weld.test.util.ActionSequence;
-import org.jboss.weld.test.util.Utils;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- *
- * @author Matej Novotny
- */
-@RunWith(Arquillian.class)
-public class WeldInstanceTest {
-
- @Deployment
- public static Archive> createTestArchive() {
- return ShrinkWrap.create(BeanArchive.class, Utils.getDeploymentNameAsHash(WeldInstanceTest.class))
- .addClasses(Alpha.class, Bravo.class, FirstProcessor.class, Juicy.class, Processor.class,
- SecondProcessor.class, WeldClient.class)
- .addClass(ActionSequence.class);
- }
-
- @Test
- public void testIsResolvable(WeldClient client) {
- ActionSequence.reset();
- assertNotNull(client);
- assertTrue(client.getAlphaInstance().isResolvable());
- assertFalse(client.getBigDecimalInstance().isResolvable());
- }
-
- @Test
- public void testGetHandler(WeldClient client, BeanManager beanManager) {
- ActionSequence.reset();
- assertNotNull(client);
-
- Bean> alphaBean = beanManager.resolve(beanManager.getBeans(Alpha.class));
- WeldInstance instance = client.getAlphaInstance();
-
- Handler alpha1 = instance.getHandler();
- assertEquals(alphaBean, alpha1.getBean());
- assertEquals(Dependent.class, alpha1.getBean().getScope());
-
- String alpha2Id;
-
- // Test try-with-resource
- try (Handler alpha2 = instance.getHandler()) {
- alpha2Id = alpha2.get().getId();
- assertFalse(alpha1.get().getId().equals(alpha2Id));
- }
-
- List sequence = ActionSequence.getSequenceData();
- assertEquals(1, sequence.size());
- assertEquals(alpha2Id, sequence.get(0));
-
- alpha1.destroy();
- // Subsequent invocations are no-op
- alpha1.destroy();
-
- sequence = ActionSequence.getSequenceData();
- assertEquals(2, sequence.size());
-
- // Test normal scoped bean is also destroyed
- WeldInstance bravoInstance = client.getInstance().select(Bravo.class);
- String bravoId = bravoInstance.get().getId();
- try (Handler bravo = bravoInstance.getHandler()) {
- assertEquals(bravoId, bravo.get().getId());
- ActionSequence.reset();
- }
- sequence = ActionSequence.getSequenceData();
- assertEquals(1, sequence.size());
- assertEquals(bravoId, sequence.get(0));
- }
-
- @Test
- public void testGetAfterDestroyingContextualInstance(WeldClient client) {
- ActionSequence.reset();
- assertNotNull(client);
-
- Handler alphaHandle = client.getAlphaInstance().getHandler();
- // trigger bean creation
- alphaHandle.get();
- // trigger bean destruction
- alphaHandle.destroy();
- // verify that the destruction happened
- List sequence = ActionSequence.getSequenceData();
- assertEquals(1, sequence.size());
-
- // try to invoke Handle.get() again; this should throw an exception
- try {
- alphaHandle.get();
- Assert.fail("Invoking Handle.get() after destroying contextual instance should throw an exception.");
- } catch (IllegalStateException e) {
- // expected
- }
- }
-
- @Test
- public void testHandlers(WeldInstance instance) {
- ActionSequence.reset();
- assertTrue(instance.isAmbiguous());
- for (Handler handler : instance.handlers()) {
- handler.get().ping();
- if (handler.getBean().getScope().equals(Dependent.class)) {
- handler.destroy();
- }
- }
- assertEquals(3, ActionSequence.getSequenceSize());
- ActionSequence.assertSequenceDataContainsAll("firstPing", "secondPing", "firstDestroy");
-
- ActionSequence.reset();
- assertTrue(instance.isAmbiguous());
- for (Iterator> iterator = instance.handlers().iterator(); iterator.hasNext();) {
- try (Handler handler = iterator.next()) {
- handler.get().ping();
- }
- }
- assertEquals(4, ActionSequence.getSequenceSize());
- ActionSequence.assertSequenceDataContainsAll("firstPing", "secondPing", "firstDestroy", "secondDestroy");
- }
-}
diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/AroundConstructInterceptor.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/AroundConstructInterceptor.java
deleted file mode 100644
index e3c9ed710db..00000000000
--- a/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/AroundConstructInterceptor.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2013, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of 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.jboss.weld.tests.interceptors.context.bindings;
-
-import java.lang.annotation.Annotation;
-import java.util.Set;
-
-import jakarta.annotation.Priority;
-import jakarta.interceptor.AroundConstruct;
-import jakarta.interceptor.Interceptor;
-import jakarta.interceptor.InvocationContext;
-
-import org.jboss.weld.interceptor.WeldInvocationContext;
-
-@Priority(value = Interceptor.Priority.APPLICATION)
-@Interceptor
-@FooBinding(secret = "nonbinding")
-public class AroundConstructInterceptor {
-
- private static Set contextDataBindings;
-
- private static Set contextBindings;
-
- @SuppressWarnings("unchecked")
- @AroundConstruct
- void intercept(InvocationContext ctx) throws Exception {
- contextDataBindings = (Set) ctx.getContextData().get(WeldInvocationContext.INTERCEPTOR_BINDINGS_KEY);
- if (ctx instanceof WeldInvocationContext) {
- contextBindings = ((WeldInvocationContext) ctx).getInterceptorBindings();
- }
- ctx.proceed();
- }
-
- static void reset() {
- contextDataBindings = null;
- contextBindings = null;
- }
-
- static Set getContextDataBindings() {
- return contextDataBindings;
- }
-
- static Set getContextBindings() {
- return contextBindings;
- }
-}
\ No newline at end of file
diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/AroundInvokeInterceptor.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/AroundInvokeInterceptor.java
deleted file mode 100644
index cd4253fb1a6..00000000000
--- a/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/AroundInvokeInterceptor.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2013, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of 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.jboss.weld.tests.interceptors.context.bindings;
-
-import java.lang.annotation.Annotation;
-import java.util.Set;
-
-import jakarta.annotation.Priority;
-import jakarta.interceptor.AroundInvoke;
-import jakarta.interceptor.Interceptor;
-import jakarta.interceptor.InvocationContext;
-
-import org.jboss.weld.interceptor.WeldInvocationContext;
-
-@Priority(value = Interceptor.Priority.APPLICATION)
-@Interceptor
-@FooBinding(secret = "nonbinding")
-@BarBinding(age = 1)
-public class AroundInvokeInterceptor {
-
- private static final String KEY = "org.jboss.weld.interceptor.bindings";
-
- private static Set contextDataBindings;
-
- private static Set contextBindings;
-
- @SuppressWarnings("unchecked")
- @AroundInvoke
- Object intercept(InvocationContext ctx) throws Exception {
- contextDataBindings = (Set) ctx.getContextData().get(KEY);
- if (ctx instanceof WeldInvocationContext) {
- contextBindings = ((WeldInvocationContext) ctx).getInterceptorBindings();
- }
- return ctx.proceed();
- }
-
- static void reset() {
- contextDataBindings = null;
- contextBindings = null;
- }
-
- static Set getContextDataBindings() {
- return contextDataBindings;
- }
-
- static Set getContextBindings() {
- return contextBindings;
- }
-
-}
diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/BarBinding.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/BarBinding.java
deleted file mode 100644
index a20d5f257a0..00000000000
--- a/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/BarBinding.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2013, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of 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.jboss.weld.tests.interceptors.context.bindings;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import jakarta.interceptor.InterceptorBinding;
-
-@InterceptorBinding
-@Inherited
-@Target({ TYPE, METHOD })
-@Retention(RUNTIME)
-public @interface BarBinding {
-
- int age() default 0;
-
-}
diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/BazBinding.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/BazBinding.java
deleted file mode 100644
index 95974ef26f3..00000000000
--- a/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/BazBinding.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2013, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of 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.jboss.weld.tests.interceptors.context.bindings;
-
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import jakarta.enterprise.util.Nonbinding;
-import jakarta.interceptor.InterceptorBinding;
-
-@InterceptorBinding
-@Inherited
-@Target({ TYPE })
-@Retention(RUNTIME)
-public @interface BazBinding {
-
- @Nonbinding
- String secret() default "";
-
-}
diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/FooBinding.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/FooBinding.java
deleted file mode 100644
index bc120c42cc5..00000000000
--- a/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/FooBinding.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2013, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of 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.jboss.weld.tests.interceptors.context.bindings;
-
-import static java.lang.annotation.ElementType.CONSTRUCTOR;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import jakarta.enterprise.util.Nonbinding;
-import jakarta.interceptor.InterceptorBinding;
-
-@InterceptorBinding
-@Inherited
-@Target({ TYPE, METHOD, CONSTRUCTOR })
-@Retention(RUNTIME)
-public @interface FooBinding {
-
- @Nonbinding
- String secret() default "";
-
-}
diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/InvocationContextInterceptorBindingsTest.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/InvocationContextInterceptorBindingsTest.java
deleted file mode 100644
index c78fc2b398b..00000000000
--- a/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/InvocationContextInterceptorBindingsTest.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2013, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of 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.jboss.weld.tests.interceptors.context.bindings;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import java.lang.annotation.Annotation;
-import java.util.Set;
-
-import jakarta.enterprise.inject.Instance;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.BeanArchive;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.weld.test.util.Utils;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Tests now deprecated functionality, can be altered/removed once we no longer provide
- * {@link org.jboss.weld.interceptor.WeldInvocationContext#INTERCEPTOR_BINDINGS_KEY}
- *
- * See https://issues.redhat.com/browse/WELD-2756
- */
-@RunWith(Arquillian.class)
-public class InvocationContextInterceptorBindingsTest {
-
- @Deployment
- public static Archive> getDeployment() {
- return ShrinkWrap
- .create(BeanArchive.class, Utils.getDeploymentNameAsHash(InvocationContextInterceptorBindingsTest.class))
- .addPackage(InvocationContextInterceptorBindingsTest.class.getPackage());
- }
-
- @Test
- public void testAroundInvokeBindings(SimpleBean bean) {
- AroundInvokeInterceptor.reset();
- bean.ping();
- Set bindings = AroundInvokeInterceptor.getContextDataBindings();
- assertEquals(bindings, AroundInvokeInterceptor.getContextBindings());
- assertNotNull(bindings);
- assertEquals(3, bindings.size());
- for (Annotation annotation : bindings) {
- if (annotation.annotationType().equals(BarBinding.class)) {
- BarBinding barBinding = (BarBinding) annotation;
- assertEquals("1", "" + barBinding.age());
- } else if (annotation.annotationType().equals(FooBinding.class)) {
- FooBinding fooBinding = (FooBinding) annotation;
- assertEquals("hello", fooBinding.secret());
- } else if (annotation.annotationType().equals(BazBinding.class)) {
- BazBinding bazBinding = (BazBinding) annotation;
- assertEquals("bye", bazBinding.secret());
- } else {
- fail("Unexpected annotation type");
- }
- }
- }
-
- @Test
- public void testAroundConstructBindings(Instance instance) {
- AroundConstructInterceptor.reset();
- instance.get().ping();
- Set bindings = AroundConstructInterceptor.getContextDataBindings();
- assertEquals(bindings, AroundConstructInterceptor.getContextBindings());
- assertNotNull(bindings);
- assertEquals(2, bindings.size());
- for (Annotation annotation : bindings) {
- if (annotation.annotationType().equals(FooBinding.class)) {
- FooBinding fooBinding = (FooBinding) annotation;
- assertEquals("bla", fooBinding.secret());
- } else if (annotation.annotationType().equals(BazBinding.class)) {
- BazBinding bazBinding = (BazBinding) annotation;
- assertEquals("bye", bazBinding.secret());
- } else {
- fail("Unexpected annotation type");
- }
- }
- }
-
- @Test
- public void testPostConstructBindings(Instance instance) {
- PostConstructInterceptor.reset();
- instance.get().ping();
- Set bindings = PostConstructInterceptor.getContextDataBindings();
- assertEquals(bindings, PostConstructInterceptor.getContextBindings());
- assertNotNull(bindings);
- assertEquals(2, bindings.size());
- for (Annotation annotation : bindings) {
- if (annotation.annotationType().equals(FooBinding.class)) {
- FooBinding fooBinding = (FooBinding) annotation;
- assertEquals("hello", fooBinding.secret());
- } else if (annotation.annotationType().equals(BazBinding.class)) {
- BazBinding bazBinding = (BazBinding) annotation;
- assertEquals("bye", bazBinding.secret());
- } else {
- fail("Unexpected annotation type");
- }
- }
- }
-
- @Test
- public void testPreDestroyBindings(Instance instance) {
- PreDestroyInterceptor.reset();
- instance.get().ping();
- Set bindings = PreDestroyInterceptor.getContextDataBindings();
- assertEquals(bindings, PreDestroyInterceptor.getContextBindings());
- assertNotNull(bindings);
- assertEquals(2, bindings.size());
- for (Annotation annotation : bindings) {
- if (annotation.annotationType().equals(FooBinding.class)) {
- FooBinding fooBinding = (FooBinding) annotation;
- assertEquals("hello", fooBinding.secret());
- } else if (annotation.annotationType().equals(BazBinding.class)) {
- BazBinding bazBinding = (BazBinding) annotation;
- assertEquals("bye", bazBinding.secret());
- } else {
- fail("Unexpected annotation type");
- }
- }
- }
-}
diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/PostConstructInterceptor.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/PostConstructInterceptor.java
deleted file mode 100644
index f6e95265291..00000000000
--- a/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/PostConstructInterceptor.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2013, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of 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.jboss.weld.tests.interceptors.context.bindings;
-
-import java.lang.annotation.Annotation;
-import java.util.Set;
-
-import jakarta.annotation.PostConstruct;
-import jakarta.annotation.Priority;
-import jakarta.interceptor.Interceptor;
-import jakarta.interceptor.InvocationContext;
-
-import org.jboss.weld.interceptor.WeldInvocationContext;
-
-@Priority(value = Interceptor.Priority.APPLICATION)
-@Interceptor
-@BazBinding(secret = "nonbinding")
-public class PostConstructInterceptor {
-
- private static Set contextDataBindings;
-
- private static Set contextBindings;
-
- @SuppressWarnings("unchecked")
- @PostConstruct
- void intercept(InvocationContext ctx) throws Exception {
- contextDataBindings = (Set) ctx.getContextData().get(WeldInvocationContext.INTERCEPTOR_BINDINGS_KEY);
- if (ctx instanceof WeldInvocationContext) {
- contextBindings = ((WeldInvocationContext) ctx).getInterceptorBindings();
- }
- ctx.proceed();
- }
-
- static void reset() {
- contextDataBindings = null;
- contextBindings = null;
- }
-
- static Set getContextDataBindings() {
- return contextDataBindings;
- }
-
- static Set getContextBindings() {
- return contextBindings;
- }
-}
diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/PreDestroyInterceptor.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/PreDestroyInterceptor.java
deleted file mode 100644
index 4dd4c171a48..00000000000
--- a/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/PreDestroyInterceptor.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2013, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of 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.jboss.weld.tests.interceptors.context.bindings;
-
-import java.lang.annotation.Annotation;
-import java.util.Set;
-
-import jakarta.annotation.PostConstruct;
-import jakarta.annotation.Priority;
-import jakarta.interceptor.Interceptor;
-import jakarta.interceptor.InvocationContext;
-
-import org.jboss.weld.interceptor.WeldInvocationContext;
-
-@Priority(value = Interceptor.Priority.APPLICATION)
-@Interceptor
-@BazBinding(secret = "nonbinding")
-public class PreDestroyInterceptor {
-
- private static Set contextDataBindings;
-
- private static Set contextBindings;
-
- @SuppressWarnings("unchecked")
- @PostConstruct
- void intercept(InvocationContext ctx) throws Exception {
- contextDataBindings = (Set) ctx.getContextData().get(WeldInvocationContext.INTERCEPTOR_BINDINGS_KEY);
- if (ctx instanceof WeldInvocationContext) {
- contextBindings = ((WeldInvocationContext) ctx).getInterceptorBindings();
- }
- ctx.proceed();
- }
-
- static void reset() {
- contextDataBindings = null;
- contextBindings = null;
- }
-
- static Set getContextDataBindings() {
- return contextDataBindings;
- }
-
- static Set getContextBindings() {
- return contextBindings;
- }
-}
diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/SimpleBean.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/SimpleBean.java
deleted file mode 100644
index f1f6506278a..00000000000
--- a/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/context/bindings/SimpleBean.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2013, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of 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.jboss.weld.tests.interceptors.context.bindings;
-
-import jakarta.enterprise.context.Dependent;
-import jakarta.inject.Inject;
-
-@BazBinding(secret = "bye")
-@FooBinding(secret = "hello")
-@Dependent
-public class SimpleBean {
-
- @FooBinding(secret = "bla")
- @Inject
- public SimpleBean() {
- }
-
- @BarBinding(age = 1)
- void ping() {
- }
-}
diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/async/matching/AsyncHandlerMatchingTest.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/async/matching/AsyncHandlerMatchingTest.java
new file mode 100644
index 00000000000..5771dd9bcef
--- /dev/null
+++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/async/matching/AsyncHandlerMatchingTest.java
@@ -0,0 +1,148 @@
+package org.jboss.weld.tests.invokable.async.matching;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionStage;
+
+import jakarta.annotation.PreDestroy;
+import jakarta.enterprise.context.Dependent;
+import jakarta.enterprise.event.Observes;
+import jakarta.enterprise.inject.spi.Extension;
+import jakarta.enterprise.invoke.AsyncHandler;
+import jakarta.enterprise.invoke.Invoker;
+import jakarta.inject.Inject;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.BeanArchive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.weld.bootstrap.event.WeldProcessManagedBean;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(Arquillian.class)
+public class AsyncHandlerMatchingTest {
+ @Deployment
+ public static Archive> deploy() {
+ return ShrinkWrap.create(BeanArchive.class)
+ .addClasses(AsyncHandlerMatchingTest.class.getDeclaredClasses())
+ .addAsServiceProvider(Extension.class, Invokers.class)
+ .addAsServiceProvider(AsyncHandler.ParameterType.class, AHandler.class, BHandler.class);
+ }
+
+ @Inject
+ Invokers invokers;
+
+ @Test
+ public void returnAndParameterHandlersAreAmbiguous() throws Exception {
+ Target.destroyed = 0;
+ A a = new A();
+ invokers.get("returnAndParameter").invoke(null, new Object[] { a });
+ assertEquals(1, Target.destroyed);
+ assertEquals(null, a.completion);
+ Target.stage.complete("done");
+ assertEquals(1, Target.destroyed);
+ }
+
+ @Test
+ public void repeatedTypeDoesNotDisqualifyAnotherHandler() throws Exception {
+ Target.destroyed = 0;
+ A a = new A();
+ B b = new B();
+ invokers.get("repeatedAndUnique").invoke(null, new Object[] { a, a, b });
+ assertEquals(0, Target.destroyed);
+ assertEquals(null, a.completion);
+ b.completion.run();
+ assertEquals(1, Target.destroyed);
+ }
+
+ @Test
+ public void distinctParameterHandlersAreAmbiguous() throws Exception {
+ Target.destroyed = 0;
+ A a = new A();
+ B b = new B();
+ invokers.get("distinct").invoke(null, new Object[] { a, b });
+ assertEquals(1, Target.destroyed);
+ assertEquals(null, a.completion);
+ assertEquals(null, b.completion);
+ }
+
+ @Test
+ public void repeatedParametersLeaveReturnHandlerUnambiguous() throws Exception {
+ Target.destroyed = 0;
+ A a = new A();
+ invokers.get("returnAndRepeated").invoke(null, new Object[] { a, a });
+ assertEquals(0, Target.destroyed);
+ assertEquals(null, a.completion);
+ Target.stage.complete("done");
+ assertEquals(1, Target.destroyed);
+ }
+
+ public static class A {
+ Runnable completion;
+ }
+
+ public static class B {
+ Runnable completion;
+ }
+
+ public static class AHandler implements AsyncHandler.ParameterType {
+ public A transformArgument(A original, Runnable completion) {
+ original.completion = completion;
+ return original;
+ }
+ }
+
+ public static class BHandler implements AsyncHandler.ParameterType {
+ public B transformArgument(B original, Runnable completion) {
+ original.completion = completion;
+ return original;
+ }
+ }
+
+ @Dependent
+ public static class Target {
+ static int destroyed;
+ static CompletableFuture stage;
+
+ public CompletionStage returnAndParameter(A a) {
+ stage = new CompletableFuture<>();
+ return stage;
+ }
+
+ public void repeatedAndUnique(A a, A another, B b) {
+ }
+
+ public void distinct(A a, B b) {
+ }
+
+ public CompletionStage returnAndRepeated(A a, A another) {
+ stage = new CompletableFuture<>();
+ return stage;
+ }
+
+ @PreDestroy
+ void destroy() {
+ destroyed++;
+ }
+ }
+
+ public static class Invokers implements Extension {
+ final Map> methods = new HashMap<>();
+
+ public Invoker get(String name) {
+ return methods.get(name);
+ }
+
+ void register(@Observes WeldProcessManagedBean event) {
+ event.getAnnotatedBeanClass().getMethods().stream()
+ .filter(method -> !method.getJavaMember().getName().equals("destroy"))
+ .forEach(method -> methods.put(method.getJavaMember().getName(),
+ event.createInvoker(method).withInstanceLookup().build()));
+ }
+ }
+}
diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/async/selection/BuiltinHandlerCollisionTest.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/async/selection/BuiltinHandlerCollisionTest.java
new file mode 100644
index 00000000000..d7490bbe15f
--- /dev/null
+++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/async/selection/BuiltinHandlerCollisionTest.java
@@ -0,0 +1,36 @@
+package org.jboss.weld.tests.invokable.async.selection;
+
+import java.util.concurrent.CompletionStage;
+
+import jakarta.enterprise.inject.spi.DeploymentException;
+import jakarta.enterprise.invoke.AsyncHandler;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.ShouldThrowException;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.BeanArchive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(Arquillian.class)
+public class BuiltinHandlerCollisionTest {
+ @Deployment
+ @ShouldThrowException(DeploymentException.class)
+ public static Archive> deploy() {
+ return ShrinkWrap.create(BeanArchive.class)
+ .addClass(CustomStageHandler.class)
+ .addAsServiceProvider(AsyncHandler.ReturnType.class, CustomStageHandler.class);
+ }
+
+ @Test
+ public void duplicateBuiltinRequiresSelection() {
+ }
+
+ public static class CustomStageHandler implements AsyncHandler.ReturnType> {
+ public CompletionStage> transform(CompletionStage> original, Runnable completion) {
+ return original.whenComplete((value, failure) -> completion.run());
+ }
+ }
+}
diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/async/selection/ConfiguredAsyncHandlerTest.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/async/selection/ConfiguredAsyncHandlerTest.java
new file mode 100644
index 00000000000..b901307a1f2
--- /dev/null
+++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/async/selection/ConfiguredAsyncHandlerTest.java
@@ -0,0 +1,71 @@
+package org.jboss.weld.tests.invokable.async.selection;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionStage;
+
+import jakarta.enterprise.context.Dependent;
+import jakarta.enterprise.event.Observes;
+import jakarta.enterprise.inject.spi.Extension;
+import jakarta.enterprise.invoke.AsyncHandler;
+import jakarta.enterprise.invoke.Invoker;
+import jakarta.inject.Inject;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.BeanArchive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.weld.bootstrap.event.WeldProcessManagedBean;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(Arquillian.class)
+public class ConfiguredAsyncHandlerTest {
+ @Deployment
+ public static Archive> deploy() {
+ return ShrinkWrap.create(BeanArchive.class)
+ .addClasses(ConfiguredAsyncHandlerTest.class.getDeclaredClasses())
+ .addAsServiceProvider(Extension.class, Invokers.class)
+ .addAsServiceProvider(AsyncHandler.ReturnType.class, CustomStageHandler.class)
+ .addAsResource(new StringAsset("org.jboss.weld.invokable.asyncHandlers="
+ + CompletionStage.class.getName() + "=" + CustomStageHandler.class.getName()), "weld.properties");
+ }
+
+ @Inject
+ Invokers invokers;
+
+ @Test
+ public void configuredProviderTransformsInvocationResult() throws Exception {
+ assertEquals("custom:value", ((CompletionStage>) invokers.get().invoke(null, new Object[0]))
+ .toCompletableFuture().join());
+ }
+
+ @Dependent
+ public static class Target {
+ public CompletionStage execute() {
+ return CompletableFuture.completedFuture("value");
+ }
+ }
+
+ public static class CustomStageHandler implements AsyncHandler.ReturnType> {
+ public CompletionStage> transform(CompletionStage> original, Runnable completion) {
+ return original.whenComplete((value, failure) -> completion.run()).thenApply(value -> "custom:" + value);
+ }
+ }
+
+ public static class Invokers implements Extension {
+ private Invoker invoker;
+
+ public Invoker get() {
+ return invoker;
+ }
+
+ void register(@Observes WeldProcessManagedBean event) {
+ event.getAnnotatedBeanClass().getMethods().forEach(method -> invoker = event.createInvoker(method)
+ .withInstanceLookup().build());
+ }
+ }
+}
diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/async/wrapper/AsyncInvocationWrapperTest.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/async/wrapper/AsyncInvocationWrapperTest.java
new file mode 100644
index 00000000000..09cc873df13
--- /dev/null
+++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/invokable/async/wrapper/AsyncInvocationWrapperTest.java
@@ -0,0 +1,187 @@
+package org.jboss.weld.tests.invokable.async.wrapper;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import jakarta.annotation.PreDestroy;
+import jakarta.enterprise.context.Dependent;
+import jakarta.enterprise.event.Observes;
+import jakarta.enterprise.inject.spi.Extension;
+import jakarta.enterprise.invoke.AsyncHandler;
+import jakarta.enterprise.invoke.Invoker;
+import jakarta.inject.Inject;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.BeanArchive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.weld.bootstrap.event.WeldProcessManagedBean;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(Arquillian.class)
+public class AsyncInvocationWrapperTest {
+ @Deployment
+ public static Archive> deploy() {
+ return ShrinkWrap.create(BeanArchive.class)
+ .addClasses(AsyncInvocationWrapperTest.class.getDeclaredClasses())
+ .addAsServiceProvider(Extension.class, Invokers.class)
+ .addAsServiceProvider(AsyncHandler.ParameterType.class, Handler.class)
+ .addAsServiceProvider(AsyncHandler.ReturnType.class, ReturnHandler.class);
+ }
+
+ @Inject
+ Invokers invokers;
+
+ @Test
+ public void wrappedLookupWaitsForCompletion() throws Exception {
+ Target.destroyed = 0;
+ Param param = new Param();
+ assertEquals("wrapped:handled:ok", invokers.get("execute").invoke(null, new Object[] { param }));
+ assertEquals(0, Target.destroyed);
+ param.completions.get(0).run();
+ assertEquals(1, Target.destroyed);
+ }
+
+ @Test
+ public void wrapperWorksWithoutLookup() throws Exception {
+ Target.destroyed = 0;
+ Param param = new Param();
+ assertEquals("wrapped:handled:ok", invokers.get("direct").invoke(new Target(), new Object[] { param }));
+ param.completions.get(0).run();
+ assertEquals(0, Target.destroyed);
+ }
+
+ @Test
+ public void synchronousFailureCleansUpOnlyOnce() {
+ Target.destroyed = 0;
+ Param param = new Param();
+ assertThrows(IllegalArgumentException.class, () -> invokers.get("fail").invoke(null, new Object[] { param }));
+ assertEquals(1, Target.destroyed);
+ param.completions.get(0).run();
+ assertEquals(1, Target.destroyed);
+ }
+
+ @Test
+ public void repeatedDelegationHasIndependentCleanup() throws Exception {
+ Target.destroyed = 0;
+ Param param = new Param();
+ assertEquals("handled:ok", invokers.get("twice").invoke(null, new Object[] { param }));
+ assertEquals(2, param.completions.size());
+ assertEquals(0, Target.destroyed);
+ param.completions.get(0).run();
+ assertEquals(1, Target.destroyed);
+ param.completions.get(1).run();
+ assertEquals(2, Target.destroyed);
+ }
+
+ @Test
+ public void returnHandlerTransformsBeforeWrapperWithoutLookup() throws Exception {
+ Target.destroyed = 0;
+ assertEquals("wrapped:handled:ok", invokers.get("returnDirect").invoke(new Target(), new Object[0]));
+ assertEquals(0, Target.destroyed);
+ }
+
+ public static class Param {
+ final List completions = new ArrayList<>();
+ }
+
+ public static class Handler implements AsyncHandler.ParameterType {
+ public Param transformArgument(Param original, Runnable completion) {
+ original.completions.add(completion);
+ return original;
+ }
+
+ @Override
+ public Object transformReturnValue(Object original, Runnable completion) {
+ return "handled:" + original;
+ }
+ }
+
+ public static class ReturnValue {
+ final String value;
+
+ ReturnValue(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return value;
+ }
+ }
+
+ public static class ReturnHandler implements AsyncHandler.ReturnType {
+ @Override
+ public ReturnValue transform(ReturnValue original, Runnable completion) {
+ completion.run();
+ return new ReturnValue("handled:" + original.value);
+ }
+ }
+
+ public static class Wrapper {
+ public static Object once(Target instance, Object[] args, Invoker invoker) throws Exception {
+ return "wrapped:" + invoker.invoke(instance, args);
+ }
+
+ public static Object twice(Target instance, Object[] args, Invoker invoker) throws Exception {
+ invoker.invoke(instance, args);
+ return invoker.invoke(instance, args);
+ }
+ }
+
+ @Dependent
+ public static class Target {
+ static int destroyed;
+
+ public String execute(Param param) {
+ return "ok";
+ }
+
+ public String fail(Param param) {
+ throw new IllegalArgumentException("expected");
+ }
+
+ public ReturnValue returnValue() {
+ return new ReturnValue("ok");
+ }
+
+ @PreDestroy
+ void destroy() {
+ destroyed++;
+ }
+ }
+
+ public static class Invokers implements Extension {
+ final Map> methods = new HashMap<>();
+
+ public Invoker get(String name) {
+ return methods.get(name);
+ }
+
+ void register(@Observes WeldProcessManagedBean event) {
+ event.getAnnotatedBeanClass().getMethods().forEach(method -> {
+ String name = method.getJavaMember().getName();
+ if (name.equals("destroy")) {
+ return;
+ }
+ methods.put(name, event.createInvoker(method).withInstanceLookup()
+ .withInvocationWrapper(Wrapper.class, "once").build());
+ if (name.equals("execute")) {
+ methods.put("direct", event.createInvoker(method).withInvocationWrapper(Wrapper.class, "once").build());
+ methods.put("twice", event.createInvoker(method).withInstanceLookup()
+ .withInvocationWrapper(Wrapper.class, "twice").build());
+ } else if (name.equals("returnValue")) {
+ methods.put("returnDirect", event.createInvoker(method)
+ .withInvocationWrapper(Wrapper.class, "once").build());
+ }
+ });
+ }
+ }
+}
diff --git a/weld-lite-extension-translator/src/main/java/org/jboss/weld/lite/extension/translator/LiteExtensionTranslator.java b/weld-lite-extension-translator/src/main/java/org/jboss/weld/lite/extension/translator/LiteExtensionTranslator.java
index 841866f454d..627dc84d24d 100644
--- a/weld-lite-extension-translator/src/main/java/org/jboss/weld/lite/extension/translator/LiteExtensionTranslator.java
+++ b/weld-lite-extension-translator/src/main/java/org/jboss/weld/lite/extension/translator/LiteExtensionTranslator.java
@@ -51,15 +51,6 @@ public LiteExtensionTranslator() {
this(BuildCompatibleExtensionLoader.getBuildCompatibleExtensions(), Thread.currentThread().getContextClassLoader());
}
- /**
- * Deprecated, use {@link LiteExtensionTranslator#LiteExtensionTranslator(Collection, ClassLoader)}.
- * This method will be removed in future versions.
- */
- @Deprecated(forRemoval = true)
- public LiteExtensionTranslator(List> buildCompatibleExtensions, ClassLoader cl) {
- this((Collection>) buildCompatibleExtensions, cl);
- }
-
public LiteExtensionTranslator(Collection> buildCompatibleExtensions,
ClassLoader cl) {
this.util = new ExtensionInvoker(buildCompatibleExtensions);