Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Lazy weaving vs eager weaving?

It is possible your second piece of advice there "call(*.new(..))" may
be matching the call to create the aspect instance - and that could
lead to a NoAspectBoundException.  To investigate constructors I'd
maybe use execution.

        after(): execution(*.new(..)) && !within(TheAspectType) {
                System.out.println("*2* ctor: " +
thisJoinPointStaticPart.getSignature());
        }

That should tell you which ctors are running.

I can't immediately see what is wrong with your initial piece of advice though.

Andy


On 25 March 2011 11:33, Grey, Lee <Lee.Grey@xxxxxxx> wrote:
> Andy,
>
> I took your advice (#2) below, and it's been working great in development for a month.  However, it turns out that there's something different in production (not sure what) that's preventing my harmless weaving from triggering, so my aspect is never instantiated.
>
> So, I'm trying to add something to the aspect to dump out all constructors, so I can choose something else as my eager-weaving trigger.  But, so far, I either get no output, or I get org.aspectj.lang.NoAspectBoundException.
>
> I don't know what class I want to trigger on, but I am 99% certain it's in a package somewhere beneath com.sonicsw.*.  Can you see what's wrong with this?
>
>        pointcut init(Object o):
>                this(o) &&
>                within(com.sonicsw..*) &&
>                initialization(*.new());
>
>        after(Object o) returning: init(o) {
>                System.out.println("*1* ctor: " + thisJoinPointStaticPart.getSignature());
>        }
>
>        after() returning(Object o): call(*.new(..)) {
>                System.out.println("*2* ctor: " + thisJoinPointStaticPart.getSignature());
>        }
>
> Thanks,
> Lee
>
>
> -----Original Message-----
> From: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Andy Clement
> Sent: Tuesday, February 22, 2011 12:22 PM
> To: aspectj-users@xxxxxxxxxxx
> Subject: Re: [aspectj-users] Lazy weaving vs eager weaving?
>
> Hi,
>
> There is no direct control for this.  You kind of have two options:
>
> (1) touch the aspect yourself much earlier, to cause it to be loaded up.  Just refer to something in it from one of your earlier loaded classes that will cause it to be loaded.
> (2) Use it to 'harmlessly' weave something that is loaded much earlier, which kind of causes (1) to happen.
>
> cheers
> Andy
>
> On 22 February 2011 08:57, Grey, Lee <Lee.Grey@xxxxxxx> wrote:
>> Is there any way to control when an aspect gets loaded and initialized?
>>
>> Thanks,
>> Lee
>> ________________________________
>> From: aspectj-users-bounces@xxxxxxxxxxx
>> [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Grey, Lee
>> Sent: Monday, February 21, 2011 12:58 PM
>> To: aspectj-users@xxxxxxxxxxx
>> Subject: [aspectj-users] Lazy weaving vs eager weaving?
>>
>> I'm still working on the weaving of Sonic ESB container services, and
>> it's working perfectly with one exception.
>>
>> I'm instantiating a thread object in a static block of my aspect.
>> Unfortunately, the static block doesn't execute until the first time a
>> message is received, even though the container JVM had started long ago.
>> Aside from the fact that the thread doesn't start when it should,
>> there is also a very long hit for all the class loading and weaving on
>> receipt of that first message.
>>
>> Is there any way to have the weaving occur immediately, which I'm
>> assuming would be the way to have the static block execute prior to
>> receiving a message?
>>
>> Thanks,
>> Lee Grey
>>
>> _______________________________________________
>> 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
>


Back to the top