Clarification for manually resolving 'Instance'

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Clarification for manually resolving 'Instance'

Mark Struberg
Hi!

Currently both Weld and OWB blow up if I resolve an unparameterized 'Instance' object.

beanManager.getBeans(Instance.class);

will return zero beans, so there is no way to call beanManager.getReference ...


Of course with a little trick I was able to get it working in OWB:
Type instanceType = new TypeLiteral<Instance<Object>>(){}.getType();
Set<Bean<?>> beans = beanManager.getBeans(instanceType);

(did not test it on Weld yet)


My question is which behaviour is expected.
This question could maybe be generalized to: how do beans for parameterized types need to get handled?


LieGrue,
strub

_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clarification for manually resolving 'Instance'

Pete Muir
Administrator
See section 5.6.2. The built-in Instance - the spec only requires a bean of type Instance<X> not of raw type Instance<>

I'm not sure there is a generalization here (or I don't understand yours). The parameterized type resolution rules are correct, it's just there is no raw type of Instance to resolve.

Should there be? Not sure if it would just be more confusing?

On 24 Sep 2011, at 11:41, Mark Struberg wrote:

> Hi!
>
> Currently both Weld and OWB blow up if I resolve an unparameterized 'Instance' object.
>
> beanManager.getBeans(Instance.class);
>
> will return zero beans, so there is no way to call beanManager.getReference ...
>
>
> Of course with a little trick I was able to get it working in OWB:
> Type instanceType = new TypeLiteral<Instance<Object>>(){}.getType();
> Set<Bean<?>> beans = beanManager.getBeans(instanceType);
>
> (did not test it on Weld yet)

This should work on Weld to.

>
>
> My question is which behaviour is expected.
> This question could maybe be generalized to: how do beans for parameterized types need to get handled?
>
>
> LieGrue,
> strub
>
> _______________________________________________
> cdi-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/cdi-dev


_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clarification for manually resolving 'Instance'

Mark Struberg
>The parameterized type resolution rules are correct, it's just there
> is no raw type of Instance to resolve.


Yes, I think too, but was not sure if everyone do see it that way.


> Should there be? Not sure if it would just be more confusing?

I already saw the usage of Instance.class without the TypeLiteral (which is pretty well hidden in the specs).
And people wondered why that doesn't work ...

LieGrue,
strub



----- Original Message -----

> From: Pete Muir <[hidden email]>
> To: Mark Struberg <[hidden email]>
> Cc: "[hidden email]" <[hidden email]>
> Sent: Sunday, September 25, 2011 9:44 PM
> Subject: Re: [cdi-dev] Clarification for manually resolving 'Instance'
>
> See section 5.6.2. The built-in Instance - the spec only requires a bean of type
> Instance<X> not of raw type Instance<>
>
> I'm not sure there is a generalization here (or I don't understand
> yours). The parameterized type resolution rules are correct, it's just there
> is no raw type of Instance to resolve.
>
> Should there be? Not sure if it would just be more confusing?
>
> On 24 Sep 2011, at 11:41, Mark Struberg wrote:
>
>>  Hi!
>>
>>  Currently both Weld and OWB blow up if I resolve an unparameterized
> 'Instance' object.
>>
>>  beanManager.getBeans(Instance.class);
>>
>>  will return zero beans, so there is no way to call beanManager.getReference
> ...
>>
>>
>>  Of course with a little trick I was able to get it working in OWB:
>>  Type instanceType = new
> TypeLiteral<Instance<Object>>(){}.getType();
>>  Set<Bean<?>> beans = beanManager.getBeans(instanceType);
>>
>>  (did not test it on Weld yet)
>
> This should work on Weld to.
>
>>
>>
>>  My question is which behaviour is expected.
>>  This question could maybe be generalized to: how do beans for parameterized
> types need to get handled?
>>
>>
>>  LieGrue,
>>  strub
>>
>>  _______________________________________________
>>  cdi-dev mailing list
>>  [hidden email]
>>  https://lists.jboss.org/mailman/listinfo/cdi-dev
>
_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clarification for manually resolving 'Instance'

Pete Muir
Administrator

On 25 Sep 2011, at 21:06, Mark Struberg wrote:

>> The parameterized type resolution rules are correct, it's just there
>> is no raw type of Instance to resolve.
>
>
> Yes, I think too, but was not sure if everyone do see it that way.

Ok, so until I actually see someone make a specific comment, I think we can leave this alone :-)

>
>
>> Should there be? Not sure if it would just be more confusing?
>
> I already saw the usage of Instance.class without the TypeLiteral (which is pretty well hidden in the specs).
> And people wondered why that doesn't work ...

Ok, file an issue, we can think about how to improve this.
_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clarification for manually resolving 'Instance'

Arne Limburg
Hi,

wouldn't be so hard to specify that beanManager.getBeans(Instance.class); is the same as
beanManager.getBeans(new TypeLiteral<Instance<Object>>() {}.getType());

Cheers,
Arne

--
 
Arne Limburg - Enterprise Architekt
open knowledge GmbH, Oldenburg
Bismarckstraße 13, 26122 Oldenburg
Mobil: +49 (0) 151 108 22 942
Tel: +49 (0) 441 - 4082-0
Fax: +49 (0) 441 - 4082-111
[hidden email]
http://www.openknowledge.de

Registergericht: Amtsgericht Oldenburg, HRB 4670
Geschäftsführer: Lars Röwekamp, Jens Schumann


-----Ursprüngliche Nachricht-----
Von: [hidden email] [mailto:[hidden email]] Im Auftrag von Pete Muir
Gesendet: Sonntag, 25. September 2011 22:08
An: Mark Struberg
Cc: [hidden email]
Betreff: Re: [cdi-dev] Clarification for manually resolving 'Instance'


On 25 Sep 2011, at 21:06, Mark Struberg wrote:

>> The parameterized type resolution rules are correct, it's just there
>> is no raw type of Instance to resolve.
>
>
> Yes, I think too, but was not sure if everyone do see it that way.

Ok, so until I actually see someone make a specific comment, I think we can leave this alone :-)

>
>
>> Should there be? Not sure if it would just be more confusing?
>
> I already saw the usage of Instance.class without the TypeLiteral (which is pretty well hidden in the specs).
> And people wondered why that doesn't work ...

Ok, file an issue, we can think about how to improve this.
_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev

_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clarification for manually resolving 'Instance'

Pete Muir
Administrator
Right, this is the obvious solution, (well actually we would specify that a bean is registered for Instance as well as Instance<X> rather than fiddle with the resolution rules). I'm not sure if there any problems right now ;-)

On 25 Sep 2011, at 21:11, Arne Limburg wrote:

> Hi,
>
> wouldn't be so hard to specify that beanManager.getBeans(Instance.class); is the same as
> beanManager.getBeans(new TypeLiteral<Instance<Object>>() {}.getType());
>
> Cheers,
> Arne
>
> --
>
> Arne Limburg - Enterprise Architekt
> open knowledge GmbH, Oldenburg
> Bismarckstraße 13, 26122 Oldenburg
> Mobil: +49 (0) 151 108 22 942
> Tel: +49 (0) 441 - 4082-0
> Fax: +49 (0) 441 - 4082-111
> [hidden email]
> http://www.openknowledge.de
>
> Registergericht: Amtsgericht Oldenburg, HRB 4670
> Geschäftsführer: Lars Röwekamp, Jens Schumann
>
>
> -----Ursprüngliche Nachricht-----
> Von: [hidden email] [mailto:[hidden email]] Im Auftrag von Pete Muir
> Gesendet: Sonntag, 25. September 2011 22:08
> An: Mark Struberg
> Cc: [hidden email]
> Betreff: Re: [cdi-dev] Clarification for manually resolving 'Instance'
>
>
> On 25 Sep 2011, at 21:06, Mark Struberg wrote:
>
>>> The parameterized type resolution rules are correct, it's just there
>>> is no raw type of Instance to resolve.
>>
>>
>> Yes, I think too, but was not sure if everyone do see it that way.
>
> Ok, so until I actually see someone make a specific comment, I think we can leave this alone :-)
>
>>
>>
>>> Should there be? Not sure if it would just be more confusing?
>>
>> I already saw the usage of Instance.class without the TypeLiteral (which is pretty well hidden in the specs).
>> And people wondered why that doesn't work ...
>
> Ok, file an issue, we can think about how to improve this.
> _______________________________________________
> cdi-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/cdi-dev


_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clarification for manually resolving 'Instance'

Arne Limburg
Hi Pete,

Obviously the current implementations (at least Weld and OpenWebBeans) need special handling for this case. From a user perspective it would be convenient to be able to do a beanManager.getBeans(Instance.class). That is the only way currently to list all available Beans, which is needed from time to time. Since I am always a fan of seeing things from the users perspective, so why not specifying this?

Cheers,
Arne

-----Ursprüngliche Nachricht-----
Von: Pete Muir [mailto:[hidden email]]
Gesendet: Sonntag, 25. September 2011 22:13
An: Arne Limburg
Cc: Mark Struberg; [hidden email]
Betreff: Re: AW: [cdi-dev] Clarification for manually resolving 'Instance'

Right, this is the obvious solution, (well actually we would specify that a bean is registered for Instance as well as Instance<X> rather than fiddle with the resolution rules). I'm not sure if there any problems right now ;-)

On 25 Sep 2011, at 21:11, Arne Limburg wrote:

> Hi,
>
> wouldn't be so hard to specify that
> beanManager.getBeans(Instance.class); is the same as
> beanManager.getBeans(new TypeLiteral<Instance<Object>>()
> {}.getType());
>
> Cheers,
> Arne
>
> --
>
> Arne Limburg - Enterprise Architekt
> open knowledge GmbH, Oldenburg
> Bismarckstraße 13, 26122 Oldenburg
> Mobil: +49 (0) 151 108 22 942
> Tel: +49 (0) 441 - 4082-0
> Fax: +49 (0) 441 - 4082-111
> [hidden email]
> http://www.openknowledge.de
>
> Registergericht: Amtsgericht Oldenburg, HRB 4670
> Geschäftsführer: Lars Röwekamp, Jens Schumann
>
>
> -----Ursprüngliche Nachricht-----
> Von: [hidden email]
> [mailto:[hidden email]] Im Auftrag von Pete Muir
> Gesendet: Sonntag, 25. September 2011 22:08
> An: Mark Struberg
> Cc: [hidden email]
> Betreff: Re: [cdi-dev] Clarification for manually resolving 'Instance'
>
>
> On 25 Sep 2011, at 21:06, Mark Struberg wrote:
>
>>> The parameterized type resolution rules are correct, it's just there
>>> is no raw type of Instance to resolve.
>>
>>
>> Yes, I think too, but was not sure if everyone do see it that way.
>
> Ok, so until I actually see someone make a specific comment, I think
> we can leave this alone :-)
>
>>
>>
>>> Should there be? Not sure if it would just be more confusing?
>>
>> I already saw the usage of Instance.class without the TypeLiteral (which is pretty well hidden in the specs).
>> And people wondered why that doesn't work ...
>
> Ok, file an issue, we can think about how to improve this.
> _______________________________________________
> cdi-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/cdi-dev


_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clarification for manually resolving 'Instance'

Pete Muir
Administrator
I think you misunderstood me, I asked Mark (or anyone) to file an issue so that we can specify this ;-) I'm not doing it right now as I'm in the middle of refactor of Infinispan ;-)

On 25 Sep 2011, at 21:18, Arne Limburg wrote:

> Hi Pete,
>
> Obviously the current implementations (at least Weld and OpenWebBeans) need special handling for this case. From a user perspective it would be convenient to be able to do a beanManager.getBeans(Instance.class). That is the only way currently to list all available Beans, which is needed from time to time. Since I am always a fan of seeing things from the users perspective, so why not specifying this?
>
> Cheers,
> Arne
>
> -----Ursprüngliche Nachricht-----
> Von: Pete Muir [mailto:[hidden email]]
> Gesendet: Sonntag, 25. September 2011 22:13
> An: Arne Limburg
> Cc: Mark Struberg; [hidden email]
> Betreff: Re: AW: [cdi-dev] Clarification for manually resolving 'Instance'
>
> Right, this is the obvious solution, (well actually we would specify that a bean is registered for Instance as well as Instance<X> rather than fiddle with the resolution rules). I'm not sure if there any problems right now ;-)
>
> On 25 Sep 2011, at 21:11, Arne Limburg wrote:
>
>> Hi,
>>
>> wouldn't be so hard to specify that
>> beanManager.getBeans(Instance.class); is the same as
>> beanManager.getBeans(new TypeLiteral<Instance<Object>>()
>> {}.getType());
>>
>> Cheers,
>> Arne
>>
>> --
>>
>> Arne Limburg - Enterprise Architekt
>> open knowledge GmbH, Oldenburg
>> Bismarckstraße 13, 26122 Oldenburg
>> Mobil: +49 (0) 151 108 22 942
>> Tel: +49 (0) 441 - 4082-0
>> Fax: +49 (0) 441 - 4082-111
>> [hidden email]
>> http://www.openknowledge.de
>>
>> Registergericht: Amtsgericht Oldenburg, HRB 4670
>> Geschäftsführer: Lars Röwekamp, Jens Schumann
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: [hidden email]
>> [mailto:[hidden email]] Im Auftrag von Pete Muir
>> Gesendet: Sonntag, 25. September 2011 22:08
>> An: Mark Struberg
>> Cc: [hidden email]
>> Betreff: Re: [cdi-dev] Clarification for manually resolving 'Instance'
>>
>>
>> On 25 Sep 2011, at 21:06, Mark Struberg wrote:
>>
>>>> The parameterized type resolution rules are correct, it's just there
>>>> is no raw type of Instance to resolve.
>>>
>>>
>>> Yes, I think too, but was not sure if everyone do see it that way.
>>
>> Ok, so until I actually see someone make a specific comment, I think
>> we can leave this alone :-)
>>
>>>
>>>
>>>> Should there be? Not sure if it would just be more confusing?
>>>
>>> I already saw the usage of Instance.class without the TypeLiteral (which is pretty well hidden in the specs).
>>> And people wondered why that doesn't work ...
>>
>> Ok, file an issue, we can think about how to improve this.
>> _______________________________________________
>> cdi-dev mailing list
>> [hidden email]
>> https://lists.jboss.org/mailman/listinfo/cdi-dev
>


_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clarification for manually resolving 'Instance'

Arne Limburg
OK :-) no problem,
Mark or me will file an issue for this. I'll take a look if I can provide a pull-request for this.

Cheers,
Arne

--
 
Arne Limburg - Enterprise Architekt
open knowledge GmbH, Oldenburg
Bismarckstraße 13, 26122 Oldenburg
Mobil: +49 (0) 151 108 22 942
Tel: +49 (0) 441 - 4082-0
Fax: +49 (0) 441 - 4082-111
[hidden email]
http://www.openknowledge.de

Registergericht: Amtsgericht Oldenburg, HRB 4670
Geschäftsführer: Lars Röwekamp, Jens Schumann


-----Ursprüngliche Nachricht-----
Von: Pete Muir [mailto:[hidden email]]
Gesendet: Sonntag, 25. September 2011 22:22
An: Arne Limburg
Cc: [hidden email]
Betreff: Re: AW: AW: [cdi-dev] Clarification for manually resolving 'Instance'

I think you misunderstood me, I asked Mark (or anyone) to file an issue so that we can specify this ;-) I'm not doing it right now as I'm in the middle of refactor of Infinispan ;-)

On 25 Sep 2011, at 21:18, Arne Limburg wrote:

> Hi Pete,
>
> Obviously the current implementations (at least Weld and OpenWebBeans) need special handling for this case. From a user perspective it would be convenient to be able to do a beanManager.getBeans(Instance.class). That is the only way currently to list all available Beans, which is needed from time to time. Since I am always a fan of seeing things from the users perspective, so why not specifying this?
>
> Cheers,
> Arne
>
> -----Ursprüngliche Nachricht-----
> Von: Pete Muir [mailto:[hidden email]]
> Gesendet: Sonntag, 25. September 2011 22:13
> An: Arne Limburg
> Cc: Mark Struberg; [hidden email]
> Betreff: Re: AW: [cdi-dev] Clarification for manually resolving 'Instance'
>
> Right, this is the obvious solution, (well actually we would specify
> that a bean is registered for Instance as well as Instance<X> rather
> than fiddle with the resolution rules). I'm not sure if there any
> problems right now ;-)
>
> On 25 Sep 2011, at 21:11, Arne Limburg wrote:
>
>> Hi,
>>
>> wouldn't be so hard to specify that
>> beanManager.getBeans(Instance.class); is the same as
>> beanManager.getBeans(new TypeLiteral<Instance<Object>>()
>> {}.getType());
>>
>> Cheers,
>> Arne
>>
>> --
>>
>> Arne Limburg - Enterprise Architekt
>> open knowledge GmbH, Oldenburg
>> Bismarckstraße 13, 26122 Oldenburg
>> Mobil: +49 (0) 151 108 22 942
>> Tel: +49 (0) 441 - 4082-0
>> Fax: +49 (0) 441 - 4082-111
>> [hidden email]
>> http://www.openknowledge.de
>>
>> Registergericht: Amtsgericht Oldenburg, HRB 4670
>> Geschäftsführer: Lars Röwekamp, Jens Schumann
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: [hidden email]
>> [mailto:[hidden email]] Im Auftrag von Pete Muir
>> Gesendet: Sonntag, 25. September 2011 22:08
>> An: Mark Struberg
>> Cc: [hidden email]
>> Betreff: Re: [cdi-dev] Clarification for manually resolving 'Instance'
>>
>>
>> On 25 Sep 2011, at 21:06, Mark Struberg wrote:
>>
>>>> The parameterized type resolution rules are correct, it's just
>>>> there is no raw type of Instance to resolve.
>>>
>>>
>>> Yes, I think too, but was not sure if everyone do see it that way.
>>
>> Ok, so until I actually see someone make a specific comment, I think
>> we can leave this alone :-)
>>
>>>
>>>
>>>> Should there be? Not sure if it would just be more confusing?
>>>
>>> I already saw the usage of Instance.class without the TypeLiteral (which is pretty well hidden in the specs).
>>> And people wondered why that doesn't work ...
>>
>> Ok, file an issue, we can think about how to improve this.
>> _______________________________________________
>> cdi-dev mailing list
>> [hidden email]
>> https://lists.jboss.org/mailman/listinfo/cdi-dev
>


_______________________________________________
cdi-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/cdi-dev