I would like to apply an annotation to certain method calls so that I can tell aspectj to modify the execution for those calls.
public interface Door {
void open() throws DoorException;
void close() throws DoorException;
}
public class Ferrari {
@Inject @Lightweight Door door;
public void drive() {
open();
close();
open();
}
}
In this case here, I want all open/close operations to effectively be wrapped the same way, but what if I want one to behave differently?
I would like to do something like:
public class Ferrari {
@Inject Door door;
public void drive() {
door.open();
door.close();
@Slowly door.open();
}
}
I realize that I cannot put an annotation there, but at the same token, I don't want to clobber the open signature to pass in optional metadata.
What is the best way to do this?
I could do this:
public class Ferrari {
@Inject Door door;
public void drive() {
door.open();
door.close();
((@Slowly Door)door).open();
}
}