You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by Adrian Gonzalez <ad...@yahoo.fr> on 2012/03/05 17:38:06 UTC

Re : Re : Re : ConfigResolver : adding @ConfigProperty injection ?

Thanks !

Sorry, what's the next step ?
Are there more people interested by this feature ?

I think we should wait at least 1 day before starting to formalise this (no need to formalise if there's not much interest).



----- Mail original -----
De : Gerhard Petracek <ge...@gmail.com>
À : deltaspike-dev@incubator.apache.org
Cc : 
Envoyé le : Lundi 5 mars 2012 17h24
Objet : Re: Re : Re : ConfigResolver : adding @ConfigProperty injection ?

hi adrian,

would be ok for me.

regards,
gerhard



2012/3/5 Adrian Gonzalez <ad...@yahoo.fr>

> What about having both options ?
>
> 1. be able to use directly @ConfigProperty
> @Produces
> public LoginContext
> produceLoginContext(@ConfigProperty("loginConfigFile") String
> loginConfigFileName, @ConfigProperty("loginModuleName") String
> loginModuleName)
>   }
> }
> Handy when all config values are only used in a centralized class (e.g.
> MyAppConfig).
>
> 2. type safe config annotations
> @ConfigProperty(
>   name = "pool_size",
>   eager = true, //true is also the default value -> the value gets
> converted during the bootstrapping process
>   converter = StringToIntegerConverter.class
> )
> public @interface PoolSize {
> }
>
> ----- Mail original -----
> De : Gerhard Petracek <ge...@gmail.com>
> À : deltaspike-dev@incubator.apache.org
> Cc :
> Envoyé le : Lundi 5 mars 2012 17h08
> Objet : Re: Re : ConfigResolver : adding @ConfigProperty injection ?
>
> hi adrian,
>
> @#1:
> it isn't the default value of the property.
> eager should be true by default -> the configured value gets converted
> during bootstrapping (if the value has an invalid format the bootstrapping
> process fails).
> if eager is false, the configured value will be converted directly before
> the injection (e.g. for values stored in dynamic config-sources).
>
> @#2:
> afaik there is an upcoming jsr about it.
>
> regards,
> gerhard
>
>
>
> 2012/3/5 Adrian Gonzalez <ad...@yahoo.fr>
>
> > Hi Gerhard,
> >
> > 1. didn't understood the meaning of eager attribute
> > If eager = default value, it should have been some integer value in your
> > sample
> >
> >
> > 2. StringToIntegerConverter converter
> > Is there an existing conversion API (standard, in deltaspike, ...) ?
> > (otherwise we're gonna need one here - and end up with another conversion
> > API ;) )
> >
> > Thanks !
> >
> > ----- Mail original -----
> > De : Gerhard Petracek <ge...@gmail.com>
> > À : deltaspike-dev@incubator.apache.org
> > Cc :
> > Envoyé le : Lundi 5 mars 2012 12h57
> > Objet : Re: ConfigResolver : adding @ConfigProperty injection ?
> >
> > hi adrian,
> >
> > if we agree also on adding a bit more to allow e.g.:
> >
> > //...
> > @ConfigProperty(
> >   name = "pool_size",
> >   eager = true, //true is also the default value -> the value gets
> > converted during the bootstrapping process
> >   converter = StringToIntegerConverter.class
> > )
> > public @interface PoolSize
> > {
> > }
> >
> > @Inject
> > @PoolSize
> > private int configuredPoolSize;
> >
> > then i would vote +1
> > (for sure the details need further discussions.)
> >
> > regards,
> > gerhard
> >
> >
> >
> > 2012/3/5 Adrian Gonzalez <ad...@yahoo.fr>
> >
> > > Hello,
> > >
> > > Deltaspike config module is based on ConfigResolver usage :
> > >   ConfigResolver.getPropertyValue("test")
> > >
> > >
> > > Wouldn't it be interesting to add on top of it some injection
> > > capacity ? (i.e. providing @ConfigProperty annotation)
> > >
> > > Sample usage [1] :
> > > @Produces
> > > public LoginContext
> > produceLoginContext(@ConfigProperty("loginConfigFile")
> > > String loginConfigFileName,
> > >
> >  @ConfigProperty("loginModuleName")
> > > String loginModuleName)
> > >    blabla
> > > }
> > >
> > > This approach is based on Antonio's petstore application - config code
> is
> > > available in [2]
> > >
> > > [1]
> > >
> >
> https://github.com/agoncal/agoncal-application-petstore-ee6/blob/master/src/main/java/org/agoncal/application/petstore/security/LoginContextProducer.java
> > >
> > > [2]
> > >
> >
> https://github.com/agoncal/agoncal-application-petstore-ee6/blob/master/src/main/java/org/agoncal/application/petstore/util/ConfigProperty.java
> > >
> > >
> >
> https://github.com/agoncal/agoncal-application-petstore-ee6/blob/master/src/main/java/org/agoncal/application/petstore/util/ConfigPropertyProducer.java
> > >
> > >
> >
> >
>
>