@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:
>
>> You judt want few custom sources you can call directly for that purpose but
>> to be honest this look like the opposite of tamaya design (you dont
>> discover files but property sources)
>> Le 12 févr. 2015 17:37, "Anatole Tresch" <[email protected]> a écrit :
>>
>> > Definitivly not, semms for mw you mix up things_
>> >
>> > PropertySourceProvider = n PropertySources
>> > Location(URL) + format + Config/PriorityMapping = n PropertySources
>> >
>> > Oliver B. Fischer <[email protected]> schrieb am Thu Feb 12 2015
>> at
>> > 16:51:20:
>> >
>> > > @Anatole: IMHO duplicates the formats module the functionality of the
>> > > PropertySource. IMHO.
>> > >
>> > > Am 12.02.15 um 10:41 schrieb Anatole Tresch:
>> > > > +1 for some sample snippets. Perhaps also look at the extensions
>> module
>> > > > called 'formats'. This is still work in progress though (I am not yet
>> > > > satisfied with the abstractions), though it might go in a direction
>> you
>> > > > also are thinking, perhaps...?
>> > > >
>> > > > public class MyTestSinglePropertySourceProvider extends
>> > > > BaseSimpleFormatPropertySourceProvider{
>> > > >      public MyTestSinglePropertySourceProvider() {
>> > > >          super(new JSonFormat(),
>> > > > MyTestSinglePropertySourceProvider.class.getResource(
>> > > >                  "META-INF/config/myConfig.ini"));
>> > > >      }
>> > > >
>> > > >      @Override
>> > > >      protected PropertySource createPropertySource(String
>> > entryTypeName,
>> > > > Map<String, String> entries,
>> > > >
>> ConfigurationFormat
>> > > > formatUsed) {
>> > > >          // assuming there is only one entryTypeName = default
>> > > >          return new HirarchicalPropertySource(entries);
>> > > >      }
>> > > > }
>> > > >
>> > > > and
>> > > >
>> > > > public class MyTestMultiPropertySourceProvider extends
>> > > > BasePathBasedMultiFormatPropertySourceProvider{
>> > > >      public MyTestMultiPropertySourceProvi
>> der(List<ConfigurationFormat>
>> > > > formats, String... paths) {
>> > > >          super(Arrays.asList(new ConfigurationFormat[]{}
>> > > >                  new JsonFormat(),
>> > > >                  new PropertiesFormat(),
>> > > >                  new IniConfigurationFormat()}
>> > > >          ), "META-INF/config/tamaya-config.*");
>> > > >      }
>> > > >
>> > > >      @Override
>> > > >      protected PropertySource getPropertySource(String entryTypeName,
>> > > > Map<String, String> entries,
>> > > >                                                 ConfigurationFormat
>> > > > formatUsed) {
>> > > >          // Convert items read into a corresponding PropertySource
>> > > >          return null;
>> > > >      }
>> > > > }
>> > > >
>> > > > Cheers,
>> > > > Anatole
>> > > >
>> > > >
>> > > >
>> > > > 2015-02-12 8:38 GMT+01:00 Romain Manni-Bucau <[email protected]
>> >:
>> > > >
>> > > >> Can you give a sample please? I dont get the point
>> > > >>   Le 12 févr. 2015 08:25, "Oliver B. Fischer" <
>> > [email protected]>
>> > > a
>> > > >> écrit :
>> > > >>
>> > > >>> Dear all,
>> > > >>>
>> > > >>> PropertySource is our abstraction for different property sources
>> and
>> > > >>> formats. I think we agree on this. Furthermore we said the origin
>> of
>> > a
>> > > >>> source must be overhanded as a URL (file://somewhere/).
>> > > >>>
>> > > >>> That is fine and works. But IMHO we miss the connection between
>> them.
>> > > How
>> > > >>> to specify a specific property source and to find the matching
>> > > >>> PropertySource?
>> > > >>>
>> > > >>> Therefore I would like to propose a option SPI:
>> PropertySourceLocator
>> > > (?)
>> > > >>>
>> > > >>> PropertySourceLocator#accepts(URL url):boolean
>> > > >>> PropertySourceLocator#get(URL url): PropertySource
>> > > >>>
>> > > >>> WDYT?
>> > > >>>
>> > > >>> Oliver
>> > > >>>
>> > > >>> --
>> > > >>> 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
>> > > >>>
>> > > >>>
>> > > >
>> > > >
>> > >
>> > > --
>> > > 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