Andy
2009/9/28 Kristof Jozsa <
kristof.jozsa@xxxxxxxxx>:
> Hi Andy,
>
> I think your sample is about something else. The code I pasted has a child
> class which in fact doesn't hold the method getting called, therefore
> methodcall() and super.methodcall() results in an identical behaviour just
> one of them gets weaved while the other doesn't.
>
> My target was to simply create a pointcut which can intercept childclasses
> of javax.xml.ws.Service calling their parent's getPort() method. See my
> original code:
>
> pointcut wsGetPortCall() :
> ÂÂÂ ÂÂÂ call(Object javax.xml.ws.Service+.getPort(..));
>
> but this in fact behaved a bit differently as expected as it missed the
> cases where other programmers typed super.getPort() and not simply getPort()
> in their code (and they did not had a getPort() body overwriting the
> superclass' one). This was the barebone example code which demonstrates the
> exact problem I'm having:
>
> new Service(null, null) {
> ÂÂÂ @SuppressWarnings("unused")
> ÂÂÂ public void boo() {
> ÂÂÂ ÂÂÂ super.getPort(null);ÂÂÂ // (1)
> ÂÂÂ ÂÂÂ getPort(null);ÂÂÂÂÂÂÂÂÂÂÂÂ // (2)
> ÂÂÂ }
> };
>
> I hope it makes more sense now. My question is how to accomplish my original
> goal? Is it possible?
>
> thanks,
> K
>
>
>
> On Mon, Sep 28, 2009 at 5:26 PM, Andy Clement <
andrew.clement@xxxxxxxxx>
> wrote:
>>
>> public class A {
>> Âpublic static void main(String []argv) {
>> Â ÂB b = new B();
>> Â Âb.run();
>> Â}
>> }
>>
>>
>> class Base {
>> Âpublic void getPort() {
>> Â ÂSystem.out.println("Base.getPort()");
>> Â}
>> }
>>
>> class B extends Base {
>> Âpublic void run() {
>> Â Âsuper.getPort();
>> Â ÂgetPort();
>> Â}
>> Âpublic void getPort() {
>> Â ÂSystem.out.println("B.getPort()");
>> Â}
>> }
>>
>> javac A.java
>> java A
>> Base.getPort()
>> B.getPort()
>>
>> they can do different things. ÂIf your question is why your advice
>> didn't match, it is because super calls are not join points. ÂAnd that
>> is probably a hangover from the old days of source weaving I think,
>> which has just never been revisited.
>>
>> Andy
>>
>>
>> 2009/9/28 Kristof Jozsa <
kristof.jozsa@xxxxxxxxx>:
>> > Sample code:
>> >
>> > public aspect WSPortFixerInterceptor {
>> > ÂÂÂ pointcut wsGetPortCall() :
>> > ÂÂÂ ÂÂÂ call(Object javax.xml.ws.Service+.getPort(..));
>> >
>> > ÂÂÂ Object around() : wsGetPortCall() {
>> > ÂÂÂ ÂÂÂ return
>> > WsClientTool.getInstance().fixWebServicePort(proceed());ÂÂ //
>> > never mind this line
>> > ÂÂÂ }
>> >
>> >
>> > ÂÂÂ /** private inner class to verify correct interception */
>> > ÂÂÂ @SuppressWarnings("unused")
>> > ÂÂÂ private static class TestFixer {
>> > ÂÂÂ ÂÂÂ {
>> > ÂÂÂ ÂÂÂ ÂÂÂ new Service(null, null) {
>> >
>> > ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ @SuppressWarnings("unused")
>> > ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ public void boo() {
>> > ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ super.getPort(null);ÂÂÂ // (1)
>> > ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ getPort(null);ÂÂÂÂÂÂÂÂÂÂÂÂ // (2)
>> > ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ }
>> > ÂÂÂ ÂÂÂ ÂÂÂ };
>> > ÂÂÂ ÂÂÂ }
>> > ÂÂÂ }
>> > }
>> >
>> > To my best knowledge, the two calls at (1) and (2) does the very same in
>> > Java, but appearently (2) gets intercepted by this aspect and (1) does
>> > not..
>> > what's the explanation for this behaviour?
>> >
>> > thanks,
>> > K
>> >
>> > _______________________________________________
>> > 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
>
>
> _______________________________________________
> 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