pointcuts using annotations [message #64815] |
Tue, 09 May 2006 07:20  |
Eclipse User |
|
|
|
Hi!
Newbie to AOP and even though I read up prior to actually starting I have a
problem with a simple pointcut.
1. I want to declare a pointcut that matches methods that:
i. makes calls to all getters in xyz.SomeBean (is not that possible?)
and
ii. are in classes in the package abc and have the annotation
@Transactional
2. I want to mark those poincuts with an error
package abc;
public class ABC
{
/**
* @Transactional
*/
public void doSomething() {return;}
}
a) It works to just match 1.i.
pointcut ALL(): call(* xyz.SomeBean.get*(..));
b) Then I thought that
pointcut ONLYANNOTATED_1(): @Transactional * *(..) && call(*
xyz.SomeBean.get*(..));
would work but nope. Hence, I never tried to narrow down the pointcut just
to match method annotations in the abc package.
Neither does:
pointcut ONLYANNOTATED_2(): @Transactional * *(..);
The error message I get in Eclipse/AJDT is:
"Syntax error on token "Transactional", "pointcut name" expected"
Can anyone help me with the correct syntax?
Regards,
Jimisola
|
|
|
Re: pointcuts using annotations [message #64839 is a reply to message #64815] |
Tue, 09 May 2006 14:30  |
Eclipse User |
|
|
|
I managed to get it right by myself after much trouble :)
However, I am quite sure that I will soon stumble into new problems in the
world of AOP.
I do have another pointcut question.
a)
pointcut TRANSACTIONAL(Transactional transactionalAnnotation):
execution(@Transactional * se.stickybit.X.server..*(..)) &&
@this(transactionalAnnotation);
b)
pointcut TRANSACTIONAL(Transactional transactionalAnnotation): execution(*
se.stickybit.X.server..*(..)) && @this(transactionalAnnotation);
note the difference: @Transactional immedietly after "execution("
a) works as expected, i.e. only matching methods with the annotation
@Transactional. While b) matching everything.
So, what does @this actually do? Does it only make the annotation in the
join point available in the point cut?
If so, what happens if a matched method does not have the annotation (here
@Transactional) - will transactionalAnnotation be null?
Regards,
Jimisola
"Jimisola Laursen" <public@jimisola.com> wrote in message
news:e3pu1q$vfa$1@utils.eclipse.org...
> Hi!
>
> Newbie to AOP and even though I read up prior to actually starting I have
> a
> problem with a simple pointcut.
>
> 1. I want to declare a pointcut that matches methods that:
> i. makes calls to all getters in xyz.SomeBean (is not that possible?)
> and
> ii. are in classes in the package abc and have the annotation
> @Transactional
> 2. I want to mark those poincuts with an error
>
>
> package abc;
>
> public class ABC
> {
> /**
> * @Transactional
> */
> public void doSomething() {return;}
> }
>
>
> a) It works to just match 1.i.
>
> pointcut ALL(): call(* xyz.SomeBean.get*(..));
>
> b) Then I thought that
>
> pointcut ONLYANNOTATED_1(): @Transactional * *(..) && call(*
> xyz.SomeBean.get*(..));
>
> would work but nope. Hence, I never tried to narrow down the pointcut just
> to match method annotations in the abc package.
>
> Neither does:
>
> pointcut ONLYANNOTATED_2(): @Transactional * *(..);
>
>
> The error message I get in Eclipse/AJDT is:
>
> "Syntax error on token "Transactional", "pointcut name" expected"
>
>
> Can anyone help me with the correct syntax?
>
> Regards,
> Jimisola
>
>
|
|
|
Re: pointcuts using annotations [message #593602 is a reply to message #64815] |
Tue, 09 May 2006 14:30  |
Eclipse User |
|
|
|
I managed to get it right by myself after much trouble :)
However, I am quite sure that I will soon stumble into new problems in the
world of AOP.
I do have another pointcut question.
a)
pointcut TRANSACTIONAL(Transactional transactionalAnnotation):
execution(@Transactional * se.stickybit.X.server..*(..)) &&
@this(transactionalAnnotation);
b)
pointcut TRANSACTIONAL(Transactional transactionalAnnotation): execution(*
se.stickybit.X.server..*(..)) && @this(transactionalAnnotation);
note the difference: @Transactional immedietly after "execution("
a) works as expected, i.e. only matching methods with the annotation
@Transactional. While b) matching everything.
So, what does @this actually do? Does it only make the annotation in the
join point available in the point cut?
If so, what happens if a matched method does not have the annotation (here
@Transactional) - will transactionalAnnotation be null?
Regards,
Jimisola
"Jimisola Laursen" <public@jimisola.com> wrote in message
news:e3pu1q$vfa$1@utils.eclipse.org...
> Hi!
>
> Newbie to AOP and even though I read up prior to actually starting I have
> a
> problem with a simple pointcut.
>
> 1. I want to declare a pointcut that matches methods that:
> i. makes calls to all getters in xyz.SomeBean (is not that possible?)
> and
> ii. are in classes in the package abc and have the annotation
> @Transactional
> 2. I want to mark those poincuts with an error
>
>
> package abc;
>
> public class ABC
> {
> /**
> * @Transactional
> */
> public void doSomething() {return;}
> }
>
>
> a) It works to just match 1.i.
>
> pointcut ALL(): call(* xyz.SomeBean.get*(..));
>
> b) Then I thought that
>
> pointcut ONLYANNOTATED_1(): @Transactional * *(..) && call(*
> xyz.SomeBean.get*(..));
>
> would work but nope. Hence, I never tried to narrow down the pointcut just
> to match method annotations in the abc package.
>
> Neither does:
>
> pointcut ONLYANNOTATED_2(): @Transactional * *(..);
>
>
> The error message I get in Eclipse/AJDT is:
>
> "Syntax error on token "Transactional", "pointcut name" expected"
>
>
> Can anyone help me with the correct syntax?
>
> Regards,
> Jimisola
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.06427 seconds