FroMage / redpipe

Redpipe Web Framework
Apache License 2.0
70 stars 10 forks source link

redpipe-cdi module #12

Closed fiorenzino closed 6 years ago

fiorenzino commented 6 years ago

Should be usefull a cdi producer like:

public class AppGlobalsProducer {

@Produces
public EventBus bus() {
    return AppGlobals.get().getVertx().eventBus();
}

@Produces
public Vertx vertx() {
    return AppGlobals.get().getVertx();
}

@Produces
public JsonObject config() {
    return AppGlobals.get().getConfig();
}

}

To inject:

@Inject EventBus eventBus;

@Inject
Vertx vertx;

@Inject
JsonObject config;
FroMage commented 6 years ago

Very good idea!

fiorenzino commented 6 years ago

I tried to move the AppGlobalsProducer class in the redpipe-cdi module, but weld ignore this and i have this error in the class where inject vertx or eventbus.

Have you an idea to activate the AppGlobalsProducer?

The error: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type EventBus with qualifiers @Default at injection point [UnbackedAnnotatedField] @Inject net.redpipe.example.cdi.helloworld.HelloResource.eventBus at net.redpipe.example.cdi.helloworld.HelloResource.eventBus(HelloResource.java:0)

at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:362)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:284)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:137)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:158)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:501)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:61)
at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:59)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:62)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:55)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
FroMage commented 6 years ago

I'll try to reproduce.

FroMage commented 6 years ago

Worked for me, added code very similar to yours, thanks a lot.