Package org.nutz.aop.javassist.lstn

Examples of org.nutz.aop.javassist.lstn.MethodCounter


  @Test
  public void test_duplicate_class_exception() throws Exception {
    int[] cc = new int[4];
    ClassAgent ca = getNewClassAgent();
    ca.addInterceptor(MethodMatcherFactory.matcher(".*"), new MethodCounter(cc));
    ClassAgent ca2 = getNewClassAgent();
    ca2.addInterceptor(MethodMatcherFactory.matcher(".*"), new MethodCounter(cc));

    ClassDefiner cd = Nutzs.cd();

    Class<? extends Moose> c = ca.define(cd, Moose.class);
    Moose m = c.newInstance();
View Full Code Here


  @Test
  public void test_return_array_method() {
    int[] cc = new int[4];
    Arrays.fill(cc, 0);
    ClassAgent aca = getNewClassAgent();
    aca.addInterceptor(MethodMatcherFactory.matcher("returnArrayMethod"), new MethodCounter(cc));
    Class<? extends Buffalo> c = aca.define(Nutzs.cd(), Buffalo.class);// RA.class;
    Buffalo r = Mirror.me(c).born();
    String[] ss = r.returnArrayMethod();
    assertEquals("[1, 1, 0, 0]", Json.toJson(cc));
    assertEquals(3, ss.length);
View Full Code Here

    int[] cc = new int[4];
    int[] crun = new int[4];
    Arrays.fill(cc, 0);
    Arrays.fill(crun, 0);
    ClassAgent aca = getNewClassAgent();
    aca.addInterceptor(MethodMatcherFactory.matcher("run"), new MethodCounter(crun));
    aca.addInterceptor(MethodMatcherFactory.matcher(".*"), new MethodCounter(cc));
    aca.addInterceptor(MethodMatcherFactory.matcher("doSomething"), new RhinocerosListener());
    Class<? extends Rhinoceros> c = aca.define(Nutzs.cd(), Rhinoceros.class);// RA.class;
    Rhinoceros r = Mirror.me(c).born();
    r.doSomething(BEH.run);
    r.doSomething(BEH.fight);
View Full Code Here

    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);
    try {
View Full Code Here

    @Test
    public void test_duplicate_class_exception() throws Exception {
        int[] cc = new int[4];
        ClassAgent ca = getNewClassAgent();
        ca.addInterceptor(MethodMatcherFactory.matcher(".*"), new MethodCounter(cc));
        ClassAgent ca2 = getNewClassAgent();
        ca2.addInterceptor(MethodMatcherFactory.matcher(".*"), new MethodCounter(cc));

        ClassDefiner cd = Nutzs.cd();

        Class<? extends Moose> c = ca.define(cd, Moose.class);
        Moose m = c.newInstance();
View Full Code Here

    @Test
    public void test_return_array_method() {
        int[] cc = new int[4];
        Arrays.fill(cc, 0);
        ClassAgent aca = getNewClassAgent();
        aca.addInterceptor(MethodMatcherFactory.matcher("returnArrayMethod"), new MethodCounter(cc));
        Class<? extends Buffalo> c = aca.define(Nutzs.cd(), Buffalo.class);// RA.class;
        Buffalo r = Mirror.me(c).born();
        String[] ss = r.returnArrayMethod();
        assertEquals("[1, 1, 0, 0]", Json.toJson(cc));
        assertEquals(3, ss.length);
View Full Code Here

        int[] cc = new int[4];
        int[] crun = new int[4];
        Arrays.fill(cc, 0);
        Arrays.fill(crun, 0);
        ClassAgent aca = getNewClassAgent();
        aca.addInterceptor(MethodMatcherFactory.matcher("run"), new MethodCounter(crun));
        aca.addInterceptor(MethodMatcherFactory.matcher(".*"), new MethodCounter(cc));
        aca.addInterceptor(MethodMatcherFactory.matcher("doSomething"), new RhinocerosListener());
        Class<? extends Rhinoceros> c = aca.define(Nutzs.cd(), Rhinoceros.class);// RA.class;
        Rhinoceros r = Mirror.me(c).born();
        r.doSomething(BEH.run);
        r.doSomething(BEH.fight);
View Full Code Here

        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);
        try {
View Full Code Here

TOP

Related Classes of org.nutz.aop.javassist.lstn.MethodCounter

Copyright © 2018 www.massapicom. 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.