/* * Created on 03.01.2005 * * $Id: KontoAspect.aj,v 1.1 2005/06/24 13:56:05 boehm Exp $ */ package casino; import java.io.*; /** * @author oliver * @since 03.01.2005 * @version $revision$ */ public aspect KontoAspect { /** * Falls das Konto ueberzogen wird, wird automatisch eine Exception * ausgeloest. */ before(int betrag, Konto kto) : execution(public void Konto.abheben(int)) && args(betrag) && this(kto) { if (betrag > kto.abfragen()) { throw new RuntimeException("Konto ueberzogen"); } } /** * Bei jeder Kontostand-Aenderung wird diese automatisch abgespeichert. */ after(Konto kto) : set(private int Konto.kontostand) && this(kto) { try { kto.store(); } catch (IOException e) { System.err.println("kann Konto " + kto + " nicht abspeichern"); } } }