How to force use the CDI creation method?

Part of my problem here is using the correct dictionary, so I apologize in advance for what might be simple terminology.

Suppose I have an interface Personand a class PersonBeanthat implements this interface.

Suppose I have a producer method somewhere (annotated @Produces) that returns Person. Inside, he returns a new one PersonBean, but neither here nor there.

Finally, suppose I have another CDI bean somewhere with an injection point defined as follows:

@Inject
private Person person;

Assuming I have all my files beans.xml, etc., and downloaded Weld or another CDI-1.0 compatible environment, as all of this means that I will get an ambiguous definition error. It makes sense: Weld will find mine PersonBeanas an injection candidate (he can just call the constructor) and find the output of my producer method as an injection candidate.

What I would like to do is somehow make the instances Personin this application always route through the manufacturer's method.

, - - Person, . , , , , ( , ), .

, . ( , , .) ? ? , @Typed(Object.class) PersonBean, , Person CDI....

, . .

+5
3

, , @Typed Object.class bean. , , :

@Inject
private Object something;

... , , .: -)

+2

PersonBean @Alternative, .

+3

, , - - .

.

I am not 100% sure how this will develop when merging Seam 3 and Deltaspike (the page is 90 seconds, but the content is rocky :-), but giving Solder in your class path is certainly a safe bet.

Oh, and as far as I know, a comparable mechanism fell into the CDI 1.1 specification.

+1
source

All Articles