[seam-dev] @Injecting the same bean with different @Qualifier

Jason Porter lightguard.jp at gmail.com
Mon May 23 17:19:58 EDT 2011


Take a look at
http://download.oracle.com/javaee/6/api/javax/enterprise/inject/spi/InjectionPoint.htmlI
think that should allow you to produce arbitrary instances

On Mon, May 23, 2011 at 15:05, Antoine Sabot-Durand <
antoine at sabot-durand.net> wrote:

> Hi Team,
>
> To provide simple to powerfull ways to use Seam Social, I have 2 solutions
> to inject the same Bean
>
>     @Inject
>     Twitter twitter;
>
> and
>     @Inject
>     @RelatedTo(Service.Twitter)
>     OAuthService twitter;
>
> At the end "twitter" contains an instance of TwitterScribe bean in the 2
> cases.
>
> To achieve that I have to create a producer like this :
>
>     @Produces
>     @RelatedTo(Service.Twitter)
>     protected OAuthService qualifiedTwitterProducer(@New TwitterScribe
> service) {
>         return service;
>     }
>
> in addition of TwitterScribe bean which has the @Default qualifier.
>
> As I'll have to do that for each service and people extending the API will
> also have to provide this straightforward producer for their own service
> bean, I was wondering if there wasn't a more elegant (generic ?) way to
> create a bean responding to @default and another qualifier the same way.
>
> thanks for your feedback on that.
>
>
> Antoine
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> seam-dev mailing list
> seam-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/seam-dev
>
>


-- 
Jason Porter
http://lightguard-jp.blogspot.com
http://twitter.com/lightguardjp

Software Engineer
Open Source Advocate
Author of Seam Catch - Next Generation Java Exception Handling

PGP key id: 926CCFF5
PGP key available at: keyserver.net, pgp.mit.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/seam-dev/attachments/20110523/d908e0c6/attachment-0001.html 


More information about the seam-dev mailing list