17) Version upgrade | 17) Version upgrade | ||||
============================================================================= | ============================================================================= | ||||
17.1) port to Eclipse 3.0 M9 | 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 | 18) JDT DEBUG | ||||
============================================================================= | ============================================================================= |
bin |
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." |
/******************************************************************************* | |||||
* 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(); | |||||
} | |||||
} | |||||
} |
/******************************************************************************* | |||||
* 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(); | |||||
} | |||||
} |
/******************************************************************************* | |||||
* 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(); | |||||
} | |||||
} |
/******************************************************************************* | |||||
* 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(); | |||||
} |
/******************************************************************************* | |||||
* 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(); | |||||
} | |||||
} |
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); | |||||
} | |||||
} |
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; | |||||
} | |||||
} |
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); | |||||
} | |||||
} | |||||
} |
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; | |||||
} | |||||
} |
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(); | |||||
} | |||||
} |
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; | |||||
} | |||||
} |
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; | |||||
} | |||||
} |
/* | |||||
* 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()); | |||||
} | |||||
} |
/* | |||||
* 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); | |||||
} | |||||
} | |||||
} |
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); | |||||
} | |||||
} | |||||
} |
/* | |||||
* 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); | |||||
} | |||||
} |
/* | |||||
* 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; | |||||
} | |||||
} |
/* | |||||
* 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;} | |||||
} |
/* | |||||
* 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; | |||||
} | |||||
} |