Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AJDT » Capturing annotations
Capturing annotations [message #57950] Wed, 26 October 2005 08:29 Go to next message
Benjamin Podszun is currently offline Benjamin Podszun
Messages: 4
Registered: July 2009
Junior Member
Hi there.

New to AspectJ I did some basic examples and now I want to use it to solve
real problems ;)
For my current work I planned to tag some methods with annotations to
provide security checks without implementing those several times. Is this
a good practice at all?
First tests work so far, but I'd like to use the information in my
annotation for the advice. Example:

@Guarded("AdminsOnly")
public void whatever() {}

I can match this join point using call(@Guarded * *(..)), but I see no way
to access the string value (or other values) later.

before() : call(@Guarded * *(..)) {
// I want to access the annotation here..
}

Using Google I always end up with the annotation-based way of using
AspectJ, the only usable info was http://ramnivas.com/blog/index.php?p=10
- but that's only a proposal and over a year old.

Can anyone lend me a helping hand here and tell me if it's a)
viable/okay/good practice to do what I plan to do here and b) how one is
supposed to access annotations of thisJoinPoint?

Thanks in advance,
Ben
Re: Capturing annotations [message #57972 is a reply to message #57950] Wed, 26 October 2005 10:49 Go to previous message
Matt Chapman is currently offline Matt Chapman
Messages: 429
Registered: July 2009
Senior Member
Hi Ben,

The best place to look for things like this is the developer's notebook,
such as:
http://eclipse.org/aspectj/doc/next/adk15notebook/annotation s-pointcuts-and-advice.html

Look for the context exposure subsection - near the end of that is a
snippet that uses thisJoinPointStaticPart.getSignature() to get the
corresponding
java.lang.reflect.Method object, then you can call
getAnnotation/getAnnotations on that.

BTW, the aspectj-users list is best for language questions. This newsgroup
is primarily for AJDT-specific stuff. We do try to monitor both, but the
mailing list has a bigger audience so you might get a faster/better
response.

Regards,

Matt.

Benjamin Podszun wrote:

> Hi there.

> New to AspectJ I did some basic examples and now I want to use it to solve
> real problems ;)
> For my current work I planned to tag some methods with annotations to
> provide security checks without implementing those several times. Is this
> a good practice at all?
> First tests work so far, but I'd like to use the information in my
> annotation for the advice. Example:

> @Guarded("AdminsOnly")
> public void whatever() {}

> I can match this join point using call(@Guarded * *(..)), but I see no way
> to access the string value (or other values) later.

> before() : call(@Guarded * *(..)) {
> // I want to access the annotation here..
> }

> Using Google I always end up with the annotation-based way of using
> AspectJ, the only usable info was http://ramnivas.com/blog/index.php?p=10
> - but that's only a proposal and over a year old.

> Can anyone lend me a helping hand here and tell me if it's a)
> viable/okay/good practice to do what I plan to do here and b) how one is
> supposed to access annotations of thisJoinPoint?

> Thanks in advance,
> Ben
Re: Capturing annotations [message #590690 is a reply to message #57950] Wed, 26 October 2005 10:49 Go to previous message
Matt Chapman is currently offline Matt Chapman
Messages: 429
Registered: July 2009
Senior Member
Hi Ben,

The best place to look for things like this is the developer's notebook,
such as:
http://eclipse.org/aspectj/doc/next/adk15notebook/annotation s-pointcuts-and-advice.html

Look for the context exposure subsection - near the end of that is a
snippet that uses thisJoinPointStaticPart.getSignature() to get the
corresponding
java.lang.reflect.Method object, then you can call
getAnnotation/getAnnotations on that.

BTW, the aspectj-users list is best for language questions. This newsgroup
is primarily for AJDT-specific stuff. We do try to monitor both, but the
mailing list has a bigger audience so you might get a faster/better
response.

Regards,

Matt.

Benjamin Podszun wrote:

> Hi there.

> New to AspectJ I did some basic examples and now I want to use it to solve
> real problems ;)
> For my current work I planned to tag some methods with annotations to
> provide security checks without implementing those several times. Is this
> a good practice at all?
> First tests work so far, but I'd like to use the information in my
> annotation for the advice. Example:

> @Guarded("AdminsOnly")
> public void whatever() {}

> I can match this join point using call(@Guarded * *(..)), but I see no way
> to access the string value (or other values) later.

> before() : call(@Guarded * *(..)) {
> // I want to access the annotation here..
> }

> Using Google I always end up with the annotation-based way of using
> AspectJ, the only usable info was http://ramnivas.com/blog/index.php?p=10
> - but that's only a proposal and over a year old.

> Can anyone lend me a helping hand here and tell me if it's a)
> viable/okay/good practice to do what I plan to do here and b) how one is
> supposed to access annotations of thisJoinPoint?

> Thanks in advance,
> Ben
Previous Topic:Capturing annotations
Next Topic:Multiple instances of the same class woven against different aspects in an Eclipse plugin [Cross-pos
Goto Forum:
  


Current Time: Sat Aug 30 02:23:46 EDT 2014

Powered by FUDForum. Page generated in 0.01597 seconds