diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/CommandLineArgumentsProcessor.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/CommandLineArgumentsProcessor.java index 25369b165810a..51ff75c510d90 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/CommandLineArgumentsProcessor.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/CommandLineArgumentsProcessor.java @@ -1,26 +1,27 @@ package io.quarkus.arc.deployment; -import io.quarkus.arc.runtime.ArcRecorder; -import io.quarkus.arc.runtime.CommandLineArgumentsProducer; +import org.jboss.jandex.DotName; +import org.jboss.jandex.Type; +import org.jboss.jandex.Type.Kind; + +import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; -import io.quarkus.deployment.annotations.ExecutionTime; -import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.RawCommandLineArgumentsBuildItem; import io.quarkus.runtime.annotations.CommandLineArguments; public class CommandLineArgumentsProcessor { @BuildStep - @Record(ExecutionTime.STATIC_INIT) - BeanContainerListenerBuildItem commandLineArgs(RawCommandLineArgumentsBuildItem rawCommandLineArgumentsBuildItem, - ArcRecorder arcRecorder) { - //todo: this should be filtered - return new BeanContainerListenerBuildItem(arcRecorder.initCommandLineArgs(rawCommandLineArgumentsBuildItem)); - } + SyntheticBeanBuildItem commandLineArgs(RawCommandLineArgumentsBuildItem rawCommandLineArgumentsBuildItem, + BuildProducer additionalBeans) { + additionalBeans.produce(new AdditionalBeanBuildItem(CommandLineArguments.class)); - @BuildStep - AdditionalBeanBuildItem qualifier() { - return AdditionalBeanBuildItem.builder().setUnremovable() - .addBeanClasses(CommandLineArguments.class, CommandLineArgumentsProducer.class).build(); + Type stringArray = Type.create(DotName.createSimple(String[].class.getName()), Kind.ARRAY); + // implClazz is ignored because a provider type is set + return SyntheticBeanBuildItem.configure(Object.class).providerType(stringArray).addType(stringArray) + .addQualifier(CommandLineArguments.class) + .setRuntimeInit().supplier(rawCommandLineArgumentsBuildItem) + .unremovable().done(); } + } diff --git a/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/ArcRecorder.java b/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/ArcRecorder.java index dca4146fd82ec..44f589fefbb49 100644 --- a/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/ArcRecorder.java +++ b/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/ArcRecorder.java @@ -75,13 +75,4 @@ public Object get() { }; } - public BeanContainerListener initCommandLineArgs(Supplier args) { - return new BeanContainerListener() { - @Override - public void created(BeanContainer container) { - container.instance(CommandLineArgumentsProducer.class).setCommandLineArgs(args); - } - }; - } - } diff --git a/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/CommandLineArgumentsProducer.java b/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/CommandLineArgumentsProducer.java deleted file mode 100644 index 026285d4e8eac..0000000000000 --- a/extensions/arc/runtime/src/main/java/io/quarkus/arc/runtime/CommandLineArgumentsProducer.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.quarkus.arc.runtime; - -import java.util.function.Supplier; - -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; - -import io.quarkus.runtime.annotations.CommandLineArguments; - -@ApplicationScoped -public class CommandLineArgumentsProducer { - - private volatile Supplier commandLineArgs; - - @Produces - @CommandLineArguments - public String[] getCommandLineArgs() { - return commandLineArgs.get(); - } - - public void setCommandLineArgs(Supplier commandLineArgs) { - this.commandLineArgs = commandLineArgs; - } -}