Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] changing pointcut at runtime


Hi,

>I am not limited to modify existing pointcut. Also I can insert (
>theoretically ) a new pointcut or create a new classes to extends that
>old and so on... The problem is what and how I can modify code at
>runtime? ( EX: I can modify field at runtime with reflection.) There is
>any way to insert some piece of code at runtime?

As Wes points out many of these are JVM rather than AspectJ restrictions. Runtime modification of code in a "production" JVM requires Hotswap which does not yet support schema changes (as far as I know). Therefore adding fields and methods or modifying the class hierarchy _after_ class definition is not yet possible.

As with all problems there is likely to be more than one solution. Could you elaborate on what you are trying to achieve with AspectJ LTW?

Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/



Stalsy <stalsy@xxxxxxxxx>
Sent by: aspectj-users-bounces@xxxxxxxxxxx

02/10/2006 10:08

Please respond to
aspectj-users@xxxxxxxxxxx

To
aspectj-users@xxxxxxxxxxx
cc
Subject
Re: [aspectj-users] changing pointcut at runtime





Thank both for replies.

Write some pointcut before launch the application means (for my purpose)
that I must know all the components within target program and creates an
"ad hoc" aspect that contains one pointcut for one component of the
target program. So for large application this solution is not applicable
or is not the best solution.

I am not limited to modify existing pointcut. Also I can insert (
theoretically ) a new pointcut or create a new classes to extends that
old and so on... The problem is what and how I can modify code at
runtime? ( EX: I can modify field at runtime with reflection.) There is
any way to insert some piece of code at runtime?

To Wes:
I don't know if I have understood well your final clause: the
well-defined start/end point in my aspect application is just the
control flow of main method.


thank you, best regards

Wes ha scritto:
> A longstanding and interesting question...
>
> As Eric mentioned, you can advise some join points and then include a check
> at each one whether to run the advice; you might implement the check using
> Pointcut or reflection or what have you.  You cannot change an existing
> pointcut, but you can decide what code to run.  (With some cheating you can
> change the result of an if(..) PCD, but it's clearer to change the advice.)
>
> But you're foraging around a proposal that sounds interesting: to declare
> programmatically at runtime a concrete aspect using LTW that (only)
> affects the loading of subsequent classes.  In principle this is doable
> (at some coherency risk vis-a-vis any classes loaded first), so the
> question becomes whether you can make a compelling use case, particularly
> if it involves a well-defined start/end point for defining subaspects
> programmatically.
>
> Wes
>
>  
>> ------------Original Message------------
>> From: stalsy <stalsy@xxxxxxxxx>
>> To: aspectj-users@xxxxxxxxxxx
>> Date: Sun, Oct-1-2006 11:40 AM
>> Subject: [aspectj-users] changing pointcut at runtime
>>
>>
>> Hi all,
>>
>> I'm a newbie in aspectj and I need to change a pointcut at runtime
>> based on
>> the user choice.
>>
>> I receive an input String from the user keyboard and I want create a
>> pointcut based on that input. Initially I've thinking at aspect
>> reflection,
>> but there isn't any "set" method for this pourpose.
>>
>> String comp = InitVars.getFilter(); // get an input from user keyboard
>> ....
>> AjType dt = AjTypeSystem.getAjType(DynTrace.class); // the aspect
>> (DynTrace.aj) in which I would insert new pointcut
>> Pointcut pc = dt.getPointcut("filter"); // take the old pointcut
>> PointcutExpression pce = pc.getPointcutExpression(); // take the
>> pointcut
>> old _expression_
>>
>> now how can I insert new pointcut _expression_( value of variable "comp"
>> ) in
>> this pointcut? There is another way to make this?
>>
>> ES:
>>
>> I get the input "component" from user. Than I would change the old
>> pointcut
>> public pointcut filter(): Scope() && execution(* *(..));
>> to
>> public pointcut filter(): Scope() && execution(* component(..));
>>
>> where component in pointcut _expression_ is the value of component
>> variable.
>>
>> someone can help me, please?
>>
>> thank you in advance for replies, best regards
>> --
>> View this message in context:
>> http://www.nabble.com/changing-pointcut-at-runtime-tf2365784.html#a6590719
>> Sent from the AspectJ - users mailing list archive at Nabble.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
>
>
>
>  


--
Stalsy

 HomePage   --:. http://www.stalsy.it
 Blog       --:. http://blog.stalsy.com
 Public Key --:. http://www.stalsy.it/key.php
 E-Mail     --:. stalsy@xxxxxxxxx
 ICQ        --:. 302346155
 MSN        --:. faricci@xxxxxxxx


_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top