The @PostConstruct callback is only invoked once but the constructor will never be invoked only once. First of all, Weld will always invoke the constructor for a client proxy. Moreover, WildFly integration code may invoke component class constructor for a no-interface view - see also org.jboss.as.ee.component.ViewService.View.createInstance(Map<Object, Object>). Given that org.jboss.as.weld.ejb.SessionObjectReferenceImpl does not cache the component view, the constructor is called for every SB invocation. This is not good from the performance point of view but that's a different issue.
I don't think we should test the number of constructor invocations but the component contract instead - i.e. number of @PostConstruct invocations and the component state. WDYT?
|