Why is it so fucking hard to do easy things easily? ;-)

Here is an example implementation for th JSONPropertySource

public class JSONPropertySourceLocator implements PropertySourceLocator {
    @Override
    public PropertySource get(URL source) {
        if (!accepts(source)) {
            String mesg = format("%s is not supported", source.toString());
            throw new ConfigException(mesg);
        }

        return new JSONPropertySource(source);
    }
}

Adding a PropertySourceProviderManager is not helpfull because it has to discover existing format (Anatoles approach) or existing PropertySource implementation. Every PropertySource must be scanned for an ctor with URL parameter and so on and so on. This is not an very flexible design..

Bye,

Oliver


Am 12.02.15 um 17:50 schrieb Romain Manni-Bucau:
@Olivier: Anatole is right, make of a custom propertysourceprovider a
manager and this one will be responsible to instantiate the right
property source depending the logic you need (extension). It is as
easy as having a map of factory in the idea.


Romain Manni-Bucau
@rmannibucau
http://www.tomitribe.com
http://rmannibucau.wordpress.com
https://github.com/rmannibucau


2015-02-12 17:46 GMT+01:00 Anatole Tresch <[email protected]>:
Its the PropertySourceProviders that can do file discovery and apply
whatever öpgic on top to determine the different priorities of the
different files fouind...

Romain Manni-Bucau <[email protected]> schrieb am Thu Feb 12 2015 at
17:43:31:


--
N Oliver B. Fischer
A Schönhauser Allee 64, 10437 Berlin, Deutschland/Germany
P +49 30 44793251
M +49 178 7903538
E [email protected]
S oliver.b.fischer
J [email protected]
X http://xing.to/obf

Reply via email to