Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] How to define a pointcut for intercepting setter using annotation at field level.

Hi,

 

I am using AspecJ to implement audit aspect for auditing the data change in a domain entity.

 

I have created a pointcut as follows.

 

      public pointcut auditValueChange(AbstractBusinessEntity entity) :

        execution (void !@DoNotAudit AbstractBusinessEntity +.set*(*)) && target(entity);

 

As you see there is an annotation ‘DoNotAudit’ which is defined for field and the types. I can restrict the calls to the setters getting called for an entity marked as ‘DoNotAudit’. However how can I restrict the interception of the setter methods for the fields which are marked as ‘DoNotAudit’.

 

The example would be as below:

 

@Entity

public class DomainEntity extends AbstractBusinessEntity implements Serializable{

 

            @DoNotAudit

private String shouldNotBeAudited;

 

public void setShouldNotBeAudited(String value){

            this.shouldNotBeAudited = value;

}

}

 

Please provide any inputs you may have.

 

Thanks in advance,

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

 


Back to the top