01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.transaction.config;
18:
19: import org.w3c.dom.Element;
20:
21: import org.springframework.beans.factory.support.AbstractBeanDefinition;
22: import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
23: import org.springframework.beans.factory.xml.ParserContext;
24: import org.springframework.transaction.jta.JtaTransactionManager;
25: import org.springframework.transaction.jta.OC4JJtaTransactionManager;
26: import org.springframework.transaction.jta.WebLogicJtaTransactionManager;
27: import org.springframework.transaction.jta.WebSphereUowTransactionManager;
28: import org.springframework.util.ClassUtils;
29:
30: /**
31: * Parser for the <tx:jta-transaction-manager/> element,
32: * autodetecting BEA WebLogic, IBM WebSphere and Oracle OC4J.
33: *
34: * @author Juergen Hoeller
35: * @since 2.5
36: */
37: public class JtaTransactionManagerBeanDefinitionParser extends
38: AbstractSingleBeanDefinitionParser {
39:
40: public static final String DEFAULT_TRANSACTION_MANAGER_BEAN_NAME = AnnotationDrivenBeanDefinitionParser.DEFAULT_TRANSACTION_MANAGER_BEAN_NAME;
41:
42: private static final boolean weblogicPresent = ClassUtils
43: .isPresent("weblogic.transaction.UserTransaction");
44:
45: private static final boolean webspherePresent = ClassUtils
46: .isPresent("com.ibm.wsspi.uow.UOWManager");
47:
48: private static final boolean oc4jPresent = ClassUtils
49: .isPresent("oracle.j2ee.transaction.OC4JTransactionManager");
50:
51: protected Class getBeanClass(Element element) {
52: if (weblogicPresent) {
53: return WebLogicJtaTransactionManager.class;
54: } else if (webspherePresent) {
55: return WebSphereUowTransactionManager.class;
56: } else if (oc4jPresent) {
57: return OC4JJtaTransactionManager.class;
58: } else {
59: return JtaTransactionManager.class;
60: }
61: }
62:
63: protected String resolveId(Element element,
64: AbstractBeanDefinition definition,
65: ParserContext parserContext) {
66: return DEFAULT_TRANSACTION_MANAGER_BEAN_NAME;
67: }
68:
69: }
|