package org.theonefx.wcframework.mvc; import java.lang.reflect.Method; import org.theonefx.wcframework.core.BeanDefinitionRegistry; import org.theonefx.wcframework.core.ClassParseContext; import org.theonefx.wcframework.core.ClassParser; import org.theonefx.wcframework.core.ClassWrapper; import org.theonefx.wcframework.ioc.RootBeanDefinition; import org.theonefx.wcframework.mvc.annotation.Action; import org.theonefx.wcframework.mvc.annotation.Controller; import org.theonefx.wcframework.mvc.annotation.Filter; import org.theonefx.wcframework.mvc.wcweb.ControllerRegister; public class MVCClassParser implements ClassParser { @Override public void parse(ClassWrapper<?> wrapper, BeanDefinitionRegistry registry, ClassParseContext context) { RootBeanDefinition definition = context.getDefinition(); if (definition != null) { ControllerRegister register = (ControllerRegister) registry.getObject(WebApplicationContext.CONTROLLER_REGISTRY_NAME); if (register == null) { return; } Method[] methods = wrapper.getMethods(); Controller controller = wrapper.getAnnotation(Controller.class); for (Method method : methods) { Action actionAnno = method.getAnnotation(Action.class); if (actionAnno != null) { register.registAction(method, actionAnno, wrapper, context.getId(), controller); } } Filter filterAnno = wrapper.getAnnotation(Filter.class); if (filterAnno != null) { register.registFilter(filterAnno, wrapper, context.getId()); } } } }