| Re: [aspectj-users] selecting join points using annotations |
Ok...I almost have it working.Here is my aspect:public
aspect Encryption { pointcut encrypt(String data): args(data) && execution(public void com.company..model.*.set*(String)); pointcut decrypt(): execution(public String com.company.model.*.get*()); void around(String data) : encrypt(data) {String encryptedData = encryptData(data);
proceed(encryptedData);}
String
around(): decrypt() {String encryptedData =
proceed();String decryptedData = decryptData(encryptedData);
return decryptedData;}
private String encryptData(String data) { // dummy implementation return data;}
private String decryptData(String data) { // dummy implementation return data;}
}
This works...as in it picks out all model getter/setter methods.
However, when I add the annotation selection criteria:
pointcut encrypt(String data): args
(data) && execution(@Encrypt public void com.company..model.*.set*(String)); pointcut decrypt(): execution(@Decrypt public String com.company.model.*.get*());AJDT reports this as a warning and the selections no longer match.
I get "no match for this type name: Encrypt[Xlint:invalidAbsoluteTypeName]"
The @Encrypt annotation is defined and I have one method on a single model annotated.
Any ideas on why the join point selection with the annotation doesn't seem to work?
/robert
Sent: Saturday, September 19, 2009 6:58 AMSubject: Re: [aspectj-users] selecting join points using annotationsI guess I didn't look enough:Thanks again Ramnivas.----- Original Message -----From: Robert TaylorSent: Saturday, September 19, 2009 6:26 AMSubject: Re: [aspectj-users] selecting join points using annotationsPerfect!I didn't see any selection examples using annotations so I was unsure on how to use them in the join point.Thank you Ramnivas/robert----- Original Message -----From: Ramnivas LaddadSent: Friday, September 18, 2009 11:51 PMSubject: Re: [aspectj-users] selecting join points using annotationsThis is easily possible:
pointcut encryptionOp(String data) : execution(@Encrypt void *(String)) && args(data);
void around(String data) : encryption(data) {
proceed(encrypt(data));
}
pointcut decryptionOp() : execution(@Decrypt String *(..));
String around() : decryptionOp() {
String encryptedData = proceed();
return decrypt(encryptedData);
}
-Ramnivas
On Fri, Sep 18, 2009 at 6:47 PM, Robert Taylor <rtaylor@xxxxxxxxxxxxxx> wrote:
Greetings,I have a need to leverage AOP to encrypt certain POJO setter String args prior to persisting them to the database
and to decrypt certain POJO getter methods return String values after they have retrieved String data from the database.I wanted to do this using annotations. For example:@Encryptpublic void setCreditCardNumber(String ccn) ...@Decryptpublic String getCreditCardNumber()...I've looked into the Security Annotations Framework (http://safr.sourceforge.net/)and it looked promising, however, it can only be used if you are using Maven to build
your project. Unfortunately, I have no immediate plans to use Maven.I haven't found any similar projects which simply use Ant tags; so I'm attempting to "roll my own" solution.I've read through the AspectJ language docs and haven't found any information on selecting join points using annotations.I browsed the docs on AspectJ 5 Developers Notebook regarding annotations, but it doesn't look like what I need.I only want the methods selected by AspectJ if they have been properly identified using an annotation.Is this possible with the current AspectJ version?/robert
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users