You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CounterAspect.java 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* *******************************************************************
  2. * Copyright (c) 2008 Contributors.
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * Andy Clement initial implementation
  11. * ******************************************************************/
  12. import org.aspectj.lang.annotation.Aspect;
  13. import org.aspectj.lang.annotation.Before;
  14. import org.aspectj.lang.annotation.Pointcut;
  15. /**
  16. * Created to enable PointcutDesignatorHandlerTests.testParsingBeanInReferencePointcut01 and 02 to run
  17. *
  18. * @author Andy Clement
  19. */
  20. @Aspect
  21. public class CounterAspect {
  22. int count;
  23. @Before("execution(* set*(..)) && bean(testBean1)")
  24. public void increment1ForAnonymousPointcut() {
  25. count++;
  26. }
  27. @Pointcut("execution(* toString(..)) && bean(testBean1)")
  28. public void testBean1toString() {
  29. }
  30. @Pointcut("execution(* setAge(..)) && bean(testBean1)")
  31. public void testBean1SetAge() {
  32. }
  33. @Pointcut("execution(* setAge(..)) && bean(testBean2)")
  34. public void testBean2SetAge() {
  35. }
  36. @Before("testBean1SetAge()")
  37. public void increment1() {
  38. count++;
  39. }
  40. @Before("testBean2SetAge()")
  41. public void increment2() {
  42. count++;
  43. }
  44. }