AresFramework - AresFramework,实现 IOC、AOP 和 MVC 框架


Apache
跨平台
Java

软件简介

AresFramework,支持IOC、AOP、MVC功能:

  • IOC:支持Component、Resource、Scope注解,按名-按类型方式注入;

  • AOP:支持Aspect、Pointcut、Order注解,使用JDK动态代理,支持切面排序;

  • MVC:支持Controller、RequestMapping、ResponseData注解,支持普通参数,String数组注入,支持JSP、JSON视图解析。

软件核心类:

  • ResolverLoader、BeanFactory、FactoryBean、Dispatcher、HandlerAdapter、ViewResolver。

代码示例

@Component("Aop")
public class AopImpl implements Aop {

    @Resource
    private IocComponent ic;

    public void aopTest() {
        System.out.println("invoke");
    }

}


@Aspect
@Order(1)
public class AopInterceptor extends AbstractHandlerInterceptor {

    @Override
    @Pointcut("frame.test.Aop.aopTest")
    public void invokeBefore(Object target, Method method, Object[] args) {
        System.out.println("before " + "target " + target.toString() + " method " + method.toString() + " args " + args);
    }

    @Override
    @Pointcut("frame.test.Aop.aopTest")
    public void invokeAfter(Object target, Method method, Object[] args) {
        System.out.println("after " + "target " + target.toString() + " method " + method.toString() + " args " + args);
    }

}


@Controller("/simple")
public class SimpleAction {

    @ResponseData("JSON")
    @RequestMapping("/json.do")
    public String getJson(int id, String name) {
        return "{" + id + ", " +name +"}";
    }

    @RequestMapping("/jsp.do")
    @ResponseData("JSP")
    @ResponseMapping("/WEB-INF/jsp/hello")
    public String getJsp(int id, String name) {
        return "{" + id + ", " +name +"}";
    }

    @RequestMapping("/jsp2.do")
    @ResponseData("JSP")
    public String getJsp2(int id, String name) {
        return "/WEB-INF/jsp/hello";
    }

}