A simple MoneyLogger.

Power Java
Dynamic Proxy Classes:
Toward Metalevel Programming in Java

Mathias Richter and Takashi Suezawa
Listing 7. A simple MoneyLogger.


public class MoneyLogger
      extends Aspect
      implements IMoney
{
	   ... // implementation of other methods

	   public void setAmount(double amount)
	   {
		    int phase = getPhase();
		    if ( phase == BEFORE )
              System.out.println( "before setting amount to " + amount);
		    else if ( phase == AFTER )
		      System.out.println( "amount set to " + amount );
	   }
}