I'm writing a Quarkus Extension (on Quarkus 2.16) whose purpose is to set some fields of a MyClient object based on values inserted in the application.properties.
我正在编写一个Quarkus扩展(在Quarkus 2.16上),其目的是根据application.properties中插入的值设置MyClient对象的某些字段。
I would like this extension to be able to manage N instances of MyClient by reading properties whose key must follow a syntax like:
我希望此扩展能够通过读取其键必须遵循如下语法的属性来管理MyClient的N个实例:
quarkus.myextension.myclient.CLIENTNAME-1.name=Bob
Quarkus.myextension.myclient.CLIENTNAME-1.name=Bob
quarkus.myextension.myclient.CLIENTNAME-2.name=John
Quarkus.myextension.myclient.CLIENTNAME-2.name=John
...
..。
quarkus.myextension.myclient.CLIENTNAME-N.name=Paul
Quarkus.myextension.myclient.CLIENTNAME-N.name=Paul
Where CLIENTNAME is a value chosen at will by the user of the extension.
其中,客户端名称是扩展的用户随意选择的值。
Is there any way to achieve this result? I've seen similar behavior in many extensions (e.g. RestClient) but haven't figured out how to reproduce it
有没有办法实现这一结果?我在许多扩展(例如RestClient)中看到了类似的行为,但还没有想出如何重现它
Thanks a lot.
非常感谢.
更多回答
So you are looking for a config object that will give you this behavior?
因此,您正在寻找一个可以提供此行为的配置对象?
Thanks for the replies. I had already read WriteYourOwnExtension, but what is not clear to me is how to use the class annotated with @ConfigMap: I see that a Processor class is defined but I don't understand whether it should be inserted in Runtime or Deployment, nor how this class should be used so that I can recover the properties
谢谢你的回复。我已经阅读了WriteYourOwnExtension,但我不清楚的是如何使用用@ConfigMap注释的类:我看到定义了一个处理器类,但我不知道它是应该插入到运行时还是部署中,也不知道应该如何使用这个类以便恢复属性
我是一名优秀的程序员,十分优秀!