Hi - Here is a problem that I observed while developing some code that supports control callback dispatching.
[Background] In ControlBean.ensureControl(), we lazily initializes the control impl, including getImplInitializer().initServices(), which will inject @Context fields (for ResourceContext and ControlBeanContext). This is done properly for a ControlMethod call (through preInvoke and invoke listeners); I don't think this is done properly for a Control callback - I'm dispatching the callback event using ControlContainerContext.dispatchEvent (). [Problem] When we dispatch a callback event for a control, since there are no control method calls involved, the ensureControl() stuff is *not* called and certain things are therefore not initialized. In addition, when this control is nested (inside of another control impl), we need to ensure control for all the nesting parent control beans so the containing impl is initialized correctly. This problem can be demonstrated by writing a control A whose impl uses another control (B); A's impl also has an event handler for an event set of B. From this event handler, if you accessed @Context fields that is declared in A impl, you would get a NullPointerException due to initialization not performed properly for A. [Solution] The solution could come from ControlContainerContext.dispatchEvent() where it pre-performs the ensureControl() step for the bean that is dispatching callback to; we have to do this for all its parents. Note that calling control methods from these callback handlers is fine as those invocations go through ensureControl(). Is my observation correct? If so I can probably create a JIRA issue and submit a patch for this. Thanks - Xibin
