private DefaultTokenServices txProxiedTokenServices(DefaultTokenServices tokenServices, DataSource dataSource) {
AnnotationTransactionAttributeSource attrSource = new AnnotationTransactionAttributeSource();
DataSourceTransactionManager txManager = new DataSourceTransactionManager(dataSource);
TransactionInterceptor txInterceptor = transactionInterceptor(attrSource, txManager);
BeanFactoryTransactionAttributeSourceAdvisor txAdvisor = transactionAdvisor(attrSource, txInterceptor);
ClassLoader classLoader = ClassUtils.getDefaultClassLoader();
ProxyFactory proxyFactory = new ProxyFactory(tokenServices);
proxyFactory.addAdvice(txInterceptor);
proxyFactory.addAdvisor(txAdvisor);
proxyFactory.setInterfaces(
ClassUtils.getAllInterfacesForClass(
new SingletonTargetSource(tokenServices).getTargetClass(), classLoader));
return (DefaultTokenServices) proxyFactory.getProxy(classLoader);
}
java类org.springframework.transaction.annotation.AnnotationTransactionAttributeSource的实例源码
OAuth2Initializer.java 文件源码
项目:joyrest
阅读 22
收藏 0
点赞 0
评论 0
TLETransactionInterceptor.java 文件源码
项目:Equella
阅读 20
收藏 0
点赞 0
评论 0
public TLETransactionInterceptor(AnnotationTransactionAttributeSource attributes,
Provider<TLETransactionManager> managerProvider, String factoryName, boolean system)
{
this.attributes = attributes;
this.factoryName = factoryName;
this.system = system;
this.managerProvider = managerProvider;
}
TransactionAspectTests.java 文件源码
项目:spring4-understanding
阅读 20
收藏 0
点赞 0
评论 0
/**
* Note: resolution does not occur. Thus we can't make a class transactional if
* it implements a transactionally annotated interface. This behaviour could only
* be changed in AbstractFallbackTransactionAttributeSource in Spring proper.
*/
public void testDoesNotResolveTxAnnotationOnMethodFromClassImplementingAnnotatedInterface() throws Exception {
AnnotationTransactionAttributeSource atas = new AnnotationTransactionAttributeSource();
Method m = ImplementsAnnotatedInterface.class.getMethod("echo", Throwable.class);
TransactionAttribute ta = atas.getTransactionAttribute(m, ImplementsAnnotatedInterface.class);
assertNull(ta);
}
TransactionConfigPostProcessor.java 文件源码
项目:ByteTCC
阅读 18
收藏 0
点赞 0
评论 0
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
String[] beanNameArray = beanFactory.getBeanDefinitionNames();
for (int i = 0; i < beanNameArray.length; i++) {
String beanName = beanNameArray[i];
BeanDefinition beanDef = beanFactory.getBeanDefinition(beanName);
String beanClassName = beanDef.getBeanClassName();
if (org.springframework.transaction.interceptor.TransactionProxyFactoryBean.class.getName().equals(beanClassName)) {
throw new FatalBeanException(String.format(
"Declaring transactions by configuration is not supported yet, please use annotations to declare transactions(beanId= %s).",
beanName));
}
if (org.springframework.transaction.interceptor.TransactionInterceptor.class.getName().equals(beanClassName)) {
boolean errorExists = true;
MutablePropertyValues mpv = beanDef.getPropertyValues();
PropertyValue pv = mpv.getPropertyValue("transactionAttributeSource");
Object value = pv == null ? null : pv.getValue();
if (value != null && RuntimeBeanReference.class.isInstance(value)) {
RuntimeBeanReference reference = (RuntimeBeanReference) value;
BeanDefinition refBeanDef = beanFactory.getBeanDefinition(reference.getBeanName());
String refBeanClassName = refBeanDef.getBeanClassName();
errorExists = AnnotationTransactionAttributeSource.class.getName().equals(refBeanClassName) == false;
}
if (errorExists) {
throw new FatalBeanException(String.format(
"Declaring transactions by configuration is not supported yet, please use annotations to declare transactions(beanId= %s).",
beanName));
}
}
}
}
Global.java 文件源码
项目:play-guice-mirage-java-example
阅读 23
收藏 0
点赞 0
评论 0
@Override
protected void configure() {
// TransactionManager
PlatformTransactionManager transactionManager = new DataSourceTransactionManager(dataSource);
// TransactionInterceptor
TransactionInterceptor transactionInterceptor = new TransactionInterceptor(transactionManager, new AnnotationTransactionAttributeSource(false));
bindInterceptor(Matchers.any(), Matchers.annotatedWith(Transactional.class), transactionInterceptor);
bind(PlatformTransactionManager.class).toInstance(transactionManager);
}
OAuth2Initializer.java 文件源码
项目:joyrest
阅读 22
收藏 0
点赞 0
评论 0
private BeanFactoryTransactionAttributeSourceAdvisor transactionAdvisor(
AnnotationTransactionAttributeSource source, TransactionInterceptor interceptor) {
BeanFactoryTransactionAttributeSourceAdvisor advisor = new BeanFactoryTransactionAttributeSourceAdvisor();
advisor.setTransactionAttributeSource(source);
advisor.setAdvice(interceptor);
return advisor;
}
OAuth2Initializer.java 文件源码
项目:joyrest
阅读 24
收藏 0
点赞 0
评论 0
private TransactionInterceptor transactionInterceptor(
AnnotationTransactionAttributeSource source, PlatformTransactionManager txManager) {
TransactionInterceptor interceptor = new TransactionInterceptor();
interceptor.setTransactionAttributeSource(source);
interceptor.setTransactionManager(txManager);
return interceptor;
}
TransactionModule.java 文件源码
项目:dbflute-play-guice-java-example
阅读 22
收藏 0
点赞 0
评论 0
@Override
protected void configure() {
// TransactionManager
bind(PlatformTransactionManager.class).toProvider(getPlatformTransactionManagerType()).in(Singleton.class);
// TransactionInterceptor
final TransactionInterceptor transactionInterceptor = new TransactionInterceptorEx(getProvider(PlatformTransactionManager.class), new AnnotationTransactionAttributeSource(false));
bindInterceptor(Matchers.any(), Matchers.annotatedWith(Transactional.class), transactionInterceptor);
}
RealmModule.java 文件源码
项目:JMaNGOS
阅读 19
收藏 0
点赞 0
评论 0
@Bean
public TransactionInterceptor transactionInterceptorRealm() {
return new TransactionInterceptor(transactionManagerRealm(),
new AnnotationTransactionAttributeSource());
}
WorldModule.java 文件源码
项目:JMaNGOS
阅读 19
收藏 0
点赞 0
评论 0
@Bean
public TransactionInterceptor transactionInterceptorWorld() {
return new TransactionInterceptor(transactionManagerWorld(),
new AnnotationTransactionAttributeSource());
}
AuthModule.java 文件源码
项目:JMaNGOS
阅读 19
收藏 0
点赞 0
评论 0
@Bean
public TransactionInterceptor transactionInterceptorAuth() {
return new TransactionInterceptor(transactionManagerAuth(),
new AnnotationTransactionAttributeSource());
}
TransactionAspectTests.java 文件源码
项目:class-guard
阅读 22
收藏 0
点赞 0
评论 0
/**
* Note: resolution does not occur. Thus we can't make a class transactional if
* it implements a transactionally annotated interface. This behaviour could only
* be changed in AbstractFallbackTransactionAttributeSource in Spring proper.
* @throws SecurityException
* @throws NoSuchMethodException
*/
public void testDoesNotResolveTxAnnotationOnMethodFromClassImplementingAnnotatedInterface() throws SecurityException, NoSuchMethodException {
AnnotationTransactionAttributeSource atas = new AnnotationTransactionAttributeSource();
Method m = ImplementsAnnotatedInterface.class.getMethod("echo", Throwable.class);
TransactionAttribute ta = atas.getTransactionAttribute(m, ImplementsAnnotatedInterface.class);
assertNull(ta);
}
AnnotationAndNameMatchingTransactionAttributeSource.java 文件源码
项目:kc-rice
阅读 22
收藏 0
点赞 0
评论 0
/**
* Sets the annotationTransactionAttributeSource attribute value.
*
* @param annotationTransactionAttributeSource The annotationTransactionAttributeSource to set.
*/
public void setAnnotationTransactionAttributeSource(AnnotationTransactionAttributeSource annotationTransactionAttributeSource) {
this.annotationTransactionAttributeSource = annotationTransactionAttributeSource;
}
AnnotationAndNameMatchingTransactionAttributeSource.java 文件源码
项目:rice
阅读 21
收藏 0
点赞 0
评论 0
/**
* Sets the annotationTransactionAttributeSource attribute value.
*
* @param annotationTransactionAttributeSource The annotationTransactionAttributeSource to set.
*/
public void setAnnotationTransactionAttributeSource(AnnotationTransactionAttributeSource annotationTransactionAttributeSource) {
this.annotationTransactionAttributeSource = annotationTransactionAttributeSource;
}
AnnotationAndNameMatchingTransactionAttributeSource.java 文件源码
项目:kuali_rice
阅读 17
收藏 0
点赞 0
评论 0
/**
* Sets the annotationTransactionAttributeSource attribute value.
*
* @param annotationTransactionAttributeSource The annotationTransactionAttributeSource to set.
*/
public void setAnnotationTransactionAttributeSource(AnnotationTransactionAttributeSource annotationTransactionAttributeSource) {
this.annotationTransactionAttributeSource = annotationTransactionAttributeSource;
}