Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: Re :Re: [aspectj-users] Protecting the joinpoints from being woven?

Have a look at abc, http://aspectbench.org .

--
Dehua Zhang
Sable Research Group, McGill University
Montréal, Québec, Canada
http://www.cs.mcgill.ca/~dzhang25





-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx on behalf of Kunal Pathak
Sent: Sat 2/23/2008 16:37
To: aspectj-users@xxxxxxxxxxx
Subject: Re :Re: [aspectj-users] Protecting the joinpoints from being woven?
 


Thanks for the reply Dean. But looking at the aspect code, I
think I haven't made my question clear. 


The brief explanation of what I am expecting is:


Every time I declare my methods as final, I make sure
that they will never be overridden. Likewise, I want some utility/
functionality/ code/ annotation that will ensure that my method, class (or any
joinpoint) is never woven by anyone in future. A nice way could be to write a
patch in ajc that will skip the weaving process if it encounters some marker in the target code. Marker just tells the ajc "You can't enter in my personal area and
spit the code (before, after, around) me".


I know the question is silly, but the functionality will at
least guarantee that no one in future will ruin my "secured" code area (especially
by writing an around advice). Also the "secured" code can be thought of never
undergoing change, whatsoever. 


Sorry for the confusion.



Thanks,Kunal.
On Sat, 23 Feb 2008 11:30:46 -0600 aspectj-users@xxxxxxxxxxx wrote  Here's a runtime aspect that will raise an exception if a method annotated with @Critical (made up annotation) calls any other methods that are advised.public aspect PreventAdvice {	public pointcut disallowed():		adviceexecution() &&		cflow(execution (@Critical * *.*(..))) &&		!within(PreventAdvice);  // prevent an infinite recursion...	before(): disallowed() {		throw new RuntimeException("Disallowed! "+thisJoinPoint);	}}  Your automated testing regime will have to catch any violations before deploying to production ;) I don't know of a robust way to accomplish the same thing with a "declare error" statement, but that would be ideal.It's really useful to think through what a "critical section" means in terms of AspectJ's join point model. In this example, I'm specifically saying I don't want any advice executed while inside @Critical methods. Note that this wouldn't prevent before or
  after advise for calls to @Critical methods. I'm assuming that's okay. For example, it might be fine to have advice that logs that the program is about to enter a @Critical method and log after it returns. You don't have to use a method (or class) annotation of course, but doing so keeps this aspect generic and robust as the underlying code gets refactored.dean	On Feb 23, 2008, at 8:43 AM, Kunal Pathak wrote:Hello All,I am just curious to know that is there any way (may be specifying some kind of annotation) to protect the joinpoint from being woven? The reason behind my question is "security". Thanks,  Kunal.   _______________________________________________  aspectj-users mailing list  aspectj-users@xxxxxxxxxxx  https://dev.eclipse.org/mailman/listinfo/aspectj-users     Dean Wampler, Ph.D.dean at objectmentor.comhttp://www.objectmentor.comSee also:http://www.aspectprogramming.com  AOP advocacy sitehttp://aquarium.rubyforge.org     AOP for Rubyhttp
 ://www.contract4j.org         Design by Contract for Java5       



Back to the top