This topic has not yet been written. The content below is from the topic description.
JBoss AOP can be used to enforce certain architectural constraints. The sample application in this example consists of a "business layer" (i.e Driver.java) which can call the "dao layer" (i.e. VehicleDAO and its subclasses MotorbikeDAO and CarDAO). VehicleDAO is an abstract class, and in our architecture for this small application we want to make sure that: All subclasses of VehicleDAO implement a save() method. The dao layer classes should not call back to the business layer classes (i.e. XXXDAO should not call Driver) JBoss AOP allows you to check for this at instrumentation time, so if you are running precompiled AOP, the checks will be done at the aopc stage. If you are using loadtime AOP the checks will be performed when the class is first loaded. Two new XML tags are used for this declare-warning and declare-error, the only difference between them is that declare-error will throw an exception, causing execution to stop, while declare-warning prints out a warning message and continues as normal. Here is the jboss-aop.xml file used for this example: All VehicleDAO subclasses must override the save() method. DAO classes should not access the Driver class DAO classes should not access the Driver class The first declare-warning tag specifies that VehicleDAO and its subclasses must implement a void noargs save() method. This condition is broken in our example by the fact that MotorbikeDAO does not do so. The second declare-warning tag specifies that none of the DAO classes can call the Driver constructor. This condition is broken in our example by the fact that CarDAO.save() tries to create a new Driver class. The third declare-warning tag specifies that no method on any of the the DAO classes can call the Driver methods. This condition is broken in our example by the fact that CarDAO.save() tries to call a method on the Driver class For pointcut expressions, only caller side pointcut expressions will work (so you cannot use all, execution, field, set or get).