In this PR
Add support for Vault’s PKI secret engine there was a need to create a bean that can be injected with default values, or created dynamically at runtime (even after bean discovery).
the proposed solution so far is to create the following components:
- the VaultPKISecretEngine interface
- a concrete implementation VaultPKIManager with 2 constructors
- @Inject public VaultPKIManager(VaultAuthManager,VaultInternalPKISecretEngine), which calls a non CDI constructor:
- a non CDI VaultPKIManager(String, VaultAuthManager vaultAuthManager,VaultInternalPKISecretEngine)
- a bean VaultPKIManagerFactory, which acts as a factory to create plain VaultPKIManager instances through the second constructor
technically this works. but I find this unsatisfying because depending on the use case (straight injection of VaultPKIManager, or creation through the factory), it is a full fledged CDI bean in the first case, or only an implementation of the service in the second.
this means that some of the CDI features we could use (e.g. CDI interceptors), will work inconsistently (it will in the first case, and obviously not in the second).
I do not see a better solution at this point, especially given that the list of VaultPKIManager instances cannot be created even at runtime from configuration (I will let Kevin describe how the factory gets called in his use case, and where the params come from).
and it may even be an anti-pattern in quarkus, but I was wondering if someone would find a more elegant solution for this problem?
thanks for your thoughts.