[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] selecting join points using annotations
|
Check your import statements. Do you have the Encrypt type imported?
-Ramnivas
On Sun, Sep 20, 2009 at 6:15 AM, Robert Taylor
<rtaylor@xxxxxxxxxxxxxx> wrote:
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
----- Original Message -----
Sent: Saturday, September 19, 2009 6:58
AM
Subject: Re: [aspectj-users] selecting
join points using annotations
I guess I didn't look enough:
Thanks again Ramnivas.
----- Original Message -----
Sent: Saturday, September 19, 2009 6:26
AM
Subject: Re: [aspectj-users] selecting
join points using annotations
Perfect!
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 -----
Sent: Friday, September 18, 2009
11:51 PM
Subject: Re: [aspectj-users]
selecting join points using annotations
This 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:
@Encrypt
public void setCreditCardNumber(String ccn)
...
@Decrypt
public String
getCreditCardNumber()...
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