Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Newbie question on inter-type member declarations

Hello!
 
 
I'm wondering if it's possible in AspectJ to add inter-type member declarations based on pointcuts? A little example to illustrate what I mean: 
 
We have a web application using Struts. For convenience we have introduced a naming convention requiring certain properties in our domain model classes to have extra ...AsString properties that formats the properties correctly for presentation in web pages (using Struts taglibs). So if we have a property 'salary' in the Employee class we will also have a property 'salaryAsString' that returns the salary (originally a double) as a string with thousand separators and two decimal precision.
 
Is it possible to enforce this convention throughout the application with an aspect? Of course, We could list each ...AsString method as an inter-type member declaration in the aspect, but that won't be much of an improvement wrt programming effort. It would be much better if we could make a pointcut selecting all get and set methods of interest and then apply an advice on them that added the extra methods...
 
Regards,
 
 
Are Meisfjord
 

Back to the top