/** * Recursively scans the controller's class and superclasses for {@literal @EventHandler} * -annotated methods. * * @param instance Controller to be wired. * @param root The root component used to resolve component names. */ public static void wire(Object instance, BaseComponent root) { Class<?> clazz = instance.getClass(); while (clazz != Object.class) { wire(instance, root, clazz); clazz = clazz.getSuperclass(); } }
public BaseComponent() { componentDefinition = ComponentRegistry.getInstance().get(getClass()); namespace = this instanceof INamespace; EventHandlerScanner.wire(this, this); }
/** * Wires a controller's annotated components and event handlers, using this component to resolve * name references. * * @param controller The controller to wire. If a string, is assumed to be the name of the * controller's implementation class in which case an instance of that class is * created. */ @PropertySetter(value = "controller", defer = true) public void wireController(Object controller) { if (controller == null) { throw new ComponentException("Controller is null or could not be resolved."); } if (controller instanceof String) { try { controller = "self".equals(controller) ? this : Class.forName((String) controller).newInstance(); } catch (Exception e) { throw MiscUtil.toUnchecked(e); } } WiredComponentScanner.wire(controller, this); EventHandlerScanner.wire(controller, this); if (controller instanceof IAutoWired) { ((IAutoWired) controller).afterInitialized(this); } }