Skip to content

Commit

Permalink
Merge pull request #12107 from mkouba/command-line-args
Browse files Browse the repository at this point in the history
Replace CommandLineArgumentsProducer with a synthetic bean
  • Loading branch information
stuartwdouglas authored Sep 15, 2020
2 parents 740ed55 + 5cdc77e commit 6d530fa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -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<AdditionalBeanBuildItem> 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();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,4 @@ public Object get() {
};
}

public BeanContainerListener initCommandLineArgs(Supplier<String[]> args) {
return new BeanContainerListener() {
@Override
public void created(BeanContainer container) {
container.instance(CommandLineArgumentsProducer.class).setCommandLineArgs(args);
}
};
}

}

This file was deleted.

0 comments on commit 6d530fa

Please sign in to comment.