|
Given:
@Named
@RequestScoped
public class TestController {
@Inject
private Event<String> event;
@PostConstruct
void init() {
event.fire("hello");
}
void onEvent(@Observes String event) {
System.out.println(event);
}
public void test() {
event.fire("world");
}
}
Initializing a TestController e.g. by invoking TestController.test() or reference some of it's properties will cause:
I assume beans not having finished their initialization lifecycle won't be available via their context, so any invocation of these beans will lead to the creation of another one. The CDI spec is unfortunately rather vague on availability of beans during creation.
I am using CDI events to break up circular dependencies between beans.Unfortunately I am not able to invoke anything from @PostConstruct initializers,if the invocation is directly (e.g. via method call on dependent bean) or indirectly (e.g. via eventing) calling the bean in in creation back.
|