summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/developer/ajdt/ajdt.core.workitems.txt2
-rw-r--r--docs/sandbox/aopalliance/.cvsignore1
-rw-r--r--docs/sandbox/aopalliance/aopalliance.jarbin0 -> 4467 bytes
-rw-r--r--docs/sandbox/aopalliance/lib/aj-aopalliance.jarbin0 -> 6402 bytes
-rw-r--r--docs/sandbox/aopalliance/readme.txt21
-rw-r--r--docs/sandbox/aopalliance/src/org/aspectj/aopalliance/AOPAllianceAdapter.aj72
-rw-r--r--docs/sandbox/aopalliance/src/org/aspectj/aopalliance/ConstructorInvocationClosure.java32
-rw-r--r--docs/sandbox/aopalliance/src/org/aspectj/aopalliance/InvocationJoinPointClosure.java54
-rw-r--r--docs/sandbox/aopalliance/src/org/aspectj/aopalliance/JoinPointClosure.java50
-rw-r--r--docs/sandbox/aopalliance/src/org/aspectj/aopalliance/MethodInvocationClosure.java33
-rw-r--r--docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/AOPAllianceAdapterTest.java19
-rw-r--r--docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/AllTests.java19
-rw-r--r--docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/ConstructorInvocationClosureTest.java39
-rw-r--r--docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/Hello.java24
-rw-r--r--docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/HelloAOPAllianceAdapter.aj28
-rw-r--r--docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/HelloConstructionInterceptor.java21
-rw-r--r--docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/HelloMethodInterceptor.java20
-rw-r--r--docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/InvocationJoinPointClosureTest.java76
-rw-r--r--docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/JoinPointClosureTest.java45
-rw-r--r--docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/MethodInvocationClosureTest.java27
-rw-r--r--docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/MockConstructorSignature.java16
-rw-r--r--docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/MockJoinPoint.java53
-rw-r--r--docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/MockMethodSignature.java18
-rw-r--r--docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/MockSignature.java51
24 files changed, 720 insertions, 1 deletions
diff --git a/docs/developer/ajdt/ajdt.core.workitems.txt b/docs/developer/ajdt/ajdt.core.workitems.txt
index 92ae2f8e6..866931ff8 100644
--- a/docs/developer/ajdt/ajdt.core.workitems.txt
+++ b/docs/developer/ajdt/ajdt.core.workitems.txt
@@ -248,7 +248,7 @@ I'm not sure what user interface features need this...
17) Version upgrade
=============================================================================
17.1) port to Eclipse 3.0 M9
-17.2) port to Eclipse 2.0 final
+17.2) port to Eclipse 3.0 final
18) JDT DEBUG
=============================================================================
diff --git a/docs/sandbox/aopalliance/.cvsignore b/docs/sandbox/aopalliance/.cvsignore
new file mode 100644
index 000000000..ba077a403
--- /dev/null
+++ b/docs/sandbox/aopalliance/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/docs/sandbox/aopalliance/aopalliance.jar b/docs/sandbox/aopalliance/aopalliance.jar
new file mode 100644
index 000000000..578b1a0c3
--- /dev/null
+++ b/docs/sandbox/aopalliance/aopalliance.jar
Binary files differ
diff --git a/docs/sandbox/aopalliance/lib/aj-aopalliance.jar b/docs/sandbox/aopalliance/lib/aj-aopalliance.jar
new file mode 100644
index 000000000..b41ecaaac
--- /dev/null
+++ b/docs/sandbox/aopalliance/lib/aj-aopalliance.jar
Binary files differ
diff --git a/docs/sandbox/aopalliance/readme.txt b/docs/sandbox/aopalliance/readme.txt
new file mode 100644
index 000000000..2c6083fe1
--- /dev/null
+++ b/docs/sandbox/aopalliance/readme.txt
@@ -0,0 +1,21 @@
+This example shows how to call an AOP Alliance aspect (interceptor) from
+within AspectJ.
+
+The contents of the src directory comprise some library classes plus an
+abstract aspect that can be extended to create AOP Alliance invoking concrete
+aspects (provide an implementation of getMethodInterceptor() and the
+targetJP() pointcut in your concrete subaspect).
+
+The contents of the testsrc directory supply test cases, and in so doing a
+sample of using the AOPAllianceAdapter aspect (HelloAOPAllianceAdapter aspect).
+
+With the docs module checked out of the AspectJ CVS tree, I build and test
+these AOPAlliance samples as follows:
+
+Create an AJDT project, "AOPAlliance" (you can call it whatever you like).
+Add the file lib/aopalliance.jar to the build path. Remove the default source
+directory that will have been set up for the project, and add a "src" directory.
+When doing this click "advanced" and set it up as a link to the src folder in
+this directory. Do the same for "testsrc". Now you have an AJDT project that
+should build and take its source from this directory. To run the tests, select
+the "AllTests.java" file in the AJDT project and choose "run as junit."
diff --git a/docs/sandbox/aopalliance/src/org/aspectj/aopalliance/AOPAllianceAdapter.aj b/docs/sandbox/aopalliance/src/org/aspectj/aopalliance/AOPAllianceAdapter.aj
new file mode 100644
index 000000000..789e18fde
--- /dev/null
+++ b/docs/sandbox/aopalliance/src/org/aspectj/aopalliance/AOPAllianceAdapter.aj
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.aopalliance;
+
+import org.aspectj.lang.SoftException;
+import org.aopalliance.intercept.MethodInterceptor;
+import org.aopalliance.intercept.ConstructorInterceptor;
+
+public abstract aspect AOPAllianceAdapter {
+
+ /**
+ * Return the interceptor to use at method execution join points.
+ * Must be overriden by subclasses.
+ * @return MethodInterceptor, or null if no method advice required
+ */
+ protected abstract MethodInterceptor getMethodInterceptor();
+
+ /**
+ * Return the interceptor to use at constructor execution join points.
+ * May be overriden by subclasses.
+ * @return ConstructorInterceptor, or null if no constructor advice required
+ */
+ protected ConstructorInterceptor getConstructorInterceptor() {
+ return null;
+ }
+
+ protected abstract pointcut targetJoinPoint();
+
+ pointcut methodExecution() : execution(* *(..));
+ pointcut constructorExecution() : execution(new(..));
+
+ Object around() : targetJoinPoint() && methodExecution() {
+ MethodInvocationClosure mic = new MethodInvocationClosure(thisJoinPoint) {
+ public Object execute() { return proceed();}
+ };
+ MethodInterceptor mInt = getMethodInterceptor();
+ if (mInt != null) {
+ try {
+ return mInt.invoke(mic);
+ } catch (Throwable t) {
+ throw new SoftException(t);
+ }
+ } else {
+ return proceed();
+ }
+ }
+
+ Object around() : targetJoinPoint() && constructorExecution() {
+ ConstructorInvocationClosure cic = new ConstructorInvocationClosure(thisJoinPoint) {
+ public Object execute() { proceed(); return thisJoinPoint.getThis();}
+ };
+ ConstructorInterceptor cInt = getConstructorInterceptor();
+ if (cInt != null) {
+ try {
+ return cInt.construct(cic);
+ } catch (Throwable t) {
+ throw new SoftException(t);
+ }
+ } else {
+ return proceed();
+ }
+ }
+
+}
diff --git a/docs/sandbox/aopalliance/src/org/aspectj/aopalliance/ConstructorInvocationClosure.java b/docs/sandbox/aopalliance/src/org/aspectj/aopalliance/ConstructorInvocationClosure.java
new file mode 100644
index 000000000..0d1541e2a
--- /dev/null
+++ b/docs/sandbox/aopalliance/src/org/aspectj/aopalliance/ConstructorInvocationClosure.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.aopalliance;
+
+import java.lang.reflect.Constructor;
+
+import org.aopalliance.intercept.ConstructorInvocation;
+import org.aspectj.lang.JoinPoint;
+
+public abstract class ConstructorInvocationClosure extends InvocationJoinPointClosure
+ implements ConstructorInvocation {
+
+ public ConstructorInvocationClosure(JoinPoint jp) {
+ super(jp);
+ }
+
+ /* (non-Javadoc)
+ * @see org.aopalliance.intercept.MethodInvocation#getMethod()
+ */
+ public Constructor getConstructor() {
+ return (Constructor) getStaticPart();
+ }
+
+}
diff --git a/docs/sandbox/aopalliance/src/org/aspectj/aopalliance/InvocationJoinPointClosure.java b/docs/sandbox/aopalliance/src/org/aspectj/aopalliance/InvocationJoinPointClosure.java
new file mode 100644
index 000000000..efbea5be2
--- /dev/null
+++ b/docs/sandbox/aopalliance/src/org/aspectj/aopalliance/InvocationJoinPointClosure.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.aopalliance;
+
+import java.lang.reflect.AccessibleObject;
+
+import org.aopalliance.intercept.Invocation;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.reflect.CodeSignature;
+import org.aspectj.lang.reflect.ConstructorSignature;
+import org.aspectj.lang.reflect.MethodSignature;
+
+public abstract class InvocationJoinPointClosure extends JoinPointClosure implements Invocation {
+
+ public InvocationJoinPointClosure(JoinPoint jp) {
+ super(jp);
+ }
+
+ /* (non-Javadoc)
+ * @see org.aopalliance.intercept.Joinpoint#getStaticPart()
+ */
+ public AccessibleObject getStaticPart() {
+ CodeSignature cSig = (CodeSignature)jp.getSignature();
+ Class clazz = cSig.getDeclaringType();
+ AccessibleObject ret = null;
+ try {
+ if (cSig instanceof MethodSignature) {
+ ret = clazz.getMethod(cSig.getName(),cSig.getParameterTypes());
+ } else if (cSig instanceof ConstructorSignature) {
+ ret = clazz.getConstructor(cSig.getParameterTypes());
+ }
+ } catch (NoSuchMethodException mEx) {
+ throw new UnsupportedOperationException(
+ "Can't find member " + cSig.toLongString());
+ }
+ return ret;
+ }
+
+ /* (non-Javadoc)
+ * @see org.aopalliance.intercept.Invocation#getArguments()
+ */
+ public Object[] getArguments() {
+ return jp.getArgs();
+ }
+
+}
diff --git a/docs/sandbox/aopalliance/src/org/aspectj/aopalliance/JoinPointClosure.java b/docs/sandbox/aopalliance/src/org/aspectj/aopalliance/JoinPointClosure.java
new file mode 100644
index 000000000..a995ff15c
--- /dev/null
+++ b/docs/sandbox/aopalliance/src/org/aspectj/aopalliance/JoinPointClosure.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.aopalliance;
+
+import java.lang.reflect.AccessibleObject;
+
+import org.aopalliance.intercept.Joinpoint;
+import org.aspectj.lang.JoinPoint;
+
+public abstract class JoinPointClosure implements Joinpoint {
+
+ protected JoinPoint jp;
+
+ public JoinPointClosure(JoinPoint joinPoint) {
+ this.jp = joinPoint;
+ }
+
+ /* (non-Javadoc)
+ * @see org.aopalliance.intercept.Joinpoint#proceed()
+ */
+ public Object proceed() throws Throwable {
+ return execute();
+ }
+
+ // for subclasses, renamed from proceed to avoid confusion in
+ // AspectJ around advice.
+ public abstract Object execute();
+
+ /* (non-Javadoc)
+ * @see org.aopalliance.intercept.Joinpoint#getThis()
+ */
+ public Object getThis() {
+ return jp.getThis();
+ }
+ /* (non-Javadoc)
+ * @see org.aopalliance.intercept.Joinpoint#getStaticPart()
+ * Must return either a Field, Method or Constructor representing the entity
+ * at the joinpoint.
+ */
+ public abstract AccessibleObject getStaticPart();
+
+}
diff --git a/docs/sandbox/aopalliance/src/org/aspectj/aopalliance/MethodInvocationClosure.java b/docs/sandbox/aopalliance/src/org/aspectj/aopalliance/MethodInvocationClosure.java
new file mode 100644
index 000000000..468a3690f
--- /dev/null
+++ b/docs/sandbox/aopalliance/src/org/aspectj/aopalliance/MethodInvocationClosure.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.aopalliance;
+
+import java.lang.reflect.Method;
+
+import org.aopalliance.intercept.MethodInvocation;
+import org.aspectj.lang.JoinPoint;
+
+public abstract class MethodInvocationClosure extends InvocationJoinPointClosure
+ implements
+ MethodInvocation {
+
+ public MethodInvocationClosure(JoinPoint jp) {
+ super(jp);
+ }
+
+ /* (non-Javadoc)
+ * @see org.aopalliance.intercept.MethodInvocation#getMethod()
+ */
+ public Method getMethod() {
+ return (Method) getStaticPart();
+ }
+
+}
diff --git a/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/AOPAllianceAdapterTest.java b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/AOPAllianceAdapterTest.java
new file mode 100644
index 000000000..a172c22f3
--- /dev/null
+++ b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/AOPAllianceAdapterTest.java
@@ -0,0 +1,19 @@
+
+package org.aspectj.aopalliance.tests;
+
+import junit.framework.TestCase;
+
+public class AOPAllianceAdapterTest extends TestCase {
+
+ public void testHello() {
+ Hello h = new Hello();
+ h.sayHello();
+ Hello h2 = new Hello("Hello AOP Alliance");
+ h2.sayHello();
+ assertTrue("Constructor executed", Hello.defaultConsExecuted);
+ assertTrue("2nd Constructor executed", Hello.paramConsExecuted);
+ assertEquals("sayHello invoked twice",2,Hello.sayHelloCount);
+ assertEquals("Constructor interceptor ran twice",2,HelloConstructionInterceptor.runCount);
+ assertEquals("Method interceptor ran twice",2,HelloMethodInterceptor.runCount);
+ }
+}
diff --git a/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/AllTests.java b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/AllTests.java
new file mode 100644
index 000000000..ea4d96c84
--- /dev/null
+++ b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/AllTests.java
@@ -0,0 +1,19 @@
+package org.aspectj.aopalliance.tests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+ public static Test suite() {
+ TestSuite suite = new TestSuite(
+ "Test for org.aspectj.aopalliance.tests");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(JoinPointClosureTest.class);
+ suite.addTestSuite(InvocationJoinPointClosureTest.class);
+ suite.addTestSuite(MethodInvocationClosureTest.class);
+ suite.addTestSuite(ConstructorInvocationClosureTest.class);
+ suite.addTestSuite(AOPAllianceAdapterTest.class);
+ //$JUnit-END$
+ return suite;
+ }
+}
diff --git a/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/ConstructorInvocationClosureTest.java b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/ConstructorInvocationClosureTest.java
new file mode 100644
index 000000000..8071193de
--- /dev/null
+++ b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/ConstructorInvocationClosureTest.java
@@ -0,0 +1,39 @@
+package org.aspectj.aopalliance.tests;
+
+import java.lang.reflect.Constructor;
+
+import org.aspectj.aopalliance.ConstructorInvocationClosure;
+
+import junit.framework.TestCase;
+
+public class ConstructorInvocationClosureTest extends TestCase {
+
+
+ public void testGetArguments() {
+ MockMethodSignature sig = new MockMethodSignature("toString",Object.class,
+ new Class[] {});
+ Object[] args = new Object[] {this};
+ MockJoinPoint jp = new MockJoinPoint(this,sig,args);
+ ConstructorInvocationClosure cic = new ConstructorInvocationClosure(jp) {
+ public Object execute() {return null;}
+ };
+ assertEquals(args,cic.getArguments());
+ }
+
+ public void testGetConstructor() {
+ MockConstructorSignature sig = new MockConstructorSignature("new",StringBuffer.class,
+ new Class[] {String.class});
+ MockJoinPoint jp = new MockJoinPoint(this,sig,null);
+ ConstructorInvocationClosure cic = new ConstructorInvocationClosure(jp) {
+ public Object execute() {return null;}
+ };
+ Constructor c = cic.getConstructor();
+ try {
+ assertEquals("Should find StringBuffer constructor",StringBuffer.class.getConstructor(new Class[]{String.class}),
+ c);
+ } catch (NoSuchMethodException e) {
+ fail("Duff test:" + e);
+ }
+
+ }
+}
diff --git a/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/Hello.java b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/Hello.java
new file mode 100644
index 000000000..6aea07096
--- /dev/null
+++ b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/Hello.java
@@ -0,0 +1,24 @@
+
+package org.aspectj.aopalliance.tests;
+
+public class Hello {
+
+ public static boolean defaultConsExecuted = false;
+ public static boolean paramConsExecuted = false;
+ public static int sayHelloCount = 0;
+
+ private String msg = "Hello";
+
+ public Hello() { defaultConsExecuted = true;}
+
+ public Hello(String s) {
+ msg = s;
+ paramConsExecuted = true;
+ }
+
+ public String sayHello() {
+ sayHelloCount++;
+ return msg;
+ }
+
+}
diff --git a/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/HelloAOPAllianceAdapter.aj b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/HelloAOPAllianceAdapter.aj
new file mode 100644
index 000000000..804cf1c3a
--- /dev/null
+++ b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/HelloAOPAllianceAdapter.aj
@@ -0,0 +1,28 @@
+package org.aspectj.aopalliance.tests;
+
+import org.aspectj.aopalliance.AOPAllianceAdapter;
+import org.aopalliance.intercept.MethodInterceptor;
+import org.aopalliance.intercept.ConstructorInterceptor;
+
+
+public aspect HelloAOPAllianceAdapter extends AOPAllianceAdapter {
+
+ private MethodInterceptor mInt;
+ private ConstructorInterceptor cInt;
+
+ public pointcut targetJoinPoint() : within(Hello);
+
+ protected MethodInterceptor getMethodInterceptor() {
+ return mInt;
+ }
+
+ protected ConstructorInterceptor getConstructorInterceptor() {
+ return cInt;
+ }
+
+ public HelloAOPAllianceAdapter() {
+ mInt = new HelloMethodInterceptor();
+ cInt = new HelloConstructionInterceptor();
+ }
+
+}
diff --git a/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/HelloConstructionInterceptor.java b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/HelloConstructionInterceptor.java
new file mode 100644
index 000000000..65d18adbd
--- /dev/null
+++ b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/HelloConstructionInterceptor.java
@@ -0,0 +1,21 @@
+package org.aspectj.aopalliance.tests;
+
+import org.aopalliance.intercept.ConstructorInterceptor;
+import org.aopalliance.intercept.ConstructorInvocation;
+
+public class HelloConstructionInterceptor implements ConstructorInterceptor {
+
+ public static int runCount = 0;
+
+ /* (non-Javadoc)
+ * @see org.aopalliance.intercept.ConstructorInterceptor#construct(org.aopalliance.intercept.ConstructorInvocation)
+ */
+ public Object construct(ConstructorInvocation jp) throws Throwable {
+ System.out.println("About to invoke AOP Alliance constructor interceptor");
+ Object ret = jp.proceed();
+ System.out.println("Invoked AOP Alliance constructor interceptor, return = " +
+ (ret != null ? ret.toString() : "null"));
+ runCount++;
+ return ret;
+ }
+}
diff --git a/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/HelloMethodInterceptor.java b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/HelloMethodInterceptor.java
new file mode 100644
index 000000000..70162fd27
--- /dev/null
+++ b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/HelloMethodInterceptor.java
@@ -0,0 +1,20 @@
+package org.aspectj.aopalliance.tests;
+
+import org.aopalliance.intercept.MethodInterceptor;
+import org.aopalliance.intercept.MethodInvocation;
+
+public class HelloMethodInterceptor implements MethodInterceptor {
+
+ public static int runCount = 0;
+
+ /* (non-Javadoc)
+ * @see org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation)
+ */
+ public Object invoke(MethodInvocation jp) throws Throwable {
+ System.out.println("About to invoke AOP Alliance method interceptor");
+ Object ret = jp.proceed();
+ System.out.println("Invoked AOP Alliance method interceptor, return = " + ret.toString());
+ runCount++;
+ return ret;
+ }
+}
diff --git a/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/InvocationJoinPointClosureTest.java b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/InvocationJoinPointClosureTest.java
new file mode 100644
index 000000000..bfa710b77
--- /dev/null
+++ b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/InvocationJoinPointClosureTest.java
@@ -0,0 +1,76 @@
+/*
+ * Created on 07-May-2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.aspectj.aopalliance.tests;
+
+import java.lang.reflect.AccessibleObject;
+
+import junit.framework.TestCase;
+
+import org.aspectj.aopalliance.InvocationJoinPointClosure;
+
+
+public class InvocationJoinPointClosureTest extends TestCase {
+
+ public void testGetStaticPartMethod() {
+ MockMethodSignature sig = new MockMethodSignature("toString",Object.class,
+ new Class[] {});
+ MockJoinPoint jp = new MockJoinPoint(this,sig,null);
+ InvocationJoinPointClosure mejpc = new InvocationJoinPointClosure(jp) {
+ public Object execute() {return null;}
+ };
+ AccessibleObject ao = mejpc.getStaticPart();
+ try {
+ assertEquals("Should find toString method",Object.class.getMethod("toString",new Class[]{}),
+ ao);
+ } catch (NoSuchMethodException e) {
+ fail("Duff test:" + e);
+ }
+ }
+
+ public void testGetStaticPartConstructor() {
+ MockConstructorSignature sig = new MockConstructorSignature("new",StringBuffer.class,
+ new Class[] {String.class});
+ MockJoinPoint jp = new MockJoinPoint(this,sig,null);
+ InvocationJoinPointClosure mejpc = new InvocationJoinPointClosure(jp) {
+ public Object execute() {return null;}
+ };
+ AccessibleObject ao = mejpc.getStaticPart();
+ try {
+ assertEquals("Should find StringBuffer constructor",StringBuffer.class.getConstructor(new Class[]{String.class}),
+ ao);
+ } catch (NoSuchMethodException e) {
+ fail("Duff test:" + e);
+ }
+ }
+
+ public void testGetStaticPartException() {
+ try {
+ MockMethodSignature sig = new MockMethodSignature("toKettle",Object.class,
+ new Class[] {});
+ MockJoinPoint jp = new MockJoinPoint(this,sig,null);
+ InvocationJoinPointClosure mejpc = new InvocationJoinPointClosure(jp) {
+ public Object execute() {return null;}
+ };
+ AccessibleObject ao = mejpc.getStaticPart();
+ fail("UnsupportedOperationException expected");
+ } catch (UnsupportedOperationException unEx) {
+ assertEquals("Can't find member long string",unEx.getMessage());
+ }
+ }
+
+ public void testGetArguments() {
+ MockMethodSignature sig = new MockMethodSignature("toString",Object.class,
+ new Class[] {});
+ Object[] args = new Object[] {this};
+ MockJoinPoint jp = new MockJoinPoint(this,sig,args);
+ InvocationJoinPointClosure mic = new InvocationJoinPointClosure(jp) {
+ public Object execute() {return null;}
+ };
+ assertEquals(args,mic.getArguments());
+ }
+
+}
diff --git a/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/JoinPointClosureTest.java b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/JoinPointClosureTest.java
new file mode 100644
index 000000000..7bc996a0f
--- /dev/null
+++ b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/JoinPointClosureTest.java
@@ -0,0 +1,45 @@
+/*
+ * Created on 07-May-2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.aspectj.aopalliance.tests;
+
+import java.lang.reflect.AccessibleObject;
+
+import junit.framework.TestCase;
+
+import org.aspectj.aopalliance.JoinPointClosure;
+import org.aspectj.lang.JoinPoint;
+
+/**
+ * @author colyer
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public class JoinPointClosureTest extends TestCase {
+
+ public void testGetThis() {
+ JoinPoint jp = new MockJoinPoint(this,null,null);
+ JoinPointClosure jpc = new JoinPointClosure(jp) {
+ public Object execute() {return null;}
+ public AccessibleObject getStaticPart() {return null;}};
+ assertEquals("getThis returns join point 'this'",this,jpc.getThis());
+ }
+
+ public void testProceed() {
+ JoinPoint jp = new MockJoinPoint(this,null,null);
+ JoinPointClosure jpc = new JoinPointClosure(jp) {
+ public Object execute() {return this;}
+ public AccessibleObject getStaticPart() {return null;}};
+ try {
+ Object ret = jpc.proceed();
+ assertTrue("should return value from execute",ret instanceof JoinPointClosure);
+ } catch (Throwable e) {
+ fail("Exception proceeding on join point : " + e);
+ }
+ }
+
+}
diff --git a/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/MethodInvocationClosureTest.java b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/MethodInvocationClosureTest.java
new file mode 100644
index 000000000..a25755f37
--- /dev/null
+++ b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/MethodInvocationClosureTest.java
@@ -0,0 +1,27 @@
+package org.aspectj.aopalliance.tests;
+
+import java.lang.reflect.Method;
+
+import org.aspectj.aopalliance.MethodInvocationClosure;
+
+import junit.framework.TestCase;
+
+public class MethodInvocationClosureTest extends TestCase {
+
+
+ public void testGetMethod() {
+ MockMethodSignature sig = new MockMethodSignature("toString",Object.class,
+ new Class[] {});
+ MockJoinPoint jp = new MockJoinPoint(this,sig,null);
+ MethodInvocationClosure mic = new MethodInvocationClosure(jp) {
+ public Object execute() {return null;}
+ };
+ Method m = mic.getMethod();
+ try {
+ assertEquals("Should find toString method",Object.class.getMethod("toString",new Class[]{}),
+ m);
+ } catch (NoSuchMethodException e) {
+ fail("Duff test:" + e);
+ }
+ }
+}
diff --git a/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/MockConstructorSignature.java b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/MockConstructorSignature.java
new file mode 100644
index 000000000..4a691c87a
--- /dev/null
+++ b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/MockConstructorSignature.java
@@ -0,0 +1,16 @@
+/*
+ * Created on 07-May-2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.aspectj.aopalliance.tests;
+
+import org.aspectj.lang.reflect.ConstructorSignature;
+
+
+class MockConstructorSignature extends MockSignature implements ConstructorSignature {
+ public MockConstructorSignature(String name,Class decClass, Class[] paramTypes) {
+ super(name,decClass,paramTypes);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/MockJoinPoint.java b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/MockJoinPoint.java
new file mode 100644
index 000000000..821ed507a
--- /dev/null
+++ b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/MockJoinPoint.java
@@ -0,0 +1,53 @@
+/*
+ * Created on 07-May-2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.aspectj.aopalliance.tests;
+
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.Signature;
+import org.aspectj.lang.reflect.SourceLocation;
+
+
+class MockJoinPoint implements JoinPoint {
+
+ private Object me;
+ private Signature sig;
+ private Object[] args;
+
+ public MockJoinPoint(Object me, Signature sig, Object[] args) {
+ this.me = me;
+ this.sig = sig;
+ this.args = args;
+ }
+
+ public Object[] getArgs() {
+ return args;
+ }
+ public String getKind() {
+ return null;
+ }
+ public Signature getSignature() {
+ return sig;
+ }
+ public SourceLocation getSourceLocation() {
+ return null;
+ }
+ public StaticPart getStaticPart() {
+ return null;
+ }
+ public Object getTarget() {
+ return null;
+ }
+ public Object getThis() {
+ return me;
+ }
+ public String toLongString() {
+ return null;
+ }
+ public String toShortString() {
+ return null;
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/MockMethodSignature.java b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/MockMethodSignature.java
new file mode 100644
index 000000000..9a70a22c6
--- /dev/null
+++ b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/MockMethodSignature.java
@@ -0,0 +1,18 @@
+/*
+ * Created on 07-May-2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.aspectj.aopalliance.tests;
+
+import org.aspectj.lang.reflect.MethodSignature;
+
+
+class MockMethodSignature extends MockSignature implements MethodSignature {
+ public MockMethodSignature(String name,Class decClass, Class[] paramTypes) {
+ super(name,decClass,paramTypes);
+ }
+
+ public Class getReturnType() {return null;}
+} \ No newline at end of file
diff --git a/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/MockSignature.java b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/MockSignature.java
new file mode 100644
index 000000000..9f81281fc
--- /dev/null
+++ b/docs/sandbox/aopalliance/testsrc/org/aspectj/aopalliance/tests/MockSignature.java
@@ -0,0 +1,51 @@
+/*
+ * Created on 07-May-2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.aspectj.aopalliance.tests;
+
+import org.aspectj.lang.reflect.CodeSignature;
+
+
+class MockSignature implements CodeSignature {
+
+ private String name;
+ private Class decClass;
+ private Class[] paramTypes;
+
+ public MockSignature(String name,Class decClass, Class[] paramTypes) {
+ this.name = name;
+ this.decClass = decClass;
+ this.paramTypes = paramTypes;
+ }
+
+ public Class[] getExceptionTypes() {
+ return null;
+ }
+ public String[] getParameterNames() {
+ return null;
+ }
+ public Class[] getParameterTypes() {
+ return paramTypes;
+ }
+ public Class getDeclaringType() {
+ return decClass;
+ }
+ public String getDeclaringTypeName() {
+ return null;
+ }
+ public int getModifiers() {
+ return 0;
+ }
+ public String getName() {
+ return name;
+ }
+ public String toLongString() {
+ return "long string";
+ }
+ public String toShortString() {
+ return null;
+ }
+} \ No newline at end of file