diff --git a/transactional-event-quarkus-deployment/src/main/java/com/github/jonasrutishauser/transactional/event/quarkus/deployment/TransactionalEventExtensionProcessor.java b/transactional-event-quarkus-deployment/src/main/java/com/github/jonasrutishauser/transactional/event/quarkus/deployment/TransactionalEventExtensionProcessor.java index d53f6cc79..94ac5dbe2 100644 --- a/transactional-event-quarkus-deployment/src/main/java/com/github/jonasrutishauser/transactional/event/quarkus/deployment/TransactionalEventExtensionProcessor.java +++ b/transactional-event-quarkus-deployment/src/main/java/com/github/jonasrutishauser/transactional/event/quarkus/deployment/TransactionalEventExtensionProcessor.java @@ -7,12 +7,8 @@ import java.util.List; import java.util.Optional; -import org.jboss.jandex.ClassInfo; -import org.jboss.jandex.Index; - import com.github.jonasrutishauser.transactional.event.api.Configuration; import com.github.jonasrutishauser.transactional.event.api.MPConfiguration; -import com.github.jonasrutishauser.transactional.event.api.handler.EventHandler; import com.github.jonasrutishauser.transactional.event.core.concurrent.DefaultEventExecutor; import com.github.jonasrutishauser.transactional.event.core.defaults.DefaultConcurrencyProvider; import com.github.jonasrutishauser.transactional.event.core.serialization.JaxbSerialization; @@ -36,7 +32,6 @@ import io.quarkus.deployment.annotations.Consume; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ApplicationIndexBuildItem; import io.quarkus.deployment.builditem.FeatureBuildItem; import io.quarkus.deployment.builditem.ServiceStartBuildItem; import io.quarkus.deployment.metrics.MetricsCapabilityBuildItem; @@ -81,28 +76,6 @@ void excludeFromBeansXml(Capabilities capabilities, Optional beanInfo.isClassBean() && hasEventHandlerMethod(beanInfo.getImplClazz(), index.getIndex())); - } - - private boolean hasEventHandlerMethod(ClassInfo implClazz, Index index) { - if (implClazz.methods().stream() // - .filter(m -> !m.isBridge()) // - .filter(m -> !m.isSynthetic()) // - .filter(m -> !m.isConstructor()) // - .filter(m -> !m.isStaticInitializer()) // - .anyMatch(m -> m.hasAnnotation(EventHandler.class))) { - return true; - } - if (implClazz.superClassType() == null) { - return false; - } - ClassInfo superClass = index.getClassByName(implClazz.superClassType().name()); - return superClass != null && hasEventHandlerMethod(implClazz, index); - } - @BuildStep(onlyIfNot = IsNormal.class) UnremovableBeanBuildItem ensureDbSchemaIsNotRemoved() { return UnremovableBeanBuildItem.beanTypes(DbSchema.class); diff --git a/transactional-event-quarkus-deployment/src/test/java/com/github/jonasrutishauser/transactional/event/quarkus/deployment/it/TestEventHandler.java b/transactional-event-quarkus-deployment/src/test/java/com/github/jonasrutishauser/transactional/event/quarkus/deployment/it/TestEventHandler.java index 222d51b33..19f723cd3 100644 --- a/transactional-event-quarkus-deployment/src/test/java/com/github/jonasrutishauser/transactional/event/quarkus/deployment/it/TestEventHandler.java +++ b/transactional-event-quarkus-deployment/src/test/java/com/github/jonasrutishauser/transactional/event/quarkus/deployment/it/TestEventHandler.java @@ -13,9 +13,13 @@ @Typed(Handler.class) public class TestEventHandler extends AbstractHandler { - @Inject private Messages messages; + @Inject + TestEventHandler(Messages messages) { + this.messages = messages; + } + @Override protected void handle(TestEvent event) { if (event.getMessage().contains("failure") && messages.addFailure(event.getMessage())) { diff --git a/transactional-event-quarkus-deployment/src/test/java/com/github/jonasrutishauser/transactional/event/quarkus/deployment/it/TestHandlerMethod.java b/transactional-event-quarkus-deployment/src/test/java/com/github/jonasrutishauser/transactional/event/quarkus/deployment/it/TestHandlerMethod.java new file mode 100644 index 000000000..e210747d9 --- /dev/null +++ b/transactional-event-quarkus-deployment/src/test/java/com/github/jonasrutishauser/transactional/event/quarkus/deployment/it/TestHandlerMethod.java @@ -0,0 +1,23 @@ +package com.github.jonasrutishauser.transactional.event.quarkus.deployment.it; + +import com.github.jonasrutishauser.transactional.event.api.handler.EventHandler; + +import jakarta.enterprise.context.Dependent; +import jakarta.inject.Inject; + +@Dependent +public class TestHandlerMethod { + + private final Messages messages; + + @Inject + TestHandlerMethod(Messages messages) { + this.messages = messages; + } + + @EventHandler + void handle(String event) { + messages.add(event); + } + +} diff --git a/transactional-event-quarkus-deployment/src/test/java/com/github/jonasrutishauser/transactional/event/quarkus/deployment/it/TestPublisher.java b/transactional-event-quarkus-deployment/src/test/java/com/github/jonasrutishauser/transactional/event/quarkus/deployment/it/TestPublisher.java index 24409af14..b10205e63 100644 --- a/transactional-event-quarkus-deployment/src/test/java/com/github/jonasrutishauser/transactional/event/quarkus/deployment/it/TestPublisher.java +++ b/transactional-event-quarkus-deployment/src/test/java/com/github/jonasrutishauser/transactional/event/quarkus/deployment/it/TestPublisher.java @@ -3,7 +3,6 @@ import java.util.Collection; import com.github.jonasrutishauser.transactional.event.api.EventPublisher; -import com.github.jonasrutishauser.transactional.event.api.handler.EventHandler; import jakarta.enterprise.context.Dependent; import jakarta.enterprise.context.control.ActivateRequestContext; @@ -13,11 +12,15 @@ @Dependent public class TestPublisher { - @Inject - private EventPublisher publisher; + private final EventPublisher publisher; + + private final Messages messages; @Inject - private Messages messages; + TestPublisher(EventPublisher publisher, Messages messages) { + this.publisher = publisher; + this.messages = messages; + } @Transactional @ActivateRequestContext @@ -35,9 +38,4 @@ public Collection getMessages() { return messages.get(); } - @EventHandler - void handle(String event) { - messages.add(event); - } - } diff --git a/transactional-event-quarkus-deployment/src/test/java/com/github/jonasrutishauser/transactional/event/quarkus/deployment/it/TransactionalEventIT.java b/transactional-event-quarkus-deployment/src/test/java/com/github/jonasrutishauser/transactional/event/quarkus/deployment/it/TransactionalEventIT.java index 3382af69f..044ebab9d 100644 --- a/transactional-event-quarkus-deployment/src/test/java/com/github/jonasrutishauser/transactional/event/quarkus/deployment/it/TransactionalEventIT.java +++ b/transactional-event-quarkus-deployment/src/test/java/com/github/jonasrutishauser/transactional/event/quarkus/deployment/it/TransactionalEventIT.java @@ -18,7 +18,8 @@ class TransactionalEventIT { static final QuarkusUnitTest config = new QuarkusUnitTest() // .setFlatClassPath(true) // needed for invoker .withApplicationRoot(archive -> archive // - .addClasses(Messages.class, TestEvent.class, TestEventHandler.class, TestPublisher.class) // + .addClasses(Messages.class, TestEvent.class, TestEventHandler.class, TestPublisher.class, + TestHandlerMethod.class) // .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") // ).overrideRuntimeConfigKey("quarkus.transactional.event.initial-dispatch-interval", "1"); diff --git a/transactional-event-quarkus/src/main/java/com/github/jonasrutishauser/transactional/event/quarkus/concurrent/QuarkusEventExecutor.java b/transactional-event-quarkus/src/main/java/com/github/jonasrutishauser/transactional/event/quarkus/concurrent/QuarkusEventExecutor.java index 95563021f..6c05a8635 100644 --- a/transactional-event-quarkus/src/main/java/com/github/jonasrutishauser/transactional/event/quarkus/concurrent/QuarkusEventExecutor.java +++ b/transactional-event-quarkus/src/main/java/com/github/jonasrutishauser/transactional/event/quarkus/concurrent/QuarkusEventExecutor.java @@ -24,6 +24,10 @@ class QuarkusEventExecutor implements EventExecutor { private final ExecutorService executor; private final ScheduledExecutorService scheduler; + QuarkusEventExecutor() { + this(null, null); + } + @Inject QuarkusEventExecutor(@Events ExecutorService executor, ScheduledExecutorService scheduler) { this.executor = executor;