Package org.nutz.aop

Examples of org.nutz.aop.ClassAgent.addInterceptor()


        int[] cpub = new int[4];
        int[] cpro = new int[4];
        Arrays.fill(cpub, 0);
        Arrays.fill(cpro, 0);
        ClassAgent aca = getNewClassAgent();
        aca.addInterceptor(MethodMatcherFactory.matcher(PUBLIC), new MethodCounter(cpub));
        aca.addInterceptor(MethodMatcherFactory.matcher(PROTECTED), new MethodCounter(cpro));
        Class<? extends Hippo> c = aca.define(Nutzs.cd(), Hippo.class);// RA.class;
        Hippo r = Mirror.me(c).born();
        Vegetarians.run(r, 78);
        r.doSomething(BEH.run);
View Full Code Here


        int[] cpro = new int[4];
        Arrays.fill(cpub, 0);
        Arrays.fill(cpro, 0);
        ClassAgent aca = getNewClassAgent();
        aca.addInterceptor(MethodMatcherFactory.matcher(PUBLIC), new MethodCounter(cpub));
        aca.addInterceptor(MethodMatcherFactory.matcher(PROTECTED), new MethodCounter(cpro));
        Class<? extends Hippo> c = aca.define(Nutzs.cd(), Hippo.class);// RA.class;
        Hippo r = Mirror.me(c).born();
        Vegetarians.run(r, 78);
        r.doSomething(BEH.run);
        try {
View Full Code Here

        assertEquals("[2, 2, 0, 0]", Json.toJson(cpro));
    }

    public ClassAgent getNewClassAgent() {
        ClassAgent classAgent = new AsmClassAgent();
        classAgent.addInterceptor(MethodMatcherFactory.matcher(".*"), new LoggingMethodInterceptor());
        return classAgent;
    }
}
View Full Code Here

public class Main2 {

    public static void main(String[] args) throws Throwable {

        ClassAgent agent = new AsmClassAgent();
        agent.addInterceptor(MethodMatcherFactory.matcher(".*"), new MyMethodInterceptor());
        Class<Aop1> classZ = agent.define(Nutzs.cd(), Aop1.class);
        System.out.println(classZ);
        Field[] fields = classZ.getDeclaredFields();
        for (Field field : fields) {
            System.out.println("找到一个Field: " + field);
View Full Code Here

                }
            }
            // 生成Aop化的类
            ClassAgent agent = new AsmClassAgent();
            for (InterceptorPair interceptorPair : interceptorPairs)
                agent.addInterceptor(interceptorPair.getMethodMatcher(),
                                     interceptorPair.getMethodInterceptor());
            Class lazyClass = agent.define(DefaultClassDefiner.defaultOne(), type);

            // 检查对象的创建方法
            BornContext<T> bc = Borns.evalByArgTypes(type, ResultSet.class);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.