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.

TraceJoinPointsBase.java 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* *******************************************************************
  2. * Copyright (c) 2005 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. * Wes Isberg initial implementation
  11. * ******************************************************************/
  12. // START-SAMPLE tracing-traceJoinPoints Trace join points executed
  13. package org.aspectj.lib.tracing;
  14. import org.aspectj.lang.JoinPoint;
  15. /**
  16. * Trace join points being executed in context.
  17. * To use this, define the abstract members in a subaspect.
  18. * <b>Warning</b>: this does not trace join points that do not
  19. * support after advice.
  20. * @author Jim Hugunin, Wes Isberg
  21. */
  22. abstract aspect TraceJoinPointsBase {
  23. declare precedence : TraceJoinPointsBase, *;
  24. abstract protected pointcut entry();
  25. /** ignore join points outside this scope - use within(..) */
  26. abstract protected pointcut withinScope();
  27. protected pointcut exit(): withinScope() && call(* java..*.*(..));
  28. final pointcut start(): withinScope() && entry() && !cflowbelow(entry());
  29. final pointcut trace(): withinScope() && cflow(entry())
  30. && !cflowbelow(exit()) && !within(TraceJoinPointsBase+);
  31. private pointcut supportsAfterAdvice() : !handler(*)
  32. && !preinitialization(new(..));
  33. before(): start() { startLog(); }
  34. before(): trace() && supportsAfterAdvice(){
  35. logEnter(thisJoinPointStaticPart);
  36. }
  37. after(): trace() && supportsAfterAdvice() {
  38. logExit(thisJoinPointStaticPart);
  39. }
  40. after(): start() { completeLog(); }
  41. abstract protected void logEnter(JoinPoint.StaticPart jp);
  42. abstract protected void logExit(JoinPoint.StaticPart jp);
  43. /** called before any logging */
  44. abstract protected void startLog();
  45. /** called after any logging */
  46. abstract protected void completeLog();
  47. }
  48. // END-SAMPLE tracing-traceJoinPoints