| 1 package com.tirsen.nanning.samples.prevayler; 2 3 import java.lang.reflect.Method ; 4 5 import com.tirsen.nanning.*; 6 import com.tirsen.nanning.attribute.Attributes; 7 8 public class CheckTransactionUnsupportedInterceptor implements MethodInterceptor { 9 private static ThreadLocal transactionsUnsupported = new ThreadLocal (); 10 11 static boolean isTransactionsSupported() { 12 return transactionsUnsupported.get() == null; 13 } 14 15 static void enterTransactionsUnsupported() { 16 transactionsUnsupported.set(transactionsUnsupported); 17 } 18 19 static void exitTransactionsUnsupported() { 20 transactionsUnsupported.set(null); 21 } 22 23 public Object invoke(Invocation invocation) throws Throwable { 24 if (!isTransactionsSupported()) { 25 throw new IllegalStateException ("Transactions are not supported in the current calling context."); 26 } 27 28 return invocation.invokeNext(); 29 } 30 } 31 | Popular Tags |