You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by Thomas Andraschko <an...@gmail.com> on 2013/10/29 21:23:19 UTC

Alternative + Named

Hi,

should it actually be possible to overwrite a bean with a alternative named
bean?

e.g ->

@Named public class A

with a activated

@Named("a") @Alternative public class A extends B


This somehow just works randomly. Every X container startup, the right bean
will be used with EL.

Thanks.

Regards,
Thomas

Re: Alternative + Named

Posted by Mark Struberg <st...@yahoo.de>.
Sure, just send a mail to the user list.
Or create a CDI jira ticket.

LieGrue,
strub




>________________________________
> From: Thomas Andraschko <an...@gmail.com>
>To: dev@openwebbeans.apache.org; Mark Struberg <st...@yahoo.de> 
>Sent: Tuesday, 29 October 2013, 22:55
>Subject: Re: Alternative + Named
> 
>
>Thanks but IMO this is quite complex for such a normal requirement.
>Is there any chance to discuss this with the expert group?
>Maybe we could implement in OWB after a successful discussion.
>
>
>
>2013/10/29 Mark Struberg <st...@yahoo.de>
>
>> you could create a CDI Extension which does the
>> ProcessAnnotatedType.veto().
>>
>> You could also try to use DeltaSpike globalAlternatives for it. This
>> should do pretty much what you like and internally also works with veto().
>>
>> LieGrue,
>> strub
>>
>>
>>
>>
>> >________________________________
>> > From: Thomas Andraschko <an...@gmail.com>
>> >To: dev@openwebbeans.apache.org; Mark Struberg <st...@yahoo.de>
>> >Sent: Tuesday, 29 October 2013, 21:43
>> >Subject: Re: Alternative + Named
>> >
>> >
>> >
>> >Hi Mark,
>> >
>> >is there any change to get similar behavior?
>> >It's actually a must-have for product development.
>> >We would like to have multiple implementations in our core and just
>> active them via alternative.
>> >With @Specialized or @Exclude, i can't do it without code changes :/
>> >
>> >
>> >
>> >
>> >
>> >
>> >2013/10/29 Mark Struberg <st...@yahoo.de>
>> >
>> >Gee, I fear this is not really well specified.
>> >>I'd rather not bet for it to work.
>> >>Honestly I would have expected that an AmbiguousResolutionException gets
>> thrown.
>> >>
>> >>I'd use @Exclude or @Specializes in this case.
>> >>
>> >>LieGrue,
>> >>strub
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>----- Original Message -----
>> >>> From: Thomas Andraschko <an...@gmail.com>
>> >>> To: dev@openwebbeans.apache.org
>> >>> Cc:
>> >>> Sent: Tuesday, 29 October 2013, 21:23
>> >>> Subject: Alternative + Named
>> >>>
>> >>> Hi,
>> >>>
>> >>> should it actually be possible to overwrite a bean with a alternative
>> named
>> >>> bean?
>> >>>
>> >>> e.g ->
>> >>>
>> >>> @Named public class A
>> >>>
>> >>> with a activated
>> >>>
>> >>> @Named("a") @Alternative public class A extends B
>> >>>
>> >>>
>> >>> This somehow just works randomly. Every X container startup, the right
>> bean
>> >>> will be used with EL.
>> >>>
>> >>> Thanks.
>> >>>
>> >>> Regards,
>> >>> Thomas
>> >>>
>> >>
>> >
>> >
>> >
>>
>
>
>

Re: Alternative + Named

Posted by Thomas Andraschko <an...@gmail.com>.
Thanks but IMO this is quite complex for such a normal requirement.
Is there any chance to discuss this with the expert group?
Maybe we could implement in OWB after a successful discussion.


2013/10/29 Mark Struberg <st...@yahoo.de>

> you could create a CDI Extension which does the
> ProcessAnnotatedType.veto().
>
> You could also try to use DeltaSpike globalAlternatives for it. This
> should do pretty much what you like and internally also works with veto().
>
> LieGrue,
> strub
>
>
>
>
> >________________________________
> > From: Thomas Andraschko <an...@gmail.com>
> >To: dev@openwebbeans.apache.org; Mark Struberg <st...@yahoo.de>
> >Sent: Tuesday, 29 October 2013, 21:43
> >Subject: Re: Alternative + Named
> >
> >
> >
> >Hi Mark,
> >
> >is there any change to get similar behavior?
> >It's actually a must-have for product development.
> >We would like to have multiple implementations in our core and just
> active them via alternative.
> >With @Specialized or @Exclude, i can't do it without code changes :/
> >
> >
> >
> >
> >
> >
> >2013/10/29 Mark Struberg <st...@yahoo.de>
> >
> >Gee, I fear this is not really well specified.
> >>I'd rather not bet for it to work.
> >>Honestly I would have expected that an AmbiguousResolutionException gets
> thrown.
> >>
> >>I'd use @Exclude or @Specializes in this case.
> >>
> >>LieGrue,
> >>strub
> >>
> >>
> >>
> >>
> >>
> >>----- Original Message -----
> >>> From: Thomas Andraschko <an...@gmail.com>
> >>> To: dev@openwebbeans.apache.org
> >>> Cc:
> >>> Sent: Tuesday, 29 October 2013, 21:23
> >>> Subject: Alternative + Named
> >>>
> >>> Hi,
> >>>
> >>> should it actually be possible to overwrite a bean with a alternative
> named
> >>> bean?
> >>>
> >>> e.g ->
> >>>
> >>> @Named public class A
> >>>
> >>> with a activated
> >>>
> >>> @Named("a") @Alternative public class A extends B
> >>>
> >>>
> >>> This somehow just works randomly. Every X container startup, the right
> bean
> >>> will be used with EL.
> >>>
> >>> Thanks.
> >>>
> >>> Regards,
> >>> Thomas
> >>>
> >>
> >
> >
> >
>

Re: Alternative + Named

Posted by Mark Struberg <st...@yahoo.de>.
you could create a CDI Extension which does the ProcessAnnotatedType.veto().

You could also try to use DeltaSpike globalAlternatives for it. This should do pretty much what you like and internally also works with veto().

LieGrue,
strub




>________________________________
> From: Thomas Andraschko <an...@gmail.com>
>To: dev@openwebbeans.apache.org; Mark Struberg <st...@yahoo.de> 
>Sent: Tuesday, 29 October 2013, 21:43
>Subject: Re: Alternative + Named
> 
>
>
>Hi Mark,
>
>is there any change to get similar behavior?
>It's actually a must-have for product development.
>We would like to have multiple implementations in our core and just active them via alternative.
>With @Specialized or @Exclude, i can't do it without code changes :/
>
>
>
>
>
>
>2013/10/29 Mark Struberg <st...@yahoo.de>
>
>Gee, I fear this is not really well specified.
>>I'd rather not bet for it to work.
>>Honestly I would have expected that an AmbiguousResolutionException gets thrown.
>>
>>I'd use @Exclude or @Specializes in this case.
>>
>>LieGrue,
>>strub
>>
>>
>>
>>
>>
>>----- Original Message -----
>>> From: Thomas Andraschko <an...@gmail.com>
>>> To: dev@openwebbeans.apache.org
>>> Cc:
>>> Sent: Tuesday, 29 October 2013, 21:23
>>> Subject: Alternative + Named
>>>
>>> Hi,
>>>
>>> should it actually be possible to overwrite a bean with a alternative named
>>> bean?
>>>
>>> e.g ->
>>>
>>> @Named public class A
>>>
>>> with a activated
>>>
>>> @Named("a") @Alternative public class A extends B
>>>
>>>
>>> This somehow just works randomly. Every X container startup, the right bean
>>> will be used with EL.
>>>
>>> Thanks.
>>>
>>> Regards,
>>> Thomas
>>>
>>
>
>
>

Re: Alternative + Named

Posted by Thomas Andraschko <an...@gmail.com>.
Hi Mark,

is there any change to get similar behavior?
It's actually a must-have for product development.
We would like to have multiple implementations in our core and just active
them via alternative.
With @Specialized or @Exclude, i can't do it without code changes :/




2013/10/29 Mark Struberg <st...@yahoo.de>

> Gee, I fear this is not really well specified.
> I'd rather not bet for it to work.
> Honestly I would have expected that an AmbiguousResolutionException gets
> thrown.
>
> I'd use @Exclude or @Specializes in this case.
>
> LieGrue,
> strub
>
>
>
>
> ----- Original Message -----
> > From: Thomas Andraschko <an...@gmail.com>
> > To: dev@openwebbeans.apache.org
> > Cc:
> > Sent: Tuesday, 29 October 2013, 21:23
> > Subject: Alternative + Named
> >
> > Hi,
> >
> > should it actually be possible to overwrite a bean with a alternative
> named
> > bean?
> >
> > e.g ->
> >
> > @Named public class A
> >
> > with a activated
> >
> > @Named("a") @Alternative public class A extends B
> >
> >
> > This somehow just works randomly. Every X container startup, the right
> bean
> > will be used with EL.
> >
> > Thanks.
> >
> > Regards,
> > Thomas
> >
>

Re: Alternative + Named

Posted by Mark Struberg <st...@yahoo.de>.
Gee, I fear this is not really well specified. 
I'd rather not bet for it to work.
Honestly I would have expected that an AmbiguousResolutionException gets thrown.

I'd use @Exclude or @Specializes in this case.

LieGrue,
strub




----- Original Message -----
> From: Thomas Andraschko <an...@gmail.com>
> To: dev@openwebbeans.apache.org
> Cc: 
> Sent: Tuesday, 29 October 2013, 21:23
> Subject: Alternative + Named
> 
> Hi,
> 
> should it actually be possible to overwrite a bean with a alternative named
> bean?
> 
> e.g ->
> 
> @Named public class A
> 
> with a activated
> 
> @Named("a") @Alternative public class A extends B
> 
> 
> This somehow just works randomly. Every X container startup, the right bean
> will be used with EL.
> 
> Thanks.
> 
> Regards,
> Thomas
>