How about using the Command Pattern?
abstract class MyLoggingCommandPart {
MyLoggingCommandPart() {
log.info("Entering execute part");
executeWithoutLogging();
log.info("Exiting execute part");
}
abstract void executeWithoutLogging();
}
abstract class MyLoggingCommandWhole {
MyLoggingCommandWhole() {
log.info("Entering execute whole");
executeWithoutLogging();
log.info("Exiting execute whole");
}
abstract void executeWithoutLogging();
}
public final class MyBusinessFunction extends BaseFunction {
@Override
public final void execute() {
new MyLoggingCommandWhole(){
@Override
executeWithoutLogging(){
new MyLoggingCommandPart(){
@Override
executeWithoutLogging(){
// ... what I actually wanne do
}
}
new MyLoggingCommandPart(){
@Override
executeWithoutLogging(){
// ... some more stuff I actually wanne do
}
}
}
}
}
}