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.

TraceMyClasses.java 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. Copyright (c) Xerox Corporation 1998-2002. All rights reserved.
  3. Use and copying of this software and preparation of derivative works based
  4. upon this software are permitted. Any distribution of this software or
  5. derivative works must comply with all applicable United States export control
  6. laws.
  7. This software is made available AS IS, and Xerox Corporation makes no warranty
  8. about the software, its performance or its conformity to any specification.
  9. |<--- this code is formatted to fit into 80 columns --->|
  10. |<--- this code is formatted to fit into 80 columns --->|
  11. |<--- this code is formatted to fit into 80 columns --->|
  12. */
  13. package tracing.lib;
  14. import tracing.TwoDShape;
  15. import tracing.Circle;
  16. import tracing.Square;
  17. import tracing.ExampleMain;
  18. import java.io.FileOutputStream;
  19. import java.io.PrintStream;
  20. import java.io.FileNotFoundException;
  21. aspect TraceMyClasses extends AbstractTrace {
  22. /**
  23. * The application classes
  24. */
  25. pointcut classes(): within(TwoDShape) || within(Circle) || within(Square);
  26. /**
  27. * The constructors in those classes - but only the ones with 3
  28. * arguments.
  29. */
  30. pointcut constructors(): execution(new(double, double, double));
  31. /**
  32. * This specifies all the message executions.
  33. */
  34. pointcut methods(): execution(* *(..));
  35. /**
  36. * A main function for testing the trace aspect.
  37. */
  38. public static void main(String[] _args) {
  39. final String[] args = _args;
  40. new Thread() {
  41. public void run() {
  42. TraceMyClasses.aspectOf().initStream(System.err);
  43. ExampleMain.main(args);
  44. }
  45. }.start();
  46. new Thread() {
  47. public void run() {
  48. try {
  49. TraceMyClasses.aspectOf().initStream(new PrintStream(new FileOutputStream("AJTRACETEST")));
  50. }
  51. catch (FileNotFoundException e) {}
  52. ExampleMain.main(args);
  53. }
  54. }.start();
  55. }
  56. }