1 /*************************************************************************************** 2 * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. * 3 * http://aspectwerkz.codehaus.org * 4 * ---------------------------------------------------------------------------------- * 5 * The software in this package is published under the terms of the LGPL license * 6 * a copy of which has been included with this distribution in the license.txt file. * 7 **************************************************************************************/ 8 package test.customproceed; 9 10 import org.codehaus.aspectwerkz.joinpoint.JoinPoint; 11 import org.codehaus.aspectwerkz.joinpoint.StaticJoinPoint; 12 13 /*** 14 * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a> 15 */ 16 public class MyAspect { 17 18 public static interface ProceedWithIntArg extends JoinPoint { 19 Object proceed(int i); 20 } 21 22 public static interface ProceedWithLongArg extends StaticJoinPoint { 23 Object proceed(long l); 24 } 25 26 public static interface ProceedWithStringArg extends JoinPoint { 27 Object proceed(String s); 28 } 29 30 public static interface ProceedWithMiscArgs1 extends StaticJoinPoint { 31 Object proceed(long i, String s); 32 } 33 34 public static interface ProceedWithMiscArgs2 extends StaticJoinPoint { 35 Object proceed(long i, String s, int[][] matrix); 36 } 37 38 /*** 39 * @Around execution(* test.customproceed.CustomProceedTest.setInt(int)) && args(i) 40 */ 41 public Object around1(ProceedWithIntArg jp, int i) { 42 CustomProceedTest.log("around1 "); 43 CustomProceedTest.log(new Integer(i).toString()); 44 CustomProceedTest.log(" "); 45 return jp.proceed(1); 46 } 47 48 49 /*** 50 * @Around execution(* test.customproceed.CustomProceedTest.setLong(long)) && args(l) 51 */ 52 public Object around2(ProceedWithLongArg jp, long l) { 53 CustomProceedTest.log("around2 "); 54 CustomProceedTest.log(new Long(l).toString()); 55 CustomProceedTest.log(" "); 56 return jp.proceed(2); 57 } 58 59 /*** 60 * @Around execution(* test.customproceed.CustomProceedTest.setString(String)) && args(s) 61 */ 62 public Object around3(ProceedWithStringArg jp, String s) { 63 CustomProceedTest.log("around3 "); 64 CustomProceedTest.log(s); 65 CustomProceedTest.log(" "); 66 return jp.proceed("gnitset"); 67 } 68 69 /*** 70 * Around execution(* test.customproceed.CustomProceedTest.setMisc1(..)) && args(l, s) 71 * 72 * @Around execution(* test.customproceed.CustomProceedTest.setMisc1(long, String)) && args(l, s) 73 */ 74 public Object around4(ProceedWithMiscArgs1 jp, long l, String s) { 75 CustomProceedTest.log("around4 "); 76 CustomProceedTest.log(new Long(l).toString()); 77 CustomProceedTest.log(" "); 78 CustomProceedTest.log(s); 79 CustomProceedTest.log(" "); 80 return jp.proceed(12345, "gnitset"); 81 } 82 83 /*** 84 * @Around execution(* test.customproceed.CustomProceedTest.setMisc2(long, String, int[][])) && args(l, s, matrix) 85 */ 86 public Object around5(ProceedWithMiscArgs2 jp, long l, String s, int[][] matrix) { 87 CustomProceedTest.log("around5 "); 88 CustomProceedTest.log(new Long(l).toString()); 89 CustomProceedTest.log(" "); 90 CustomProceedTest.log(s); 91 CustomProceedTest.log(" "); 92 CustomProceedTest.log(new Integer(matrix[0][0]).toString()); 93 CustomProceedTest.log(" "); 94 matrix[0][0] = 123; 95 return jp.proceed(12345, "gnitset", matrix); 96 } 97 }