Question

It's clear to me how to inject an object which is in my domain (I have access to the source) using Weld. You just annotate the implementation with e.g. @Named and @ApplicationScoped, and then annotate the target attribute with @Inject to get the implementation injected.

However, not sure how can I inject implementations of classes which I don't have access to its source code. For example, I am using Dozer. Dozer mapper is programmed against an interface (Mapper) and I want Weld to inject the implementation (DozerBeanMapper), but since I don't have access to the source cause I am using a .jar dependency, I cannot annotate it.

Any ideas on how to achieve this?

Was it helpful?

Solution

Annotations embedded within POJOs is the internal configuration. Internal configuration and 3rd party components don't mix. External configuration(such as beans.xml) is the only way. You should check the document of Weld for external configuration.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top