Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.bitsensor.plugins.shaded.org.springframework.transaction.interceptor;
import java.lang.reflect.Method;
import java.util.Properties;
import java.util.concurrent.ConcurrentMap;
import io.bitsensor.plugins.shaded.org.apache.commons.logging.Log;
import io.bitsensor.plugins.shaded.org.apache.commons.logging.LogFactory;
import io.bitsensor.plugins.shaded.org.springframework.beans.factory.BeanFactory;
import io.bitsensor.plugins.shaded.org.springframework.beans.factory.BeanFactoryAware;
import io.bitsensor.plugins.shaded.org.springframework.beans.factory.InitializingBean;
import io.bitsensor.plugins.shaded.org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils;
import io.bitsensor.plugins.shaded.org.springframework.core.NamedThreadLocal;
import io.bitsensor.plugins.shaded.org.springframework.transaction.NoTransactionException;
import io.bitsensor.plugins.shaded.org.springframework.transaction.PlatformTransactionManager;
import io.bitsensor.plugins.shaded.org.springframework.transaction.TransactionStatus;
import io.bitsensor.plugins.shaded.org.springframework.transaction.TransactionSystemException;
import io.bitsensor.plugins.shaded.org.springframework.transaction.support.CallbackPreferringPlatformTransactionManager;
import io.bitsensor.plugins.shaded.org.springframework.transaction.support.TransactionCallback;
import io.bitsensor.plugins.shaded.org.springframework.util.ClassUtils;
import io.bitsensor.plugins.shaded.org.springframework.util.ConcurrentReferenceHashMap;
import io.bitsensor.plugins.shaded.org.springframework.util.StringUtils;
/**
* Base class for transactional aspects, such as the {@link TransactionInterceptor}
* or an AspectJ aspect.
*
*
This enables the underlying Spring transaction infrastructure to be used easily
* to implement an aspect for any aspect system.
*
*
Subclasses are responsible for calling methods in this class in the correct order.
*
*
If no transaction name has been specified in the {@code TransactionAttribute},
* the exposed name will be the {@code fully-qualified class name + "." + method name}
* (by default).
*
*
Uses the Strategy design pattern. A {@code PlatformTransactionManager}
* implementation will perform the actual transaction management, and a
* {@code TransactionAttributeSource} is used for determining transaction definitions.
*
*
A transaction aspect is serializable if its {@code PlatformTransactionManager}
* and {@code TransactionAttributeSource} are serializable.
*
* @author Rod Johnson
* @author Juergen Hoeller
* @author Stéphane Nicoll
* @author Sam Brannen
* @since 1.1
* @see #setTransactionManager
* @see #setTransactionAttributes
* @see #setTransactionAttributeSource
*/
public abstract class TransactionAspectSupport implements BeanFactoryAware, InitializingBean {
// NOTE: This class must not implement Serializable because it serves as base
// class for AspectJ aspects (which are not allowed to implement Serializable)!
/**
* Key to use to store the default transaction manager.
*/
private static final Object DEFAULT_TRANSACTION_MANAGER_KEY = new Object();
/**
* Holder to support the {@code currentTransactionStatus()} method,
* and to support communication between different cooperating advices
* (e.g. before and after advice) if the aspect involves more than a
* single method (as will be the case for around advice).
*/
private static final ThreadLocal transactionInfoHolder =
new NamedThreadLocal("Current aspect-driven transaction");
/**
* Subclasses can use this to return the current TransactionInfo.
* Only subclasses that cannot handle all operations in one method,
* such as an AspectJ aspect involving distinct before and after advice,
* need to use this mechanism to get at the current TransactionInfo.
* An around advice such as an AOP Alliance MethodInterceptor can hold a
* reference to the TransactionInfo throughout the aspect method.
*
A TransactionInfo will be returned even if no transaction was created.
* The {@code TransactionInfo.hasTransaction()} method can be used to query this.
*
To find out about specific transaction characteristics, consider using
* TransactionSynchronizationManager's {@code isSynchronizationActive()}
* and/or {@code isActualTransactionActive()} methods.
* @return TransactionInfo bound to this thread, or {@code null} if none
* @see TransactionInfo#hasTransaction()
* @see io.bitsensor.plugins.shaded.org.springframework.transaction.support.TransactionSynchronizationManager#isSynchronizationActive()
* @see io.bitsensor.plugins.shaded.org.springframework.transaction.support.TransactionSynchronizationManager#isActualTransactionActive()
*/
protected static TransactionInfo currentTransactionInfo() throws NoTransactionException {
return transactionInfoHolder.get();
}
/**
* Return the transaction status of the current method invocation.
* Mainly intended for code that wants to set the current transaction
* rollback-only but not throw an application exception.
* @throws NoTransactionException if the transaction info cannot be found,
* because the method was invoked outside an AOP invocation context
*/
public static TransactionStatus currentTransactionStatus() throws NoTransactionException {
TransactionInfo info = currentTransactionInfo();
if (info == null || info.transactionStatus == null) {
throw new NoTransactionException("No transaction aspect-managed TransactionStatus in scope");
}
return info.transactionStatus;
}
protected final Log logger = LogFactory.getLog(getClass());
private String transactionManagerBeanName;
private PlatformTransactionManager transactionManager;
private TransactionAttributeSource transactionAttributeSource;
private BeanFactory beanFactory;
private final ConcurrentMap