/* * Created on 08.05.2005 * * $Id$ */ package verwaltung; import org.aspectj.lang.annotation.*; /* public aspect GefuehlsAspekt { public interface Feeling {}; private String Feeling.sense = "I feel good"; public String Feeling.getSense() { return sense; } declare parents : Person implements Feeling; after(Feeling f) : execution(* *.*(..)) && this(f) && !within(GefuehlsAspekt) { System.out.println(f.getSense()); } // String around(Feeling f) : execution(* *.toString()) && this(f) { // return proceed(f) + " (" + f.getSense() + ")"; // } } */ @Aspect public class GefuehlsAspekt { public interface Feeling { String getSense(); } // declare-Anweisung scheint mit M4 immer no net zu tun //@DeclareParents("verwaltung.Person") public static class FeelingImpl implements Feeling { private String sense = "I feel good"; public String getSense() { return sense; } } // doch, die declare-Anweisung tut jetzt (1.5.0.200510241400) // aber a bißele anders... // @see http://dev.eclipse.org/viewcvs/index.cgi/org.aspectj/modules/docs/adk15ProgGuideDB/ataspectj.xml?rev=HEAD&cvsroot=Technology_Project&content-type=text/vnd.viewcvs-markup //@DeclareParents("verwaltung.Person") //static public Feeling introduced = new FeelingImpl(); // ab AspectJ 1.5.0 (Build 20051220093604) geht's jetzt so: @DeclareParents(value="verwaltung.Person", defaultImpl=FeelingImpl.class) private Feeling introduced; @After("execution(* *.*(..)) && this(f) && !within(GefuehlsAspekt)") public void howdoyoufeeltoday(Feeling f) { System.out.println(f.getSense()); } }