List of usage examples for org.springframework.transaction.reactive TransactionSynchronizationUtils unwrapResourceIfNecessary
static Object unwrapResourceIfNecessary(Object resource)
From source file:org.springframework.transaction.reactive.TransactionSynchronizationManager.java
/** * Check if there is a resource for the given key bound to the current thread. * @param key the key to check (usually the resource factory) * @return if there is a value bound to the current thread */// ww w . jav a 2 s.com public boolean hasResource(Object key) { Object actualKey = TransactionSynchronizationUtils.unwrapResourceIfNecessary(key); Object value = doGetResource(actualKey); return (value != null); }
From source file:org.springframework.transaction.reactive.TransactionSynchronizationManager.java
/** * Retrieve a resource for the given key that is bound to the current thread. * @param key the key to check (usually the resource factory) * @return a value bound to the current thread (usually the active * resource object), or {@code null} if none */// w w w .j a va 2s . com @Nullable public Object getResource(Object key) { Object actualKey = TransactionSynchronizationUtils.unwrapResourceIfNecessary(key); Object value = doGetResource(actualKey); if (value != null && logger.isTraceEnabled()) { logger.trace("Retrieved value [" + value + "] for key [" + actualKey + "] bound to context [" + this.transactionContext.getName() + "]"); } return value; }
From source file:org.springframework.transaction.reactive.TransactionSynchronizationManager.java
/** * Bind the given resource for the given key to the current context. * @param key the key to bind the value to (usually the resource factory) * @param value the value to bind (usually the active resource object) * @throws IllegalStateException if there is already a value bound to the context *///from w ww. j ava 2 s.c om public void bindResource(Object key, Object value) throws IllegalStateException { Object actualKey = TransactionSynchronizationUtils.unwrapResourceIfNecessary(key); Assert.notNull(value, "Value must not be null"); Map<Object, Object> map = this.transactionContext.getResources(); Object oldValue = map.put(actualKey, value); if (oldValue != null) { throw new IllegalStateException("Already value [" + oldValue + "] for key [" + actualKey + "] bound to context [" + this.transactionContext.getName() + "]"); } if (logger.isTraceEnabled()) { logger.trace("Bound value [" + value + "] for key [" + actualKey + "] to context [" + this.transactionContext.getName() + "]"); } }
From source file:org.springframework.transaction.reactive.TransactionSynchronizationManager.java
/** * Unbind a resource for the given key from the current context. * @param key the key to unbind (usually the resource factory) * @return the previously bound value (usually the active resource object) * @throws IllegalStateException if there is no value bound to the context *//*from w w w . j av a2 s . c o m*/ public Object unbindResource(Object key) throws IllegalStateException { Object actualKey = TransactionSynchronizationUtils.unwrapResourceIfNecessary(key); Object value = doUnbindResource(actualKey); if (value == null) { throw new IllegalStateException("No value for key [" + actualKey + "] bound to context [" + this.transactionContext.getName() + "]"); } return value; }
From source file:org.springframework.transaction.reactive.TransactionSynchronizationManager.java
/** * Unbind a resource for the given key from the current context. * @param key the key to unbind (usually the resource factory) * @return the previously bound value, or {@code null} if none bound *///from w ww . j a v a 2s. c o m @Nullable public Object unbindResourceIfPossible(Object key) { Object actualKey = TransactionSynchronizationUtils.unwrapResourceIfNecessary(key); return doUnbindResource(actualKey); }