I solved this by
using + wildcard.
So the pointcut
definition looks like
execution
(public
com.arisglobal.aglite.entities.AbstractBusinessEntity+
|| java.util.List<AbstractBusinessEntity+>
|| java.util.Set<AbstractBusinessEntity+>
!@DoNotAudit
AbstractBusinessEntity
+.get*())
&& this(entity);
Regards,
Shashi
From:
aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx]
On Behalf Of Shashikant Kale
Sent: Monday, March 30, 2009 5:07
PM
To: aspectj-users@xxxxxxxxxxx
Subject: RE: [aspectj-users] Help
required to define pointcutforgettersreturning a specific
type.
Thanks
Neale,
So wouldn’t I be able
to intercept all the getters returning a particular type? Please note that if
I change the return value in the pointcut to * the following pointcut works.
So in the method definition even if I use base class it works, but in the
return type I can’t use base classL
Thanks and
Regards,
Shashi
From:
aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx]
On Behalf Of Neale
Upstone
Sent: Monday, March
30, 2009 4:59 PM
To:
aspectj-users@xxxxxxxxxxx
Subject: RE: [aspectj-users] Help
required to define pointcut forgettersreturning a specific
type.
Hi,
I've not tried your
code, but I suspect it's because your return values are not your base entity,
in one instance.
The other is a common
mistake. You're using execution() with target() when you should be using
this().
You could
try:
public
pointcut
auditCompositeGetter(AbstractBusinessEntity entity) :
(execution
(public
AbstractBusinessEntity+ AbstractBusinessEntity +.get*())
||
execution
(public
Collection<AbstractBusinessEntity+> AbstractBusinessEntity
+.get*()))
&& this(entity);
From:
aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx]
On Behalf Of Shashikant Kale
Sent: 30 March 2009 12:19
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] Help required
to define pointcut for gettersreturning a specific
type.
Hello
Everybody,
I am trying to define a pointcut
to intercept all the calls to getter methods of following
types.
public class A extends
AbstractBusinessEntity{
private String test1;
private List<B> bCollection;
private C c;
public String
getTest1(){
// I don’t want to intercept
these getters
return
this.test1;
}
public List<B>
getBCollection(){
// I want to intercept all such getters
return
this.bCollection;
}
public C
getC(){
return this.c;
}
}
public class B extends
AbstractBusinessEntity{
public String test2;
…
….
}
public class C extends
AbstractBusinessEntity{
public String test3;
…
….
}
I am trying to define the
pointcut as below
public
pointcut
auditCompositeGetter(AbstractBusinessEntity entity) :
(execution
(public
AbstractBusinessEntity AbstractBusinessEntity +.get*())
||
execution
(public
Collection<AbstractBusinessEntity> AbstractBusinessEntity
+.get*()))
&& target(entity);
However at the advice definition
it gives a warning saying advice is not applied since it didn’t match. Could
anyone please let me know if there is any problem with the pointcut
definition above?
Thanks and
Regards,
Shashi
Legal Notice: This transmission, including any
attachments, is confidential, proprietary, and may be privileged. It is
intended solely for the intended recipient. If you are not the intended
recipient, you have received this transmission in error and you
are hereby advised that any review, disclosure, copying, distribution, or
use of this transmission, or any of the information included therein, is
unauthorized and strictly prohibited. If you have received this
transmission in error, please immediately notify the sender by reply and
permanently delete all copies of this transmission and its
attachments