Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Introducing fields; can the type be changed?


I'm presuming you know that you can do this:

public aspect NakedCustomer {

  declare parents : Customer implements NakedObject;

   private TextString Customer.no$LastName;
   private TextString Customer.no$FirstName;

}

but there is no generic way in aspectj to say "whenever you see a field matching pattern A, make an inter-type declaration of the form...".

 I'm guessing that you could probably use the JET framework in Eclipse (http://www.eclipse.org/articles/Article-JET/jet_tutorial1.html, http://www.eclipse.org/articles/Article-JET2/jet_tutorial2.html) to quickly write something that would take as input a set of POJO classes, and create as output a set of aspects that can be used to turn them into NakedObjects. A combination like that seems the ideal way to go here, but I've never had to use JET yet, so I can't vouch for it personally. I'd be really interested to know if you get this to work though, because the general pattern of easily generating aspects that customize application classes in pre-defined ways (where simple library aspects won't work) would be useful to a reasonably large body of users I suspect.

-- Adrian
Adrian_Colyer@xxxxxxxxxx



Dan Haywood <dan@xxxxxxxxxxxxxxxxxxxxxxxx>
Sent by: aspectj-users-admin@xxxxxxxxxxx

14/04/2004 18:13

Please respond to
aspectj-users

To
<aspectj-users@xxxxxxxxxxx>
cc
Dan Haywood <dan@xxxxxxxxxxxxxxxxxxxxxxxx>
Subject
[aspectj-users] Introducing fields; can the type be changed?





I'm trying to write an aspect that takes a POJO and then introduces fields to make it live within the Naked Objects framework (http://www.nakedobjects.org).

For example, where I might have:

public Customer {
private String lastName;
private String firstName;
}

I'd like to introduce:
import org.nakedobjects.object;
//
private TextString no$LastName;
private TextString no$FirstName;
..

or something similar.  Similarly, an int field would correspond to the WholeNumber type in Naked Objects.

I'm stumped on how to do this; my best guess is instead to have a generic Map of TextStrings, but this would force me to modify the framework.  Any help gratefully received.

Many thanks
Dan Haywood




_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top