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.staticfield; 9 10 import org.codehaus.aspectwerkz.definition.Pointcut; 11 import org.codehaus.aspectwerkz.joinpoint.JoinPoint; 12 13 /*** 14 * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a> 15 * @Aspect 16 */ 17 public class TestAspect { 18 /*** 19 * @Expression set(* test.staticfield.StaticFieldAdviceTest.s_field*) 20 */ 21 Pointcut pcSet; 22 23 /*** 24 * @Expression set(* test.staticfield.StaticFieldAdviceTest.m_field*) 25 */ 26 Pointcut pcSetMember; 27 28 /*** 29 * @Expression set(* test.staticfield.CollectionFieldTest.s_field) 30 */ 31 Pointcut pcSetColl; 32 33 /*** 34 * @Expression set(* test.staticfield.CollectionFieldTest.m_field) 35 */ 36 Pointcut pcSetMemberColl; 37 38 /*** 39 * @Expression get(* test.staticfield.CollectionFieldTest.s_field) 40 */ 41 Pointcut pcGetColl; 42 43 /*** 44 * @Expression get(* test.staticfield.CollectionFieldTest.m_field) 45 */ 46 Pointcut pcGetMemberColl; 47 48 /*** 49 * @Expression within(test.staticfield.*) 50 */ 51 Pointcut filter; 52 53 /*** 54 * @Before pcSet && filter 55 */ 56 public void preStaticField(final JoinPoint joinPoint) throws Throwable { 57 CollectionFieldTest.s_log += "MyPreAdvice1 "; 58 } 59 60 /*** 61 * @Before pcSetMember && filter 62 */ 63 public void preMemberField1(final JoinPoint joinPoint) throws Throwable { 64 CollectionFieldTest.s_log += "MyPreAdvice2 "; 65 } 66 67 /*** 68 * @Before pcSetColl && filter 69 */ 70 public void preStaticField2(final JoinPoint joinPoint) throws Throwable { 71 CollectionFieldTest.s_log += "MyPreAdvice1 "; 72 } 73 74 /*** 75 * @Before pcSetMemberColl && filter 76 */ 77 public void preMemberField2(final JoinPoint joinPoint) throws Throwable { 78 CollectionFieldTest.s_log += "MyPreAdvice2 "; 79 } 80 81 /*** 82 * @After pcGetColl && filter 83 */ 84 public void postStaticField(final JoinPoint joinPoint) throws Throwable { 85 CollectionFieldTest.s_log += "MyPostAdvice1 "; 86 } 87 88 /*** 89 * @After pcGetMemberColl && filter 90 */ 91 public void postMemberField(final JoinPoint joinPoint) throws Throwable { 92 CollectionFieldTest.s_log += "MyPostAdvice2 "; 93 } 94 }