01: /**************************************************************************************
02: * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
03: * http://aspectwerkz.codehaus.org *
04: * ---------------------------------------------------------------------------------- *
05: * The software in this package is published under the terms of the LGPL license *
06: * a copy of which has been included with this distribution in the license.txt file. *
07: **************************************************************************************/package test.customproceed;
08:
09: import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
10: import org.codehaus.aspectwerkz.joinpoint.StaticJoinPoint;
11:
12: /**
13: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
14: */
15: public class MyAspect {
16:
17: public static interface ProceedWithIntArg extends JoinPoint {
18: Object proceed(int i);
19: }
20:
21: public static interface ProceedWithLongArg extends StaticJoinPoint {
22: Object proceed(long l);
23: }
24:
25: public static interface ProceedWithStringArg extends JoinPoint {
26: Object proceed(String s);
27: }
28:
29: public static interface ProceedWithMiscArgs1 extends
30: StaticJoinPoint {
31: Object proceed(long i, String s);
32: }
33:
34: public static interface ProceedWithMiscArgs2 extends
35: StaticJoinPoint {
36: Object proceed(long i, String s, int[][] matrix);
37: }
38:
39: /**
40: * @Around execution(* test.customproceed.CustomProceedTest.setInt(int)) && args(i)
41: */
42: public Object around1(ProceedWithIntArg jp, int i) {
43: CustomProceedTest.log("around1 ");
44: CustomProceedTest.log(new Integer(i).toString());
45: CustomProceedTest.log(" ");
46: return jp.proceed(1);
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,
87: int[][] matrix) {
88: CustomProceedTest.log("around5 ");
89: CustomProceedTest.log(new Long(l).toString());
90: CustomProceedTest.log(" ");
91: CustomProceedTest.log(s);
92: CustomProceedTest.log(" ");
93: CustomProceedTest.log(new Integer(matrix[0][0]).toString());
94: CustomProceedTest.log(" ");
95: matrix[0][0] = 123;
96: return jp.proceed(12345, "gnitset", matrix);
97: }
98: }
|