[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] Help required to define pointcut for gettersreturning a specific type.

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,


 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


Confidentiality:  This e-mail and its attachments are intended for the above named only and may be confidential.  If they have come to you in error you must take no action based on them, nor must you copy or show them to anyone; please reply to this e-mail and highlight the error.
Security Warning:  Please note that this e-mail has been created in the knowledge that Internet e-mail is not a 100% secure communications medium.
We advise that you understand and observe this lack of security when e-mailing us.
Viruses:  Although we have taken steps to ensure that this e-mail and attachments are free from any virus, we advise that in keeping with good computing practice the recipient should ensure they are actually virus free.
Monitoring and Scanning:  Cambridge Cognition has monitoring and scanning systems in place in relation to emails sent and received to: monitor / record business communications; prevent and detect crime; investigate the use of the Company's internal and external email system; and provide evidence of compliance with business practices.

Cambridge Cognition Limited
Company Registration Number 4338746
Registered address:
Tunbridge Court
Tunbridge Lane
CB25 9TU