/* * Created on Jul 13, 2004 */ package verwaltung; import java.util.*; import org.aspectj.lang.*; import org.aspectj.lang.annotation.*; import org.aspectj.lang.reflect.*; /** * Leiter geheh mit AspectJ 1.5.0M2 die @AspectJ-Annotations noch nicht, * deswegen sind sie noch auskommentiert */ //@Aspect(instantiationModel=AspectInstantiationModel.PERTHIS, // perClausePattern="this(Person)") //public class ArbeitszeitAspekt { //public aspect ArbeitszeitAspekt perthis(this(Person)) { /** * Naechster Versuch mit AspectJ 1.5.0M3... * * @Aspect("perthis(this(verwaltung.Person))" * -> gibt "can't do instanceof matching on paterns with wildcards" * @Aspect("perthis(this(Person))") * -> keine Fehlermeldung, aber jetzt gibt's gar keine Ausgabe */ @Aspect public class ArbeitszeitAspekt { long start; long end; /** * ermittle Arbeitszeit */ // void around(Person x) : // execution(public void Person.arbeite()) && this(x) { // start = System.currentTimeMillis(); // proceed(x); // end = System.currentTimeMillis(); // System.out.println("Arbeitszeit " + x + ": " + new Date(start) // + " - " + new Date(end)); // } @Around("execution(public void verwaltung.Person.arbeite()) && this(x)") public void watchWorkingHours(ProceedingJoinPoint thisJoinPoint, Person x) { start = System.currentTimeMillis(); thisJoinPoint.proceed(new Object[] {x}); end = System.currentTimeMillis(); System.out.println("*** ARBEITSZEIT " + x + ": " + new Date(start) + " - " + new Date(end)); } }