Weld CDI: how to make one bean class satisfy any of multiple qualifiers?

As I said in my comment there is no straight way to have an OR relation when you have two or more qualifiers on a bean class.

As I said in my comment there is no straight way to have an OR relation when you have two or more qualifiers on a bean class. So the solution to have the same Bean with another qualifier is to use the Producer mechanism. In your example you can create you first class as usual : @JobBinding(JobType.

JOB_X) public class JobABuilder implements JobBuilder { .... } and after that create a producer method in either in the first class or in a dedicated producers class like that public class MoreJobsProducer { @Produces @JobBinding(JobType. JOB_Y) protected JobBuilder prodJobYBuilder(@New @JobBinding(JobType. JOB_X) JobBuilder theJob) { return theJob; } } In the paramaters of the producer method you Inject your former bean with its own qualifier and the @Newqualifier which create a new instance of the bean to be sure you avoid some scoping issues (read the Weld doc for more info).

It should do the "Job".

Ahhh - thanks Antoine, cunning! Great idea. I can see that it would work if you did @Inject @JobBinding(JobTYpe.

JOB_Y) JobBuilder myYJobBuilder;, but I'm not sure about builderSource. Select(new JobBindingQualifier(JobType. JOB_Y).get(); - does the Instance stuff use Producers as well, or would it still be expecting an actual annotated class...? I'll give it a go and find out, anyway - thanks a lot!

– Ben Kirby Nov 1 at 10:43 It works. I use it in Seam Social to allow inject of Twitter services and associated settings in two ways. If you have issues let me know – Antoine Sabot-Durand Nov 1 at 12:47.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions