aboutsummaryrefslogtreecommitdiffstats
path: root/docs/examples/tjp
diff options
context:
space:
mode:
authorAlexander Kriegisch <Alexander@Kriegisch.name>2024-01-04 10:12:59 +0700
committerAlexander Kriegisch <Alexander@Kriegisch.name>2024-01-06 10:09:11 +0100
commit61ceb8a58ea72d4c07ff0b2f669d5f84b75700ec (patch)
tree857d468f6c8cc4d83370ed9d526e79f3abdb3f2a /docs/examples/tjp
parentf7962810eca3ddda75d64b85caab2449eeff480e (diff)
downloadaspectj-61ceb8a58ea72d4c07ff0b2f669d5f84b75700ec.tar.gz
aspectj-61ceb8a58ea72d4c07ff0b2f669d5f84b75700ec.zip
Move docs examples directory two levels up
Now, the location more closely resembles where it is on the website. Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'docs/examples/tjp')
-rw-r--r--docs/examples/tjp/Demo.java37
-rw-r--r--docs/examples/tjp/GetInfo.java49
-rw-r--r--docs/examples/tjp/files.lst2
3 files changed, 88 insertions, 0 deletions
diff --git a/docs/examples/tjp/Demo.java b/docs/examples/tjp/Demo.java
new file mode 100644
index 000000000..64d249c82
--- /dev/null
+++ b/docs/examples/tjp/Demo.java
@@ -0,0 +1,37 @@
+/*
+
+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.
+
+*/
+package tjp;
+
+public class Demo {
+ static Demo d;
+
+ public static void main(String[] args){
+ new Demo().go();
+ }
+
+ void go(){
+ d = new Demo();
+ d.foo(1,d);
+ System.out.println(d.bar(new Integer(3)));
+ }
+
+ void foo(int i, Object o){
+ System.out.println("Demo.foo(" + i + ", " + o + ")\n");
+ }
+
+ String bar (Integer j){
+ System.out.println("Demo.bar(" + j + ")\n");
+ return "Demo.bar(" + j + ")";
+ }
+}
diff --git a/docs/examples/tjp/GetInfo.java b/docs/examples/tjp/GetInfo.java
new file mode 100644
index 000000000..0d38a3766
--- /dev/null
+++ b/docs/examples/tjp/GetInfo.java
@@ -0,0 +1,49 @@
+/*
+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.
+*/
+
+package tjp;
+
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.reflect.CodeSignature;
+
+aspect GetInfo {
+
+ static final void println(String s){ System.out.println(s); }
+
+ pointcut goCut(): cflow(this(Demo) && execution(void go()));
+
+ pointcut demoExecs(): within(Demo) && execution(* *(..));
+
+ Object around(): demoExecs() && !execution(* go()) && goCut() {
+ println("Intercepted message: " +
+ thisJoinPointStaticPart.getSignature().getName());
+ println("in class: " +
+ thisJoinPointStaticPart.getSignature().getDeclaringType().getName());
+ printParameters(thisJoinPoint);
+ println("Running original method: \n" );
+ Object result = proceed();
+ println(" result: " + result );
+ return result;
+ }
+
+ static private void printParameters(JoinPoint jp) {
+ println("Arguments: " );
+ Object[] args = jp.getArgs();
+ String[] names = ((CodeSignature)jp.getSignature()).getParameterNames();
+ Class[] types = ((CodeSignature)jp.getSignature()).getParameterTypes();
+ for (int i = 0; i < args.length; i++) {
+ println(" " + i + ". " + names[i] +
+ " : " + types[i].getName() +
+ " = " + args[i]);
+ }
+ }
+}
diff --git a/docs/examples/tjp/files.lst b/docs/examples/tjp/files.lst
new file mode 100644
index 000000000..0cfc34bdf
--- /dev/null
+++ b/docs/examples/tjp/files.lst
@@ -0,0 +1,2 @@
+Demo.java
+GetInfo.java