Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] candidate feature req: Perthis and Pertarget deactivation

Hi,

I was wondering whether pertarget and perthis aspects could benefit from a deactivatedAt pointcut? Percflow aspects have a well-defined point at which they are eligible for garbage collection. This is nice because there's a well-defined lifespan during which the aspect can advise join points. As it stands, there's no way for a developer to turn off, say, a pertarget aspect based on runtime information (short of using if() pointcuts).

I'm envisioning something like:

public aspect PerTest pertarget(activate()) deactivatedAt(deactivate()){

pointcut activate() : call(public void Thing.activate(..)) && target(Thing);
	
pointcut deactivate() : call(public void Thing.deactivate(..)) && target(Thing);
	
void around(Thing thing) : execution(public void Thing.work(..)) && this(thing){
		System.out.println("->Only affects activated things " +thing);
		proceed(thing);
		System.out.println("<-Only affects activated things " +thing);
		
	}
}

Of course, the name deactivatedAt probably needs some work.

I don't have a specific usecase in mind, it just seems that for consistency I ought to be able to control the deactivation of perinstance aspects the same way I can control activation.

Does anyone else think that this feature is warranted/useful? Does anyone use perthis and target aspects enough to warrant fiddling with them?

Cheers,


Nicholas Lesiecki
Software Craftsman, specializing in J2EE,
Agile Methods, and aspect-oriented programming
m: 520 591-1849

Books:
* Mastering AspectJ: http://tinyurl.com/66vf
* Java Tools for Extreme Programming: http://tinyurl.com/66vt

Articles on AspectJ:
* http://tinyurl.com/66vu and http://tinyurl.com/66vv



Back to the top