A more sophisticated MoneyLogger.
- By Mathias Richter and Takashi Suezawa
- July 18, 2000
Power Java
Dynamic Proxy Classes:
Toward Metalevel Programming in Java
Mathias Richter and Takashi Suezawa
Listing 9. A more sophisticated MoneyLogger.
public class MoneyLogger
extends Aspect
implements IMoney
{
private double fOldAmount;
... // implementation of other methods
public void setAmount(double amount)
{
IMoney primary = (IMoney)getPrimary();
if ( getPhase() == BEFORE )
fOldAmount = primary.getAmount();
if ( getPhase() == AFTER )
System.out.println( primary + ": Set amount from " +
fOldAmount + " to " + amount );
}
}