On Monday, April 9, 2018 at 3:53:16 PM UTC-7, Alasdair Nottingham wrote:
Here is more focused scenario that I think is more realistic and will (I hope!) make my concern more clear.
Suppose I am putting together a MicroProfile application. And suppose as part of putting this application together I would like to use two third-party CDI extensions from vendors A and B that are, themselves, MicroProfile-Config aware, i.e. they use MicroProfile Config themselves to look up configuration information. So I include these extensions in my application.
Let's say that A's extension allows my application to inject a Redis client (arbitrary; making this up) and B's extension allows me to inject a Cassandra client (arbitrary; making this up). Let's further suppose that both extensions need URL information: A's needs it so that it knows where Redis is, and B's needs it so that it knows where Cassandra is.
Let's say that A packages a
Converter<URL> with a priority of
100 that knows how to turn
Strings of the form "
example.com:6379" into
URL instances.
Let's say that B packages a
Converter<URL> with a priority of
101 that knows how to turn
Strings of the form "
jdbc:cassandra://example.com:9160/system?version=3.0.0" into
URL instances.
So A's extension does config.getValue("redisUrl", URL.class) in order to produce a URL and B's extension does config.getValue("cassandraUrl", URL.class) in order to produce a URL.
What happens?
My further understanding is that the ways to fix this problem include patterns like:
- Urge vendor A and vendor B to rely on implicit conversion and wait for them to deliver new extensions that don't use their own converters.
- Write my own Converter<URL> that handles both formats and edit /META-INF/services/org.eclipse.microprofile.config.spi.Converter files as appropriate to make sure that only mine is the one that's used.
Is that correct? Are there others?
The part that is concerning to me is that I need to understand when I package these extensions together that this problem will arise, but it seems to me that I won't know that there is a problem until I try to run my application. I'm probably missing something again!
Thanks very much for bearing with me as I try to understand these scenarios.
Best,
Laird