Skip to main content

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

Good to hear!
 
I'm not totally sure without going to the documentation for AspectJ5, but I'd double check on the matcher for the generic List<> and Set<>.  I suspect that those equate to List<?> and Set<?>.  Andy Clement will be able to clarify that (in a few hours... I suspect the sun is only just coming up), as he's maintaining the AJ compiler.

Cheers,

Neale


From: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Shashikant Kale
Sent: 30 March 2009 12:53
To: aspectj-users@xxxxxxxxxxx
Subject: RE: [aspectj-users] Help required to definepointcutforgettersreturning a specific type.

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

 

**********************************************************************
IMPORTANT NOTICE.
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
Bottisham
Cambridge
CB25 9TU
UK
**********************************************************************
**********************************************************************
IMPORTANT NOTICE.
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
Bottisham
Cambridge
CB25 9TU
UK
**********************************************************************


Back to the top