Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] obtaining aspect value from advice around field get pointcut

Thanks for the fast response.

I got this to work with two notes:

- I had to make the aspect use runtime retention, which should not be required according to the docs which say this is only the case for args, target and this.
- I did not need your correction to the get pointcut...assume because one of these is optional in certain circumstances...I often have trouble figuring out when I need an asterisk and when I don't, but this works with just two!



Inactive hide details for Dean Wampler <dean@xxxxxxxxxxxxxxxxxxxxx>Dean Wampler <dean@xxxxxxxxxxxxxxxxxxxxx>


          Dean Wampler <dean@xxxxxxxxxxxxxxxxxxxxx>
          Sent by: aspectj-users-bounces@xxxxxxxxxxx

          03/13/2008 10:46 AM

          Please respond to
          aspectj-users@xxxxxxxxxxx

To

aspectj-users@xxxxxxxxxxx

cc


Subject

Re: [aspectj-users] obtaining aspect value from advice around field get pointcut

On Mar 13, 2008, at 8:05 AM, Christian.Hall@xxxxxxxxxxx wrote:
      My inability to figure this out may be based on my weak understanding of how the get pointcut works in fhe first place, so I apologize in advance.

      I have something like the following in a class:

      Class Foo
      {
      @MyAnnotation("aValue")
      private String field;
      }

      and within an aspect:

      String around() : get(@MyAnnotation * *)
      {
      //HERE
      }

Change this to

String around(MyAnnotation annotation) : get(@MyAnnotation * *.*) && @annotation(annotation) {
// do something with annotation.value(); // Get the string in the annotation.
}

Note that your get(...) had a little bug; the 3 '*' are the type, class, and field.

Hope this helps.

Dean



      How do I get the value of "aValue" from within the advice (marked //HERE)? I can get the target class and find fields, etc...but I need to know which field is the "target" (don't think it is considered a target from AspectJ's perspective) of the pointcut, etc.











      This message contains information from Equifax Inc. which may be confidential and privileged. If you are not an intended recipient, please refrain from any disclosure, copying, distribution or use of this information and note that such actions are prohibited. If you have received this transmission in error, please notify by e-mail
      postmaster@xxxxxxxxxxx.

      _______________________________________________
      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


GIF image

GIF image

GIF image


Back to the top