private void restoreThreadLocalStatus() { // Use stack to restore old transaction TransactionInfo. // Will be null if none was set. transactionInfoHolder.set(this.oldTransactionInfo); }
/** * Set a ConnectionSpec for this proxy and the current thread. * The given ConnectionSpec will be applied to all subsequent * {@code getConnection()} calls on this ConnectionFactory proxy. * <p>This will override any statically specified "connectionSpec" property. * @param spec the ConnectionSpec to apply * @see #removeConnectionSpecFromCurrentThread */ public void setConnectionSpecForCurrentThread(ConnectionSpec spec) { this.threadBoundSpec.set(spec); }
/** * Expose a read-only flag for the current transaction. * Called by the transaction manager on transaction begin and on cleanup. * @param readOnly {@code true} to mark the current transaction * as read-only; {@code false} to reset such a read-only marker * @see org.springframework.transaction.TransactionDefinition#isReadOnly() */ public static void setCurrentTransactionReadOnly(boolean readOnly) { currentTransactionReadOnly.set(readOnly ? Boolean.TRUE : null); }
/** * Expose whether there currently is an actual transaction active. * Called by the transaction manager on transaction begin and on cleanup. * @param active {@code true} to mark the current thread as being associated * with an actual transaction; {@code false} to reset that marker */ public static void setActualTransactionActive(boolean active) { actualTransactionActive.set(active ? Boolean.TRUE : null); }
private void bindToThread() { // Expose current TransactionStatus, preserving any existing TransactionStatus // for restoration after this transaction is complete. this.oldTransactionInfo = transactionInfoHolder.get(); transactionInfoHolder.set(this); }
/** * Expose the name of the current transaction, if any. * Called by the transaction manager on transaction begin and on cleanup. * @param name the name of the transaction, or {@code null} to reset it * @see org.springframework.transaction.TransactionDefinition#getName() */ public static void setCurrentTransactionName(@Nullable String name) { currentTransactionName.set(name); }
/** * Set the name of the currently proxied bean instance. * @param beanName the name of the bean, or {@code null} to reset it */ static void setCurrentProxiedBeanName(@Nullable String beanName) { if (beanName != null) { currentProxiedBeanName.set(beanName); } else { currentProxiedBeanName.remove(); } }
/** * Bind the given SimpAttributes to the current thread. * @param attributes the RequestAttributes to expose */ public static void setAttributes(@Nullable SimpAttributes attributes) { if (attributes != null) { attributesHolder.set(attributes); } else { resetAttributes(); } }
/** * Activate transaction synchronization for the current thread. * Called by a transaction manager on transaction begin. * @throws IllegalStateException if synchronization is already active */ public static void initSynchronization() throws IllegalStateException { if (isSynchronizationActive()) { throw new IllegalStateException("Cannot activate transaction synchronization - already active"); } logger.trace("Initializing transaction synchronization"); synchronizations.set(new LinkedHashSet<>()); }
private static InternalThreadLocalMap slowGet() { ThreadLocal<InternalThreadLocalMap> slowThreadLocalMap = InternalThreadLocalMap.slowThreadLocalMap; InternalThreadLocalMap ret = slowThreadLocalMap.get(); if (ret == null) { ret = new InternalThreadLocalMap(); slowThreadLocalMap.set(ret); } return ret; }
private static InternalThreadLocalMap slowGet() { ThreadLocal<InternalThreadLocalMap> slowThreadLocalMap = InternalThreadLocalMap.slowThreadLocalMap; InternalThreadLocalMap ret = slowThreadLocalMap.get(); if (ret == null) { ret = new InternalThreadLocalMap(); slowThreadLocalMap.set(ret); } return ret; }
@Override public Integer call() { int i = threadLocalCount.get(); threadLocalCount.set(i + 1); return i; } };
protected Path createFile() throws IOException { Path file = java.nio.file.Files.createTempFile("SinkSourceFile", "txt"); fileThreadLocal.set(file); return file; }
protected File createFile() throws IOException { File file = File.createTempFile("SinkSourceFile", "txt"); fileThreadLocal.set(file); return file; }
@Override public void run() { threadLocalCount.set(threadLocalCount.get() + 1); } };
@Before("serviceExecution()") public void countUse() { this.useCount++; threadLocalCount.set(this.useCount); }
private static Yylex getLexer(Reader reader) { Yylex ret = LOCAL_LEXER.get(); if (ret == null) { ret = new Yylex(reader); LOCAL_LEXER.set(ret); } else { ret.yyreset(reader); } return ret; }
private static Yylex getLexer(Reader reader) { Yylex ret = LOCAL_LEXER.get(); if (ret == null) { ret = new Yylex(reader); LOCAL_LEXER.set(ret); } else { ret.yyreset(reader); } return ret; }
@Override public void beforeTestMethod(TestContext testContext) throws Exception { String name = testContext.getTestMethod().getName(); actualMethods.add(name); testContext.setAttribute("method", name); this.methodName.set(name); }