You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by "John D. Ament" <jo...@apache.org> on 2017/07/29 11:12:23 UTC

Should primitive types work in config?

Hey guys

I raised a spec level issue on MP Config because primitives don't work
quite right in Geronimo Config and when I looked at the spec, it didn't say
they should.

Basically, primitives aren't used in the TCK, and the follow behaviors are
noticed:

int port = config.getValue("some key", Integer.class); // this works via
unboxing
int port = config.getValue("some key", int.class); //fails due to missing
converter
    @Inject
    @ConfigProperty(name="some key",defaultValue = "8080")
    private int port;
// also fails due to missing converter

So should they? Is this a Geronimo specific issue?

John

Re: Should primitive types work in config?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hmm right, pretty sure I had an issue with primitives at some point but can
be specific to a version or project. Let handle it anyway here and thanks
for the memory refresh ;).


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2017-07-30 13:36 GMT+02:00 John D. Ament <jo...@apache.org>:

> You can inject to primitive fields in DS config (that's how I found this
> problem).
>
> John
>
>
> On Sun, Jul 30, 2017 at 6:10 AM Romain Manni-Bucau <rm...@gmail.com>
> wrote:
>
>> Interesting, why was it rejected in DeltaSpike config then? Do you recall?
>>
>> Now on config itself if cdi does +1 to support it. We should probably
>> align on the spec defaults, ie null would resolve to 0 for an int for
>> instance.
>>
>>
>> Romain Manni-Bucau
>> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
>> <https://blog-rmannibucau.rhcloud.com> | Old Blog
>> <http://rmannibucau.wordpress.com> | Github
>> <https://github.com/rmannibucau> | LinkedIn
>> <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
>> <https://javaeefactory-rmannibucau.rhcloud.com>
>>
>> 2017-07-30 10:49 GMT+02:00 Mark Struberg <st...@yahoo.de>:
>>
>>> http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#
>>> primitive_types_and_null_values
>>>
>>> "For the purposes of typesafe resolution and dependency injection,
>>> primitive types and their corresponding wrapper types in the package
>>> java.lang are considered identical and assignable. If necessary, the
>>> container performs boxing or unboxing when it injects a value to a field or
>>> parameter of primitive or wrapper type."
>>>
>>> LieGrue,
>>> strub
>>>
>>> > Am 30.07.2017 um 10:25 schrieb Romain Manni-Bucau <
>>> rmannibucau@gmail.com>:
>>> >
>>> > Hmm, cdi does? was pretty sure injections had Object constraint. Do I
>>> get it wrong?
>>> >
>>> >
>>> > Romain Manni-Bucau
>>> > @rmannibucau |  Blog | Old Blog | Github | LinkedIn | JavaEE Factory
>>> >
>>> > 2017-07-30 10:06 GMT+02:00 Mark Struberg <st...@yahoo.de>:
>>> > CDI supports primitives. So I'm not quite sure what's the point?
>>> >
>>> > LieGrue,
>>> > strub
>>> >
>>> >
>>> > > Am 30.07.2017 um 09:26 schrieb Romain Manni-Bucau <
>>> rmannibucau@gmail.com>:
>>> > >
>>> > >
>>> > > Alternative would be to make cdi support primitive, agree there is
>>> no blocker at all to do it but then for libs i think we need to limit to
>>> the most constrained impl, cdi here.
>>> > >
>>> >
>>> >
>>>
>>>
>>

Re: Should primitive types work in config?

Posted by "John D. Ament" <jo...@apache.org>.
You can inject to primitive fields in DS config (that's how I found this
problem).

John

On Sun, Jul 30, 2017 at 6:10 AM Romain Manni-Bucau <rm...@gmail.com>
wrote:

> Interesting, why was it rejected in DeltaSpike config then? Do you recall?
>
> Now on config itself if cdi does +1 to support it. We should probably
> align on the spec defaults, ie null would resolve to 0 for an int for
> instance.
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <https://blog-rmannibucau.rhcloud.com> | Old Blog
> <http://rmannibucau.wordpress.com> | Github
> <https://github.com/rmannibucau> | LinkedIn
> <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
> <https://javaeefactory-rmannibucau.rhcloud.com>
>
> 2017-07-30 10:49 GMT+02:00 Mark Struberg <st...@yahoo.de>:
>
>>
>> http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#primitive_types_and_null_values
>>
>> "For the purposes of typesafe resolution and dependency injection,
>> primitive types and their corresponding wrapper types in the package
>> java.lang are considered identical and assignable. If necessary, the
>> container performs boxing or unboxing when it injects a value to a field or
>> parameter of primitive or wrapper type."
>>
>> LieGrue,
>> strub
>>
>> > Am 30.07.2017 um 10:25 schrieb Romain Manni-Bucau <
>> rmannibucau@gmail.com>:
>> >
>> > Hmm, cdi does? was pretty sure injections had Object constraint. Do I
>> get it wrong?
>> >
>> >
>> > Romain Manni-Bucau
>> > @rmannibucau |  Blog | Old Blog | Github | LinkedIn | JavaEE Factory
>> >
>> > 2017-07-30 10:06 GMT+02:00 Mark Struberg <st...@yahoo.de>:
>> > CDI supports primitives. So I'm not quite sure what's the point?
>> >
>> > LieGrue,
>> > strub
>> >
>> >
>> > > Am 30.07.2017 um 09:26 schrieb Romain Manni-Bucau <
>> rmannibucau@gmail.com>:
>> > >
>> > >
>> > > Alternative would be to make cdi support primitive, agree there is no
>> blocker at all to do it but then for libs i think we need to limit to the
>> most constrained impl, cdi here.
>> > >
>> >
>> >
>>
>>
>

Re: Should primitive types work in config?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Interesting, why was it rejected in DeltaSpike config then? Do you recall?

Now on config itself if cdi does +1 to support it. We should probably align
on the spec defaults, ie null would resolve to 0 for an int for instance.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2017-07-30 10:49 GMT+02:00 Mark Struberg <st...@yahoo.de>:

> http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#primitive_types_and_null_
> values
>
> "For the purposes of typesafe resolution and dependency injection,
> primitive types and their corresponding wrapper types in the package
> java.lang are considered identical and assignable. If necessary, the
> container performs boxing or unboxing when it injects a value to a field or
> parameter of primitive or wrapper type."
>
> LieGrue,
> strub
>
> > Am 30.07.2017 um 10:25 schrieb Romain Manni-Bucau <rmannibucau@gmail.com
> >:
> >
> > Hmm, cdi does? was pretty sure injections had Object constraint. Do I
> get it wrong?
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau |  Blog | Old Blog | Github | LinkedIn | JavaEE Factory
> >
> > 2017-07-30 10:06 GMT+02:00 Mark Struberg <st...@yahoo.de>:
> > CDI supports primitives. So I'm not quite sure what's the point?
> >
> > LieGrue,
> > strub
> >
> >
> > > Am 30.07.2017 um 09:26 schrieb Romain Manni-Bucau <
> rmannibucau@gmail.com>:
> > >
> > >
> > > Alternative would be to make cdi support primitive, agree there is no
> blocker at all to do it but then for libs i think we need to limit to the
> most constrained impl, cdi here.
> > >
> >
> >
>
>

Re: Should primitive types work in config?

Posted by Mark Struberg <st...@yahoo.de>.
http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#primitive_types_and_null_values

"For the purposes of typesafe resolution and dependency injection, primitive types and their corresponding wrapper types in the package java.lang are considered identical and assignable. If necessary, the container performs boxing or unboxing when it injects a value to a field or parameter of primitive or wrapper type."

LieGrue,
strub

> Am 30.07.2017 um 10:25 schrieb Romain Manni-Bucau <rm...@gmail.com>:
> 
> Hmm, cdi does? was pretty sure injections had Object constraint. Do I get it wrong?
> 
> 
> Romain Manni-Bucau
> @rmannibucau |  Blog | Old Blog | Github | LinkedIn | JavaEE Factory
> 
> 2017-07-30 10:06 GMT+02:00 Mark Struberg <st...@yahoo.de>:
> CDI supports primitives. So I'm not quite sure what's the point?
> 
> LieGrue,
> strub
> 
> 
> > Am 30.07.2017 um 09:26 schrieb Romain Manni-Bucau <rm...@gmail.com>:
> >
> >
> > Alternative would be to make cdi support primitive, agree there is no blocker at all to do it but then for libs i think we need to limit to the most constrained impl, cdi here.
> >
> 
> 


Re: Should primitive types work in config?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hmm, cdi does? was pretty sure injections had Object constraint. Do I get
it wrong?


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2017-07-30 10:06 GMT+02:00 Mark Struberg <st...@yahoo.de>:

> CDI supports primitives. So I'm not quite sure what's the point?
>
> LieGrue,
> strub
>
>
> > Am 30.07.2017 um 09:26 schrieb Romain Manni-Bucau <rmannibucau@gmail.com
> >:
> >
> >
> > Alternative would be to make cdi support primitive, agree there is no
> blocker at all to do it but then for libs i think we need to limit to the
> most constrained impl, cdi here.
> >
>
>

Re: Should primitive types work in config?

Posted by Mark Struberg <st...@yahoo.de>.
CDI supports primitives. So I'm not quite sure what's the point?

LieGrue,
strub


> Am 30.07.2017 um 09:26 schrieb Romain Manni-Bucau <rm...@gmail.com>:
> 
> 
> Alternative would be to make cdi support primitive, agree there is no blocker at all to do it but then for libs i think we need to limit to the most constrained impl, cdi here.
> 


Re: Should primitive types work in config?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
@John: it is not a technical issue, it is a model issue:

public class MyConfig {
@Inject @ConfigProperty(name = "...") int port;
}

will work in standalone, spring, ... but if you have a cdi extension
bridging the lib it will just fail - that is why proxy model is more
portable for config for instance ;).

Alternative would be to make cdi support primitive, agree there is no
blocker at all to do it but then for libs i think we need to limit to the
most constrained impl, cdi here.



Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2017-07-30 0:47 GMT+02:00 John D. Ament <jo...@apache.org>:

> It knows enough about primitives to satisfy the converters/programmatic
> lookup.  For CDI, I convert the type back to the wrapper.
>
>
> On Sat, Jul 29, 2017 at 6:44 PM Romain Manni-Bucau <rm...@gmail.com>
> wrote:
>
>> Dont think we should. Would make the api asymmetric/not consistent in cdi
>>
>>
>> Le 29 juil. 2017 17:21, "John D. Ament" <jo...@apache.org> a écrit :
>>
>> Ok i can push when im back at a computer (have changes locally).  Do we
>> want to introduce geronimo specific tests or wait until i can push to mp
>> config?
>>
>> On Jul 29, 2017 11:02 AM, "Mark Struberg" <st...@yahoo.de> wrote:
>>
>>> Oh I see. Now I get what you mean.
>>> Yes, we should just register the same converters for their primitive
>>> counterparts as well.
>>>
>>> LieGrue,
>>> strub
>>>
>>> > Am 29.07.2017 um 13:12 schrieb John D. Ament <jo...@apache.org>:
>>> >
>>> > Hey guys
>>> >
>>> > I raised a spec level issue on MP Config because primitives don't work
>>> quite right in Geronimo Config and when I looked at the spec, it didn't say
>>> they should.
>>> >
>>> > Basically, primitives aren't used in the TCK, and the follow behaviors
>>> are noticed:
>>> >
>>> > int port = config.getValue("some key", Integer.class); // this works
>>> via unboxing
>>> > int port = config.getValue("some key", int.class); //fails due to
>>> missing converter
>>> >     @Inject
>>> >     @ConfigProperty(name="some key",defaultValue = "8080")
>>> >     private int port;
>>> > // also fails due to missing converter
>>> >
>>> > So should they? Is this a Geronimo specific issue?
>>> >
>>> > John
>>>
>>>
>>

Re: Should primitive types work in config?

Posted by "John D. Ament" <jo...@apache.org>.
It knows enough about primitives to satisfy the converters/programmatic
lookup.  For CDI, I convert the type back to the wrapper.

On Sat, Jul 29, 2017 at 6:44 PM Romain Manni-Bucau <rm...@gmail.com>
wrote:

> Dont think we should. Would make the api asymmetric/not consistent in cdi
>
>
> Le 29 juil. 2017 17:21, "John D. Ament" <jo...@apache.org> a écrit :
>
> Ok i can push when im back at a computer (have changes locally).  Do we
> want to introduce geronimo specific tests or wait until i can push to mp
> config?
>
> On Jul 29, 2017 11:02 AM, "Mark Struberg" <st...@yahoo.de> wrote:
>
>> Oh I see. Now I get what you mean.
>> Yes, we should just register the same converters for their primitive
>> counterparts as well.
>>
>> LieGrue,
>> strub
>>
>> > Am 29.07.2017 um 13:12 schrieb John D. Ament <jo...@apache.org>:
>> >
>> > Hey guys
>> >
>> > I raised a spec level issue on MP Config because primitives don't work
>> quite right in Geronimo Config and when I looked at the spec, it didn't say
>> they should.
>> >
>> > Basically, primitives aren't used in the TCK, and the follow behaviors
>> are noticed:
>> >
>> > int port = config.getValue("some key", Integer.class); // this works
>> via unboxing
>> > int port = config.getValue("some key", int.class); //fails due to
>> missing converter
>> >     @Inject
>> >     @ConfigProperty(name="some key",defaultValue = "8080")
>> >     private int port;
>> > // also fails due to missing converter
>> >
>> > So should they? Is this a Geronimo specific issue?
>> >
>> > John
>>
>>
>

Re: Should primitive types work in config?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Dont think we should. Would make the api asymmetric/not consistent in cdi

Le 29 juil. 2017 17:21, "John D. Ament" <jo...@apache.org> a écrit :

Ok i can push when im back at a computer (have changes locally).  Do we
want to introduce geronimo specific tests or wait until i can push to mp
config?

On Jul 29, 2017 11:02 AM, "Mark Struberg" <st...@yahoo.de> wrote:

> Oh I see. Now I get what you mean.
> Yes, we should just register the same converters for their primitive
> counterparts as well.
>
> LieGrue,
> strub
>
> > Am 29.07.2017 um 13:12 schrieb John D. Ament <jo...@apache.org>:
> >
> > Hey guys
> >
> > I raised a spec level issue on MP Config because primitives don't work
> quite right in Geronimo Config and when I looked at the spec, it didn't say
> they should.
> >
> > Basically, primitives aren't used in the TCK, and the follow behaviors
> are noticed:
> >
> > int port = config.getValue("some key", Integer.class); // this works via
> unboxing
> > int port = config.getValue("some key", int.class); //fails due to
> missing converter
> >     @Inject
> >     @ConfigProperty(name="some key",defaultValue = "8080")
> >     private int port;
> > // also fails due to missing converter
> >
> > So should they? Is this a Geronimo specific issue?
> >
> > John
>
>

Re: Should primitive types work in config?

Posted by "John D. Ament" <jo...@apache.org>.
Ok i can push when im back at a computer (have changes locally).  Do we
want to introduce geronimo specific tests or wait until i can push to mp
config?

On Jul 29, 2017 11:02 AM, "Mark Struberg" <st...@yahoo.de> wrote:

> Oh I see. Now I get what you mean.
> Yes, we should just register the same converters for their primitive
> counterparts as well.
>
> LieGrue,
> strub
>
> > Am 29.07.2017 um 13:12 schrieb John D. Ament <jo...@apache.org>:
> >
> > Hey guys
> >
> > I raised a spec level issue on MP Config because primitives don't work
> quite right in Geronimo Config and when I looked at the spec, it didn't say
> they should.
> >
> > Basically, primitives aren't used in the TCK, and the follow behaviors
> are noticed:
> >
> > int port = config.getValue("some key", Integer.class); // this works via
> unboxing
> > int port = config.getValue("some key", int.class); //fails due to
> missing converter
> >     @Inject
> >     @ConfigProperty(name="some key",defaultValue = "8080")
> >     private int port;
> > // also fails due to missing converter
> >
> > So should they? Is this a Geronimo specific issue?
> >
> > John
>
>

Re: Should primitive types work in config?

Posted by Mark Struberg <st...@yahoo.de>.
Oh I see. Now I get what you mean. 
Yes, we should just register the same converters for their primitive counterparts as well.

LieGrue,
strub

> Am 29.07.2017 um 13:12 schrieb John D. Ament <jo...@apache.org>:
> 
> Hey guys
> 
> I raised a spec level issue on MP Config because primitives don't work quite right in Geronimo Config and when I looked at the spec, it didn't say they should.
> 
> Basically, primitives aren't used in the TCK, and the follow behaviors are noticed:
> 
> int port = config.getValue("some key", Integer.class); // this works via unboxing
> int port = config.getValue("some key", int.class); //fails due to missing converter
>     @Inject
>     @ConfigProperty(name="some key",defaultValue = "8080")
>     private int port;
> // also fails due to missing converter
> 
> So should they? Is this a Geronimo specific issue?
> 
> John