[seam-dev] @Injecting the same bean with different @Qualifier
Antoine Sabot-Durand
antoine at sabot-durand.net
Mon May 23 17:05:36 EDT 2011
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/seam-dev/attachments/20110523/d500c5f5/attachment.html
More information about the seam-dev
mailing list