You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@deltaspike.apache.org by Stevo Slavić <ss...@gmail.com> on 2012/07/13 17:20:13 UTC

Custom config file resolution strategy

Hello DeltaSpike community,

I'm looking into configuration API, and AFAICT I can only reuse
@ConfigProperty (and maybe PropertyConfigSource) but file resolution
strategy in current 0.3 incubator snapshot is not flexible enough.

In an app, tests configuration (java properties) files are to be provided
on classpath.
At runtime there ought to be a fallback chain of config file resolution
strategies. For provided configuration source file name strategies should
try to:
- resolve property files as relative to system/application configuration
directory defined by Java system property and/or environment variable
- resolve relative from user home;
- resolve using provided file name on the file system;
- resolve from classpath.

If I'm not mistaken, this would require implementing custom ConfigProperty
producer and resolvers. Also, as consequence I'd miss out on bundled
DeltaSpike's config source implementations (which extend BaseConfigSource),
because they are package private.

Am I missing something, can configuration file resolution strategy be
easily customized and extended?

Kind regards,
Stevo Slavić.

Re: Custom config file resolution strategy

Posted by Gerhard Petracek <ge...@gmail.com>.
hi stevo,

this interface is just for simple use-cases.
for more complex cases you can use ConfigSource
(see ConfigSource#getOrdinal) and for advanced use-cases you can use
ConfigSourceProvider.

regards,
gerhard



2012/7/13 Stevo Slavić <ss...@gmail.com>

> Hello DeltaSpike community,
>
> I'm looking into configuration API, and AFAICT I can only reuse
> @ConfigProperty (and maybe PropertyConfigSource) but file resolution
> strategy in current 0.3 incubator snapshot is not flexible enough.
>
> In an app, tests configuration (java properties) files are to be provided
> on classpath.
> At runtime there ought to be a fallback chain of config file resolution
> strategies. For provided configuration source file name strategies should
> try to:
> - resolve property files as relative to system/application configuration
> directory defined by Java system property and/or environment variable
> - resolve relative from user home;
> - resolve using provided file name on the file system;
> - resolve from classpath.
>
> If I'm not mistaken, this would require implementing custom ConfigProperty
> producer and resolvers. Also, as consequence I'd miss out on bundled
> DeltaSpike's config source implementations (which extend BaseConfigSource),
> because they are package private.
>
> Am I missing something, can configuration file resolution strategy be
> easily customized and extended?
>
> Kind regards,
> Stevo Slavić.
>