Arquillian and CDI
-
18-06-2021 - |
Question
I'm reading the Arquillian Reference Guide which is very well written, however in the chapter that talks about setting up dependency injection I can't find where you actually specify the beans/bindings.
Most of the Arquillian CDI code examples show the use of Java's @Inject
annotation. So I'm just wondering, where I define these beans/DI mappings/bindings, and how do I configure Arquillian to use them?
In Spring DI, you specify a bean descriptor, like spring-config.xml
. In Guice you implement a Module
and define its configure(Binder)
method. What does this look like in Arquillian-land when using javax.inject.Inject
? Thanks in advance.
Solution
The short answer - there is no need to define bean mappings in CDI, because CDI works with annotations exclusively. You can add extra information in config-files, but this is usually not required.
The long answer is best taken from this excellent introduction into CDI.
OTHER TIPS
I think you need to use "Alternatives" CDI mechanism
Alternatives are beans whose implementation is specific to a particular client module or deployment scenario.