[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
Re: [aspectj-users] Need advice on how to craft a pointcut ... a real challenge :)
|
- From: Andrew Eisenberg <andrew@xxxxxxxxxxxx>
- Date: Thu, 19 Feb 2009 16:16:12 -0800
- Delivered-to: aspectj-users@eclipse.org
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:reply-to:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:content-type:content-transfer-encoding; bh=Szsetbx1huqi1+BMoCKav4untWcxhFXe+rPUl1qi3yw=; b=pfmaSYGi7revesvsodtOowHb+YXS2GTbl7OaZ/4XUF68r3MWzmHxBvDCrnByOgiHKi NB3axhneZl0Tf+2CocZYxzScnCIRYYEKRqMeS0bgRaTpVCaI+/bT9Tzc68t6mqpGY6Cd 2ws2dv2lqw3hpie36SVHotjz0rXKYzZw8/HJc=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:reply-to:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=lk2mJ+Crq1fkyoEvNO6et0umZNceyrpO3oio24nSB5MRE1WuHRiNBKY54nuzHuTyDQ wIStUpzVv3FdclOdcnKw/QqOts+N0gEnlEeEX9FhDCGm3Q+OoXZjCmPG2gCRMlVbhFl5 ShYz8tzv3j6DIZIYfzQym114HtC9qQHvg4Xf8=
Unfortunately, this is not possible in AspectJ.
On Thu, Feb 19, 2009 at 8:54 AM, Pavlovich, Peter
<Peter.Pavlovich@xxxxxxxxxx> wrote:
>
>
> A) The process() method must be defined on this class (and each
> subclass) individually (cannot rely on superclass to provide
> implementation).
Can't look for this. You can't match on the lack of a joinpoint.
>
> B) Every public attribute (defined directly on the class in question --
> the one implementing the interface) as well as every private attribute with
> a public or protected accessor method (again, defined directly on the class
> implementing the interface) must satisfy one of the following:
>
> i) The attribute is marked with the "OkToIgnore" annotation.
>
> ii) The attribute (if public) or the public getter must be
> called/accessed within the scope of the "process()" method defined on this
> class.
>
>
This is not possible either. I originally wrote the following,
thinking it might work, but it will fail if there is any call to a
shouldn't ignore method outside of the process method.
pointcut shouldntIgnore() : within(MyProcessor+) && call(
(!@OkToIgnore) (public || protected) *.*(..));
pointcut inProcess() : withincode(public void MyProcessor+.process())
&& call(* *.*(..));
declare error : shouldntIgnore() && !inProcess() : "Fail!";
Again, the problem here is that you can't discover the lack of a joinpoint.
>
> If one of (i) or (ii) is not satisfied, then I want to fail compilation or
> log a message or some similar action to be implemented in the advice. The
> action is not that important at this point – my challenge is with defining
> the pointcut.
>
>
>
> Note that the same rules must also apply to subclasses of any class
> implementing the interface -- but these subclasses must define the process()
> method themselves and must "process" their own attributes (the ones defined
> directly on themselves) within that process method.
>
>
>
> Is this even possible? If so, any help on how to define the best pointcut
> for this scenario would be greatly appreciated! I am open to any reasonable
> refactoring that might need to be done to enable this sort of checking as
> well if that would help. I'd prefer not to have to refactor or add extra
> code to the classes if at all possible though.
>
>
>
> I look forward to your help with this challenge!!! Thanks in advance!
>
>
>
> Peter
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>