removed outdated reflection code
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1909 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
parent
56d0246713
commit
3e5ef8ba7c
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2009 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.
|
||||
|
|
@ -26,6 +26,7 @@ import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
|
|||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.transaction.annotation.AnnotationTransactionAttributeSource;
|
||||
import org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor;
|
||||
import org.springframework.transaction.interceptor.TransactionInterceptor;
|
||||
|
||||
|
|
@ -46,8 +47,6 @@ import org.springframework.transaction.interceptor.TransactionInterceptor;
|
|||
*/
|
||||
class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
||||
|
||||
public static final String DEFAULT_TRANSACTION_MANAGER_BEAN_NAME = "transactionManager";
|
||||
|
||||
/**
|
||||
* The bean name of the internally managed transaction advisor (mode="proxy").
|
||||
*/
|
||||
|
|
@ -93,9 +92,8 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
|||
}
|
||||
|
||||
private static void registerTransactionManager(Element element, BeanDefinition def) {
|
||||
String transactionManagerName = (element.hasAttribute(TxNamespaceUtils.TRANSACTION_MANAGER_ATTRIBUTE) ?
|
||||
element.getAttribute(TxNamespaceUtils.TRANSACTION_MANAGER_ATTRIBUTE) : DEFAULT_TRANSACTION_MANAGER_BEAN_NAME);
|
||||
def.getPropertyValues().addPropertyValue("transactionManagerBeanName", transactionManagerName);
|
||||
def.getPropertyValues().addPropertyValue("transactionManagerBeanName",
|
||||
TxNamespaceHandler.getTransactionManagerName(element));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -111,8 +109,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
|||
Object eleSource = parserContext.extractSource(element);
|
||||
|
||||
// Create the TransactionAttributeSource definition.
|
||||
Class sourceClass = TxNamespaceUtils.getAnnotationTransactionAttributeSourceClass();
|
||||
RootBeanDefinition sourceDef = new RootBeanDefinition(sourceClass);
|
||||
RootBeanDefinition sourceDef = new RootBeanDefinition(AnnotationTransactionAttributeSource.class);
|
||||
sourceDef.setSource(eleSource);
|
||||
sourceDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
String sourceName = parserContext.getReaderContext().registerWithGeneratedName(sourceDef);
|
||||
|
|
@ -122,16 +119,14 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
|||
interceptorDef.setSource(eleSource);
|
||||
interceptorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
registerTransactionManager(element, interceptorDef);
|
||||
interceptorDef.getPropertyValues().addPropertyValue(TxNamespaceUtils.TRANSACTION_ATTRIBUTE_SOURCE,
|
||||
new RuntimeBeanReference(sourceName));
|
||||
interceptorDef.getPropertyValues().addPropertyValue("transactionAttributeSource", new RuntimeBeanReference(sourceName));
|
||||
String interceptorName = parserContext.getReaderContext().registerWithGeneratedName(interceptorDef);
|
||||
|
||||
// Create the TransactionAttributeSourceAdvisor definition.
|
||||
RootBeanDefinition advisorDef = new RootBeanDefinition(BeanFactoryTransactionAttributeSourceAdvisor.class);
|
||||
advisorDef.setSource(eleSource);
|
||||
advisorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
advisorDef.getPropertyValues().addPropertyValue(TxNamespaceUtils.TRANSACTION_ATTRIBUTE_SOURCE,
|
||||
new RuntimeBeanReference(sourceName));
|
||||
advisorDef.getPropertyValues().addPropertyValue("transactionAttributeSource", new RuntimeBeanReference(sourceName));
|
||||
advisorDef.getPropertyValues().addPropertyValue("adviceBeanName", interceptorName);
|
||||
if (element.hasAttribute("order")) {
|
||||
advisorDef.getPropertyValues().addPropertyValue("order", element.getAttribute("order"));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2009 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.
|
||||
|
|
@ -45,9 +45,6 @@ public class JtaTransactionManagerBeanDefinitionParser extends AbstractSingleBea
|
|||
private static final String JTA_TRANSACTION_MANAGER_CLASS_NAME =
|
||||
"org.springframework.transaction.jta.JtaTransactionManager";
|
||||
|
||||
public static final String DEFAULT_TRANSACTION_MANAGER_BEAN_NAME =
|
||||
AnnotationDrivenBeanDefinitionParser.DEFAULT_TRANSACTION_MANAGER_BEAN_NAME;
|
||||
|
||||
|
||||
private static final boolean weblogicPresent = ClassUtils.isPresent(
|
||||
"weblogic.transaction.UserTransaction", JtaTransactionManagerBeanDefinitionParser.class.getClassLoader());
|
||||
|
|
@ -77,7 +74,7 @@ public class JtaTransactionManagerBeanDefinitionParser extends AbstractSingleBea
|
|||
|
||||
@Override
|
||||
protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext) {
|
||||
return DEFAULT_TRANSACTION_MANAGER_BEAN_NAME;
|
||||
return TxNamespaceHandler.DEFAULT_TRANSACTION_MANAGER_BEAN_NAME;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2009 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.
|
||||
|
|
@ -27,6 +27,7 @@ import org.springframework.beans.factory.support.ManagedMap;
|
|||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.transaction.annotation.AnnotationTransactionAttributeSource;
|
||||
import org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource;
|
||||
import org.springframework.transaction.interceptor.NoRollbackRuleAttribute;
|
||||
import org.springframework.transaction.interceptor.RollbackRuleAttribute;
|
||||
|
|
@ -70,10 +71,7 @@ class TxAdviceBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
|
|||
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
// Set the transaction manager property.
|
||||
String transactionManagerName = (element.hasAttribute(TxNamespaceUtils.TRANSACTION_MANAGER_ATTRIBUTE) ?
|
||||
element.getAttribute(TxNamespaceUtils.TRANSACTION_MANAGER_ATTRIBUTE) : "transactionManager");
|
||||
builder.addPropertyReference(TxNamespaceUtils.TRANSACTION_MANAGER_PROPERTY, transactionManagerName);
|
||||
builder.addPropertyReference("transactionManager", TxNamespaceHandler.getTransactionManagerName(element));
|
||||
|
||||
List txAttributes = DomUtils.getChildElementsByTagName(element, ATTRIBUTES);
|
||||
if (txAttributes.size() > 1) {
|
||||
|
|
@ -84,12 +82,12 @@ class TxAdviceBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
|
|||
// Using attributes source.
|
||||
Element attributeSourceElement = (Element) txAttributes.get(0);
|
||||
RootBeanDefinition attributeSourceDefinition = parseAttributeSource(attributeSourceElement, parserContext);
|
||||
builder.addPropertyValue(TxNamespaceUtils.TRANSACTION_ATTRIBUTE_SOURCE, attributeSourceDefinition);
|
||||
builder.addPropertyValue("transactionAttributeSource", attributeSourceDefinition);
|
||||
}
|
||||
else {
|
||||
// Assume annotations source.
|
||||
Class sourceClass = TxNamespaceUtils.getAnnotationTransactionAttributeSourceClass();
|
||||
builder.addPropertyValue(TxNamespaceUtils.TRANSACTION_ATTRIBUTE_SOURCE, new RootBeanDefinition(sourceClass));
|
||||
builder.addPropertyValue("transactionAttributeSource",
|
||||
new RootBeanDefinition(AnnotationTransactionAttributeSource.class));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
* Copyright 2002-2009 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.
|
||||
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package org.springframework.transaction.config;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
|
||||
|
||||
/**
|
||||
|
|
@ -23,7 +25,7 @@ import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
|
|||
* declarative transaction management using either XML or using annotations.
|
||||
*
|
||||
* <p>This namespace handler is the central piece of functionality in the
|
||||
* Spring 2 transaction management facilities and offers two appraoched
|
||||
* Spring transaction management facilities and offers two approaches
|
||||
* to declaratively manage transactions.
|
||||
*
|
||||
* <p>One approach uses transaction semantics defined in XML using the
|
||||
|
|
@ -37,6 +39,17 @@ import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
|
|||
*/
|
||||
public class TxNamespaceHandler extends NamespaceHandlerSupport {
|
||||
|
||||
static final String TRANSACTION_MANAGER_ATTRIBUTE = "transaction-manager";
|
||||
|
||||
static final String DEFAULT_TRANSACTION_MANAGER_BEAN_NAME = "transactionManager";
|
||||
|
||||
|
||||
static String getTransactionManagerName(Element element) {
|
||||
return (element.hasAttribute(TRANSACTION_MANAGER_ATTRIBUTE) ?
|
||||
element.getAttribute(TRANSACTION_MANAGER_ATTRIBUTE) : DEFAULT_TRANSACTION_MANAGER_BEAN_NAME);
|
||||
}
|
||||
|
||||
|
||||
public void init() {
|
||||
registerBeanDefinitionParser("advice", new TxAdviceBeanDefinitionParser());
|
||||
registerBeanDefinitionParser("annotation-driven", new AnnotationDrivenBeanDefinitionParser());
|
||||
|
|
|
|||
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2007 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 org.springframework.transaction.config;
|
||||
|
||||
import org.springframework.core.Conventions;
|
||||
import org.springframework.core.JdkVersion;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.0
|
||||
*/
|
||||
class TxNamespaceUtils {
|
||||
|
||||
public static final String TRANSACTION_MANAGER_ATTRIBUTE = "transaction-manager";
|
||||
|
||||
public static final String TRANSACTION_MANAGER_PROPERTY =
|
||||
Conventions.attributeNameToPropertyName(TRANSACTION_MANAGER_ATTRIBUTE);
|
||||
|
||||
public static final String TRANSACTION_ATTRIBUTE_SOURCE = "transactionAttributeSource";
|
||||
|
||||
private static final String ANNOTATION_TRANSACTION_ATTRIBUTE_SOURCE_CLASS_NAME =
|
||||
"org.springframework.transaction.annotation.AnnotationTransactionAttributeSource";
|
||||
|
||||
|
||||
public static Class getAnnotationTransactionAttributeSourceClass() {
|
||||
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_15) {
|
||||
throw new IllegalStateException(
|
||||
"AnnotationTransactionAttributeSource is only available on Java 1.5 and higher");
|
||||
}
|
||||
try {
|
||||
return ClassUtils.forName(
|
||||
ANNOTATION_TRANSACTION_ATTRIBUTE_SOURCE_CLASS_NAME, TxNamespaceUtils.class.getClassLoader());
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
throw new IllegalStateException("Unable to load Java 1.5 dependent class [" +
|
||||
ANNOTATION_TRANSACTION_ATTRIBUTE_SOURCE_CLASS_NAME + "]", ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue