Is it possible to use the CDI manufacturing method defined in module A to insert the CDI into the bean in the second module B?
Is there any description of the relationship between CDI and the JBoss module system?
In the manufacturer.jar file:
import javax.enterprise.inject.Produces; import javax.enterprise.inject.spi.InjectionPoint; import java.util.logging.Logger; public class Producer { @Produces public static Logger produceLog(InjectionPoint injectionPoint) { return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName()); } }
In consumer.war:
import javax.inject.Inject; import java.util.logging.Logger; public class Consumer { @Inject Logger logger; public void doLog() { logger.info("Hello CDI with JBoss Modules"); } }
module B has a manifest dependency on module A:
Manifest-Version: 1.0 Dependencies: deployment.producer.jar
this approach leads to the unmet problem of weld dependency:
"JBAS014671: Failed services" => {"jboss.deployment.unit.\"consumer.war\".WeldService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"consumer.war\".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Logger] with qualifiers [@Default] at injection point [[field] @Inject question.Consumer.logger]"
I posted a sample project on Github: https://github.com/sistar/jboss-cdi-demo
Tia Ralf
source share