Re: [aspectwerkz-user] Is there a way to get a pointcut name from within an around advic e?
Alexandru Popescu <[email protected]>
| Newsgroups | gmane.comp.java.aspectwerkz.user |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Not sure if this is the cause but: - - the around advice signature must include the throws Throwable - - not sure if you correctly provided the package name of HelloWorldHijacker in aop.xmp (is it really in <<default>> package? otherwise the <aspect class="fully_qualified_name"> - -- :alex |.::the_mindstorm::.| [quote Krasheninnikov, Konstantin::on 4/8/2005 5:06 PM] > Alex, > > Thank you for the reply. > > I could not find how to get to the pointcut name but I can specify it as > parameter to an advice, e.g. > > <aspect name="1" class="HelloWorldHijacker"> > > <param name="pointcutName" value="greetMethod"/> > <pointcut name="greetMethod" expression="execution(* > testAOP.HelloWorld2.greet(..))"/> > <advice name="yellifyier" type="around" > bind-to="greetMethod"/> > > </aspect> > > <aspect name="2" class="HelloWorldHijacker"> > > <param name="pointcutName" value="fooMethod"/> > <pointcut name="fooMethod" expression="execution(* > testAOP.HelloWorld2.foo(..))"/> > <advice name="yellifyier" type="around" bind-to="fooMethod"/> > > </aspect> > > Btw, just wanted to let you know that the following does not work for > "fooMethod" (no match) > > <aspect class="HelloWorldHijacker"> > > <pointcut name="greetMethod" expression="execution(* > testAOP.HelloWorld2.greet(..))"/> > <advice name="yellifyier" type="around" bind-to="greetMethod"/> > > <pointcut name="fooMethod" expression="execution(* > testAOP.HelloWorld2.foo(..))"/> > <advice name="yellifyier" type="around" bind-to="fooMethod"/> > > </aspect> > > (See the program output below) Is it a bug or a feature? > > -krosh- > > ---------------------- > > AspectWerkz - INFO - Pre-processor > org.codehaus.aspectwerkz.transform.AspectWerkzPreProcessor loaded and > initialized > sun.misc.Launcher$AppClassLoader@67ac19@6794265:testAOP.HelloWorld2[main] > ****************************************************************** > * ClassLoader = sun.misc.Launcher$ExtClassLoader@53ba3d@5487165 > * SystemID = virtual_5487165, 1 aspects. > ****************************************************************** > ****************************************************************** > * ClassLoader = sun.misc.Launcher$AppClassLoader@67ac19@6794265 > * SystemID = AspectWerkzExample, 2 aspects. > * SystemID = virtual_6794265, 1 aspects. > * file:/home/krashk/aspectwerkz/projects/test01/aop.xml > ****************************************************************** > [TRACE - earlymatch: greetMethod @ > AspectWerkzExample/testAOP.HelloWorldHijacker/yellifyier > [ for testAOP.HelloWorld2 > [ within testAOP.HelloWorld2 > [ type execution > [TRACE - earlymatch: greetMethod @ > AspectWerkzExample/testAOP.HelloWorldHijacker/yellifyier > [ for testAOP.HelloWorld2 > [ within testAOP.HelloWorld2 > [ type within > [TRACE - earlymatch: greetMethod @ > AspectWerkzExample/testAOP.HelloWorldHijacker/yellifyier > [ for testAOP.HelloWorld2 > [ within testAOP.HelloWorld2 > [ type within > [TRACE - earlymatch: greetMethod @ > AspectWerkzExample/testAOP.HelloWorldHijacker/yellifyier > [ for testAOP.HelloWorld2 > [ within testAOP.HelloWorld2 > [ type within > [TRACE - match: greetMethod @ > AspectWerkzExample/testAOP.HelloWorldHijacker/yellifyier > [ for testAOP.HelloWorld2.greet()Ljava/lang/String; > [ within testAOP.HelloWorld2.greet()Ljava/lang/String; > [ type execution > sun.misc.Launcher$AppClassLoader@67ac19@6794265:testAOP.HelloWorldHijacker[m > ain] > HelloWorldHijacker is constructed! > RTTI name: greet Signature: greet > Method name: greet > Return type: java.lang.String > --> testAOP.HelloWorld2::greet > <-- testAOP.HelloWorld2::greet > <yell>Hello World!</yell> > Foo > > -----Original Message----- > From: Alexandre Vasseur [mailto:[email protected]] > Sent: Friday, April 08, 2005 9:41 AM > To: [email protected] > Subject: Re: [aspectwerkz-user] Is there a way to get a pointcut name from > within an around advic e? > > Hi > > You may have an aspect constructor that accepts > org.codehaus.aspectwerkz.AspectContext as single parameter. >>From that instance you can access the AspectDefinition that should contain > what you need. > > Another option would be to use Annotation defined aspect and access the > annotation using the AspectWerkz Annotations.* API (works on Java > 1.4 as well). > > Last, another option would be to use > SystemDefinitionContainer.getDefinition(uuid, ClassLoader) that should > contain the AspectDefinitions of the deployed aspects. > > Alex > > > On Apr 8, 2005 3:31 PM, Krasheninnikov, Konstantin > <[email protected]> wrote: >> >> >> Hello, >> >> Given >> >> ... >> <aspect class="HelloWorldHijacker"> >> <pointcut name="greetMethod" expression="execution(* >> testAOP.HelloWorld2.greet(..))"/> >> <advice name="yellifyier" type="around" > bind-to="greetMethod"/> >> </aspect> >> >> ...and >> >> public class HelloWorldHijacker { >> public Object yellifyier( JoinPoint joinPoint ) { >> String ret = null; >> try { >> >> // How to get to the pointcut name (which is >> "greetMethod") here ?? >> >> Object greeting = joinPoint.proceed(); >> ret = "<yell>" + greeting + "</yell>"; >> } >> catch( Throwable e ) { >> e.printStackTrace(); >> } >> return ret; >> } >> } >> >> Q: Is there a way to get the pointcut name from within the around advice? >> >> Thanks in advance, >> >> -krosh- >> > -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (MingW32) iD8DBQFCVrpwOCPjdDT2FEURAoHOAJ4tZDZdeDiBAXSqMXjFaI6BvYU7BQCgoTU8 l006C4DbR3UGaHhxxIZVUQw= =v439 -----END PGP SIGNATURE-----