日期:2014-05-16 浏览次数:20435 次
package cn.pc.ua.util.aop;
@Target(value = ElementType.METHOD)
@Retention(value = RetentionPolicy.RUNTIME)
public @interface DbLock {
public String value() default "";
public int id() default Integer.MIN_VALUE;
}
@Pointcut("@annotation(cn.pc.ua.util.aop.DbLock)")//切点
private void pointCutMethod() {
}
@Around("pointCutMethod()")
public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
DefaultTransactionDefinition arg0 = new DefaultTransactionDefinition();
arg0.setIsolationLevel(TransactionDefinition.ISOLATION_SERIALIZABLE);
TransactionStatus ts = txManager.getTransaction(arg0);
//.....
Object object = pjp.proceed();
log.debug("release db lock !");
txManager.commit(ts);
//.....
}