BaseTransactionalExecutor implements Executor { @Override public Object execute(Object... args) throws Throwable { if (RootContext.inGlobalTransaction()) { String xid = RootContext.getXID(); statementProxy.getConnectionProxy().bind(xid); } if (RootContext.requireGlobalLock()) { statementProxy.getConnectionProxy().setGlobalLockRequire(true); } else { statementProxy.getConnectionProxy().setGlobalLockRequire(false); } return doExecute(args); } BaseTransactionalExecutor(StatementProxy<S> statementProxy, StatementCallback<T, S> statementCallback,
                                     SQLRecognizer sqlRecognizer); @Override Object execute(Object... args);  }
@SuppressWarnings({"rawtypes", "unchecked"}) @Test public void testExecuteWithGlobalLockSet() throws Exception { ConnectionProxy connectionProxy = new ConnectionProxy(null, null); StatementProxy statementProxy = new StatementProxy<>(connectionProxy, null); BaseTransactionalExecutor<Object, Statement> baseTransactionalExecutor = new BaseTransactionalExecutor<Object, Statement>(statementProxy, null, null) { @Override protected Object doExecute(Object... args) { return null; } }; GlobalLockTemplate<Object> globalLockLocalTransactionalTemplate = new GlobalLockTemplate<>(); ((Callable<Object>) () -> { try { baseTransactionalExecutor.execute(new Object()); Assertions.assertTrue(!connectionProxy.isGlobalLockRequire(), "conectionContext set!"); } catch (Throwable e) { throw new RuntimeException(e); } return null; }).call(); globalLockLocalTransactionalTemplate.execute(new Callable<Object>() { @Override public Object call() throws Exception { try { baseTransactionalExecutor.execute(new Object()); Assertions.assertTrue(connectionProxy.isGlobalLockRequire(), "conectionContext not set!"); } catch (Throwable e) { throw new RuntimeException(e); } return null; } }); }