1 16 17 package org.springframework.aop.framework; 18 19 import org.aopalliance.intercept.MethodInvocation; 20 import org.springframework.aop.support.DelegatingIntroductionInterceptor; 21 22 23 31 public class LockMixin extends DelegatingIntroductionInterceptor implements Lockable { 32 33 34 private boolean locked; 35 36 public void lock() { 37 this.locked = true; 38 } 39 40 public void unlock() { 41 this.locked = false; 42 } 43 44 47 public boolean locked() { 48 return this.locked; 49 } 50 51 58 public Object invoke(MethodInvocation invocation) throws Throwable { 59 if (locked() && invocation.getMethod().getName().indexOf("set") == 0) 60 throw new LockedException(); 61 return super.invoke(invocation); 62 } 63 64 } | Popular Tags |