package dw.wevoked.aspects; import java.util.Date; import org.prevayler.Transaction; import org.prevayler.TransactionWithQuery; /** * @author Eric * * Enforces persistent storage access. */ public aspect PersistentStorageAccess { //MAKE USE OF TRANSACTION METHODS //those are calls to methods that change combination of business objects pointcut callToInternalAdd(): call(public dw.wevoked.storage.prevalence.businessobjects.* dw.wevoked.storage.prevalence.businessobjects.*.add*()); pointcut callToInternalRemove(): call(public dw.wevoked.storage.prevalence.businessobjects.* dw.wevoked.storage.prevalence.businessobjects.*.remove*()); pointcut callToInternalSet(): call(public dw.wevoked.storage.prevalence.businessobjects.* dw.wevoked.storage.prevalence.businessobjects.*.set*()); pointcut criticalCall(): callToInternalAdd() || callToInternalRemove() || callToInternalSet(); //inside this region, such calls are allowed pointcut withinTransactionMethod(): withincode(public void Transaction+.executeOn(Object,Date)) || withincode(public Object TransactionWithQuery+.executeAndQuery(Object,Date)); //we do not allow such methods to be called outside of transaction methods declare error: criticalCall() && !withinTransactionMethod() : "Internal manipulation of prevayler business object not allowed. Create Transaction instead."; //DO NOT USE DEFAULT CONSTRUCTORS ON TRANSACTIONS declare error: call((Transaction+||TransactionWithQuery+).new()) : "Default constructor for prevayler transactions is for serialization purposes only."; }