Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Limiting declare @field to classes/aspects


I have the following use case:

I want to add annotation using declare @field. For example, I have a class 

public class Flight {
private String number;
private String airline;
private String departureAirport;
private String arrivalAirport;
 private Date departureTime;
 
private Date arrivalTime;
...
}
I want to add annotations to all fields, let's say @MyAnnotation.


public privileged aspect FlightTrackerAspect  {


declare @type : *Flight : @MyAnnotation;
}

That works fine. But, let's say I have another aspect that adds a field through ITD to Flight.

public aspect PersistentAspect {

     private int Flight.persistenceDate;
}

I don't want @MyAnnotation to apply to persistenceDate introduced in PersistentAspect. Is there a way to do so ?

I imagine to have 
declare @type : *Flight && within(Flight): @MyAnnotation;

But I dont think it is possible.

Any ideas ? 

Best regards,
Anwar.


Back to the top