[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [aspectj-users] Should this work Aspects.aspectOf(SimpleAroun dAspect.class, testC lass) ?
|
Thanks Alex - I do get the NoAspectBound exception.
-neil.
-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Alexandre Vasseur
Sent: 17 October 2005 11:42
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] Should this work
Aspects.aspectOf(SimpleAroundAspect.class, testC lass) ?
the aspect is singleton (@Aspect without perclause) hence there is no aspect
bound to a particular instance or class. For such aspect you have to use
Aspects.aspectOf(aspectClass) That said you should have a
NoAspectBoundException. I'll file a bug Alex
On 10/17/05, AVERY, Neil, FM <Neil.AVERY@xxxxxxxx> wrote:
>
> Ive defined an aspect which successfully gets applied to a testclass,
> however when I try Aspects.aspectOf() using the instance and Aspect
> class, I get the following exception:
>
> org.aspectj.lang.NoAspectBoundException: Exception while initializing
> org.stuff.SimpleAroundAspect: java.lang.NoSuchMethodException:
> org.stuff.SimpleAroundAspect.aspectOf(java.lang.Object)
> at org.aspectj.lang.Aspects.aspectOf(Aspects.java:68)
> at
> org.stuff.aspectof.AspectOfTest.testAspectCanBeRetrieved(AspectOfTest.
> java:28)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
> at
>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
> at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at junit.framework.TestCase.runTest(TestCase.java:154)
> at junit.framework.TestCase.runBare(TestCase.java:127)
> at
> junit.framework.TestResult$1.protect(TestResult.java:106)
> at
> junit.framework.TestResult.runProtected(TestResult.java:124)
> at junit.framework.TestResult.run(TestResult.java:109)
> at junit.framework.TestCase.run(TestCase.java:118)
> at
>
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
nner.java:478)
> at
>
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.
java:344)
> at
>
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner
.java:196)
> Caused by: java.lang.NoSuchMethodException:
> org.stuff.SimpleAroundAspect.aspectOf(java.lang.Object)
> at java.lang.Class.getDeclaredMethod(Class.java:1909)
> at
> org.aspectj.lang.Aspects.getPerObjectAspectOf(Aspects.java:143)
> at org.aspectj.lang.Aspects.aspectOf(Aspects.java:63)
> ... 14 more
>
>
>
> ASPECT:
> package org.stuff;
>
> import org.aspectj.lang.ProceedingJoinPoint;
> import org.aspectj.lang.annotation.*;
>
> @Aspect
> public class SimpleAroundAspect {
> public static int callCount = 0;
>
> @Around("call(* org.stuff.TestClass.*(..))")
> public Object invoke(ProceedingJoinPoint thisJoinPoint) throws
> Throwable {
>
> System.err.println("called onto SimpleAroundAspect count:" +
> callCount++);
> return thisJoinPoint.proceed();
> };
> }
> AOP-XML
>
>
> <aspectj>
> <aspects>
> <aspect name="org.stuff.SimpleAroundAspect"/>
> </aspects>
> <weaver options="-verbose -showWeaveInfo -1.5">
> <include within="org.stuff.*"/>
> <include within="org.stuff.*.*"/>
> <include within="org.stuff.*.*.*"/>
> <exclude within="org.eclipse.*"/>
> </weaver>
> </aspectj>
>
>
> TEST:
> package org.stuff.aspectof;
>
> import org.aspectj.lang.Aspects;
> import org.stuff.SimpleAroundAspect;
> import org.stuff.TestClass;
>
> import junit.framework.TestCase;
>
> public class AspectOfTest extends TestCase {
>
> public void testAspectCanBeRetrieved() throws Exception {
> TestClass testClass = new TestClass();
> testClass.doStuff(100);
> Object aspect = Aspects.aspectOf(SimpleAroundAspect.class);
> assertNotNull(aspect);
>
> >>>> aspect = Aspects.aspectOf(SimpleAroundAspect.class, testClass);
> assertNotNull(aspect);
> }
> }
>
>
>
>
> **********************************************************************
> *************
> The Royal Bank of Scotland plc. Registered in Scotland No 90312.
Registered
> Office: 36 St Andrew Square, Edinburgh EH2 2YB.
> Authorised and regulated by the Financial Services Authority
>
> This e-mail message is confidential and for use by the addressee
> only. If the message is received by anyone other than the addressee,
> please return the message to the sender by replying to it and then
> delete the message from your computer. Internet e-mails are not
> necessarily secure. The Royal Bank of Scotland plc does not accept
> responsibility for changes made to this message after it was sent.
>
> Whilst all reasonable care has been taken to avoid the transmission
> of viruses, it is the responsibility of the recipient to ensure that
> the onward transmission, opening or use of this message and any
> attachments will not adversely affect its systems or data. No
> responsibility is accepted by The Royal Bank of Scotland plc in this
> regard and the recipient should carry out such virus and other checks
> as it considers appropriate. Visit our websites at:
> http://www.rbs.co.uk/CBFM
> http://www.rbsmarkets.com
>
****************************************************************************
****
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
>
>
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users