Active Objects takes your interface and, via reflection through a complicated proxy translates your getters, setters and relations into SQL statements. If you want some of your own code in there to add or modify functionality of your AO interface, you can use @Implementation
Example:
AO interface:
@Implementation(PersonImpl.class)
public interface Person extends Entity {
String getLastName();
void setLastName(String name);
String getFirstName();
void setFirstName(String name);
@Ignore
String getName();
}
Implementation:
public class PersonImpl {
private final Person person; // this will be the original entity proxy
public PersonImpl(Person person) {
this.person = person;
}
// "Implement" ignored functions
public String getName() {
return String.format("%s %s", this.person.getFirstName(), this.person.getLastName());
}
// "Enhance" AO getters/setters
public void setFirstName(String name) {
this.person.setFirstName("Foobar");
}
}
Note that AO accesses these implementation methods via reflection. They must match the names in the interface. This might lead to problems during refactorings, as method names might change and your compiler won't tell you that your corresponding impl method name hasn't.