Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Capture current value for set pointcut

I do create one backing event handler aspect for every pojo with a perthis clause, but unfortunately the aspect is in a generic framework package. Also I capture all fields marked with an annotation so I don't even know their names:

    void around(Object arg) : set(@ModelProperty * *.*) && args(arg) {...}

And I am basing this around fields rather than getters and setters. This may turn out to be a mistake, in which case I will use your before() advice idea.

Cheers
- Ashley



-----aspectj-users-bounces@xxxxxxxxxxx wrote: -----

>To: aspectj-users@xxxxxxxxxxx
>From: Dean Wampler <dean@xxxxxxxxxxxxxxxxxxxxx>
>Sent by: aspectj-users-bounces@xxxxxxxxxxx
>Date: 06/16/2008 03:03PM
>Subject: Re: [aspectj-users] Capture current value for set pointcut
>
>You should be able to get the current value if you use before advice.
>Of the top of my head (and hence with likely errors...):
>
>before(MyClass object): set(* Class.foo) && this(object) &&
>args(newValue) {
>        
>System.out.println("Old: "+object.getFoo());
>        
>System.out.println("New: "+newValue);
>}
>
>This assumes you have a "getFoo()" method. If so, be careful about
>advice on get(* Class.foo)!  Alternatively, you could reference
>object.foo directly if foo is package private and the aspect is in
>the same package, etc.
>
>dean
>
>On Jun 16, 2008, at 7:55 AM, Ashley Williams wrote:
>
>Hi,
>
>
>I would like to be able to inspect the current value of a field in
>addition to the value that is being assigned to it during the
>application of my advice. I am using the set pointcut designator in
>my advice and I can determine the name of the field using
>thisJoinPoint.getSignature().getName(), but not the value.
>
>
>This is for an automatic event mechanism where I need name, oldValue
>and newValue.
>
>
>Is this even possible?
>
>
>Thanks
>
>- Ashley
>
>

>---
>

>
> This e-mail may contain confidential and/or privileged information.
>If you are not the intended recipient (or have received this e-mail
>in error) please notify the sender immediately and delete this
>e-mail. Any unauthorized copying, disclosure or distribution of the
>material in this e-mail is strictly forbidden.
>

>
> Please refer to 
>http://www.db.com/en/content/eu_disclosures.htm
> for additional EU corporate and regulatory disclosures.
>
> _______________________________________________
>
>aspectj-users mailing list
>
>aspectj-users@xxxxxxxxxxx
>
>https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>

>Dean Wampler, Ph.D.
>dean at objectmentor.com
>http://www.objectmentor.com
>See also:
>http://www.aspectprogramming.com
>  AOP advocacy site
>http://aquarium.rubyforge.org
>     AOP for Ruby
>http://www.contract4j.org
>         Design by Contract for Java5
>
>
>

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

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional EU corporate and regulatory disclosures.


Back to the top