aboutsummaryrefslogtreecommitdiffstats
path: root/docs/modules/ROOT/pages/examples/tracing/version3
diff options
context:
space:
mode:
authorAlexander Kriegisch <Alexander@Kriegisch.name>2024-02-01 08:57:52 +0700
committerAlexander Kriegisch <Alexander@Kriegisch.name>2024-02-01 08:58:28 +0700
commit983159c76ca8163b61f0d52c98522e8bc113f585 (patch)
tree3137bb04a0942b59d7b066912a2fa8fed5601373 /docs/modules/ROOT/pages/examples/tracing/version3
parentc99b58736fd7f2952fe9bf787333631a762dcbeb (diff)
downloadaspectj-antora.tar.gz
aspectj-antora.zip
Move source code examples to Antora examples directoryantora
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'docs/modules/ROOT/pages/examples/tracing/version3')
-rw-r--r--docs/modules/ROOT/pages/examples/tracing/version3/Trace.java123
-rw-r--r--docs/modules/ROOT/pages/examples/tracing/version3/TraceMyClasses.java46
2 files changed, 0 insertions, 169 deletions
diff --git a/docs/modules/ROOT/pages/examples/tracing/version3/Trace.java b/docs/modules/ROOT/pages/examples/tracing/version3/Trace.java
deleted file mode 100644
index 8fc9d8613..000000000
--- a/docs/modules/ROOT/pages/examples/tracing/version3/Trace.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
-
-Copyright (c) Xerox Corporation 1998-2002. All rights reserved.
-
-Use and copying of this software and preparation of derivative works based
-upon this software are permitted. Any distribution of this software or
-derivative works must comply with all applicable United States export control
-laws.
-
-This software is made available AS IS, and Xerox Corporation makes no warranty
-about the software, its performance or its conformity to any specification.
-
-|<--- this code is formatted to fit into 80 columns --->|
-|<--- this code is formatted to fit into 80 columns --->|
-|<--- this code is formatted to fit into 80 columns --->|
-
-*/
-
-package tracing.version3;
-
-import java.io.PrintStream;
-
-/**
- *
- * This class provides support for printing trace messages into a stream.
- * Trace messages are printed before and after constructors and methods
- * are executed.
- * The messages are appended with the string representation of the objects
- * whose constructors and methods are being traced.
- * It defines one abstract pointcut for injecting that tracing functionality
- * into any application classes.
- *
- */
-abstract aspect Trace {
-
- /*
- * Functional part
- */
-
- /**
- * There are 3 trace levels (values of TRACELEVEL):
- * 0 - No messages are printed
- * 1 - Trace messages are printed, but there is no indentation
- * according to the call stack
- * 2 - Trace messages are printed, and they are indented
- * according to the call stack
- */
- public static int TRACELEVEL = 0;
- protected static PrintStream stream = null;
- protected static int callDepth = 0;
-
- /**
- * Initialization.
- */
- public static void initStream(PrintStream s) {
- stream = s;
- }
-
- protected static void traceEntry(String str, Object o) {
- if (TRACELEVEL == 0) return;
- if (TRACELEVEL == 2) callDepth++;
- printEntering(str + ": " + o.toString());
- }
-
- protected static void traceExit(String str, Object o) {
- if (TRACELEVEL == 0) return;
- printExiting(str + ": " + o.toString());
- if (TRACELEVEL == 2) callDepth--;
- }
-
- private static void printEntering(String str) {
- printIndent();
- stream.println("--> " + str);
- }
-
- private static void printExiting(String str) {
- printIndent();
- stream.println("<-- " + str);
- }
-
-
- private static void printIndent() {
- for (int i = 0; i < callDepth; i++)
- stream.print(" ");
- }
-
-
- /*
- * Crosscut part
- */
-
- /**
- * Application classes - left unspecified.
- */
- abstract pointcut myClass(Object obj);
- /**
- * The constructors in those classes.
- */
- pointcut myConstructor(Object obj): myClass(obj) && execution(new(..));
- /**
- * The methods of those classes.
- */
- // toString is called from within our advice, so we shouldn't
- // advise its executions. But if toString is overridden, even
- // this might not be enough, so we might want
- // && !cflow(execution(String toString()))
- pointcut myMethod(Object obj): myClass(obj) &&
- execution(* *(..)) && !execution(String toString());
-
- before(Object obj): myConstructor(obj) {
- traceEntry("" + thisJoinPointStaticPart.getSignature(), obj);
- }
- after(Object obj): myConstructor(obj) {
- traceExit("" + thisJoinPointStaticPart.getSignature(), obj);
- }
-
- before(Object obj): myMethod(obj) {
- traceEntry("" + thisJoinPointStaticPart.getSignature(), obj);
- }
- after(Object obj): myMethod(obj) {
- traceExit("" + thisJoinPointStaticPart.getSignature(), obj);
- }
-}
diff --git a/docs/modules/ROOT/pages/examples/tracing/version3/TraceMyClasses.java b/docs/modules/ROOT/pages/examples/tracing/version3/TraceMyClasses.java
deleted file mode 100644
index c986d2615..000000000
--- a/docs/modules/ROOT/pages/examples/tracing/version3/TraceMyClasses.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-
-Copyright (c) Xerox Corporation 1998-2002. All rights reserved.
-
-Use and copying of this software and preparation of derivative works based
-upon this software are permitted. Any distribution of this software or
-derivative works must comply with all applicable United States export control
-laws.
-
-This software is made available AS IS, and Xerox Corporation makes no warranty
-about the software, its performance or its conformity to any specification.
-
-|<--- this code is formatted to fit into 80 columns --->|
-|<--- this code is formatted to fit into 80 columns --->|
-|<--- this code is formatted to fit into 80 columns --->|
-
-*/
-
-package tracing.version3;
-
-import tracing.TwoDShape;
-import tracing.Circle;
-import tracing.Square;
-import tracing.ExampleMain;
-
-/**
- *
- * This class concretizes the abstract crosscut in Trace,
- * applying the trace facility to these application classes.
- *
- */
-public aspect TraceMyClasses extends Trace {
- pointcut myClass(Object obj):
- this(obj) &&
- (within(TwoDShape) || within(Circle) || within(Square));
-
- /**
- * A main function for testing the trace aspect.
- */
- public static void main(String[] args) {
- Trace.TRACELEVEL = 2;
- Trace.initStream(System.err);
- ExampleMain.main(args);
- }
-}
-