/** * Used internally by CGLIB. Returns the <code>AbstractClassGenerator</code> * that is being used to generate a class in the current thread. */ public static AbstractClassGenerator getCurrent() { return (AbstractClassGenerator) CURRENT.get(); }
private void restoreThreadLocalStatus() { // Use stack to restore old transaction TransactionInfo. // Will be null if none was set. transactionInfoHolder.set(this.oldTransactionInfo); }
/** * Make the given proxy available via the {@code currentProxy()} method. * <p>Note that the caller should be careful to keep the old value as appropriate. * @param proxy the proxy to expose (or {@code null} to reset it) * @return the old proxy, which may be {@code null} if none was bound * @see #currentProxy() */ @Nullable static Object setCurrentProxy(@Nullable Object proxy) { Object old = currentProxy.get(); if (proxy != null) { currentProxy.set(proxy); } else { currentProxy.remove(); } return old; }
@Override public Kryo getKryo() { return holder.get(); } }
/** * 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); }
@Override void dispatch(Object event, Iterator<Subscriber> subscribers) { checkNotNull(event); checkNotNull(subscribers); Queue<Event> queueForThread = queue.get(); queueForThread.offer(new Event(event, subscribers)); if (!dispatching.get()) { dispatching.set(true); try { Event nextEvent; while ((nextEvent = queueForThread.poll()) != null) { while (nextEvent.subscribers.hasNext()) { nextEvent.subscribers.next().dispatchEvent(nextEvent.event); } } } finally { dispatching.remove(); queue.remove(); } } }
/** * Reset the JodaTimeContext for the current thread. */ public static void resetJodaTimeContext() { jodaTimeContextHolder.remove(); }
/** * 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(); } }
/** * Return if transaction synchronization is active for the current thread. * Can be called before register to avoid unnecessary instance creation. * @see #registerSynchronization */ public static boolean isSynchronizationActive() { return (synchronizations.get() != null); }
/** * 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); }
/** * Remove any user credentials for this proxy from the current thread. * Statically specified user credentials apply again afterwards. * @see #setCredentialsForCurrentThread */ public void removeCredentialsFromCurrentThread() { this.threadBoundCredentials.remove(); }
/** Returns a thread-local 1024-char array. */ static char[] charBufferFromThreadLocal() { return DEST_TL.get(); }
/** * 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); }