Annotations - Declare Errors
Declaring errors You declare an error in the same way as a warning, but you use the @DeclareError annotation instead. Modify DeclareAspect so that it becomes: import org.jboss.aop.DeclareError; import org.jboss.aop.Aspect; import org.jboss.aop.pointcut.Pointcut; @Aspect public class DeclareAspect { @DeclareError (expr="class($instanceof{VehicleDAO}) AND !has(public void *->save())", msg="All VehicleDAO subclasses must override the save() method.") public static Pointcut warning1; @DeclareError (expr="call(Driver->new(..)) AND within(*DAO)", msg="DAO classes should not access the Driver class") public static Pointcut warning2; @DeclareError (expr="call(* Driver->*(..)) AND withincode(* *DAO->save())", msg="DAO classes should not access the Driver class") public static Pointcut warning3; }