Ho Oliver

O do noz get your point, see inline...

2015-02-12 17:56 GMT+01:00 Oliver B. Fischer <[email protected]>:

> 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);
>     }
> }
>
> ​1) who is providing the URLs ?
2) Checking for an URL, if it is accepted, most of the time is a format
issue IMO only. So your code above basically
    dies the same as a format, but unfortunately on top mixes it with a
PropertySource. ​


> Adding a PropertySourceProviderManager is not helpfull because it has to
> discover existing format (Anatoles approach) or

​This is not true. My example PropertySource can as well use exactly one
single format, but also is fkexible enough to support multiple ones. BTW
also a precondition, when you want to be able to integrate alternate format
implementations such as commons-configuration ;)​



> 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..
>

​As I said, I am also not completely satisfied with everything related to
that, but when doing some criticiscm of things being inflexible, also be
aware that I expect you to provide some ideas how to improve it, Mixing up
formats (the act of parsing), with the act of mapping the parsed data to a
flat key, value structure and assigning (depending on the file location​,
the file entries and whatever else) the correct priority for every
key/value pair, are three aspects that each one must be decided on its own.
Hardcoding anything makes no sense from a framework perspective (but may be
from an enterprise perspective)...


> 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
>
>


-- 
*Anatole Tresch*
Java Engineer & Architect, JSR Spec Lead
Glärnischweg 10
CH - 8620 Wetzikon

*Switzerland, Europe Zurich, GMT+1*
*Twitter:  @atsticks*
*Blogs: **http://javaremarkables.blogspot.ch/
<http://javaremarkables.blogspot.ch/>*

*Google: atsticksMobile  +41-76 344 62 79*

Reply via email to