Removed OC4J support (including documentation references)

This commit is contained in:
Juergen Hoeller
2013-03-19 14:53:26 +01:00
parent a03d125b4e
commit 9c52ae9558
18 changed files with 822 additions and 632 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2013 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.
@@ -25,7 +25,7 @@ import org.springframework.util.ClassUtils;
/**
* Parser for the <tx:jta-transaction-manager/> element,
* autodetecting BEA WebLogic, IBM WebSphere and Oracle OC4J.
* autodetecting BEA WebLogic and IBM WebSphere.
*
* @author Juergen Hoeller
* @author Christian Dupuis
@@ -39,9 +39,6 @@ public class JtaTransactionManagerBeanDefinitionParser extends AbstractSingleBea
private static final String WEBSPHERE_TRANSACTION_MANAGER_CLASS_NAME =
"org.springframework.transaction.jta.WebSphereUowTransactionManager";
private static final String OC4J_TRANSACTION_MANAGER_CLASS_NAME =
"org.springframework.transaction.jta.OC4JJtaTransactionManager";
private static final String JTA_TRANSACTION_MANAGER_CLASS_NAME =
"org.springframework.transaction.jta.JtaTransactionManager";
@@ -52,9 +49,6 @@ public class JtaTransactionManagerBeanDefinitionParser extends AbstractSingleBea
private static final boolean webspherePresent = ClassUtils.isPresent(
"com.ibm.wsspi.uow.UOWManager", JtaTransactionManagerBeanDefinitionParser.class.getClassLoader());
private static final boolean oc4jPresent = ClassUtils.isPresent(
"oracle.j2ee.transaction.OC4JTransactionManager", JtaTransactionManagerBeanDefinitionParser.class.getClassLoader());
@Override
protected String getBeanClassName(Element element) {
@@ -64,9 +58,6 @@ public class JtaTransactionManagerBeanDefinitionParser extends AbstractSingleBea
else if (webspherePresent) {
return WEBSPHERE_TRANSACTION_MANAGER_CLASS_NAME;
}
else if (oc4jPresent) {
return OC4J_TRANSACTION_MANAGER_CLASS_NAME;
}
else {
return JTA_TRANSACTION_MANAGER_CLASS_NAME;
}

View File

@@ -79,21 +79,20 @@ import org.springframework.util.StringUtils;
* Almost all Java EE servers expose it, but do so as extension to EE. There might be some
* issues with compatibility, despite the TransactionManager interface being part of JTA.
* As a consequence, Spring provides various vendor-specific PlatformTransactionManagers,
* which are recommended to be used if appropriate: {@link WebLogicJtaTransactionManager},
* {@link WebSphereUowTransactionManager} and {@link OC4JJtaTransactionManager}.
* For all other Java EE servers, the standard JtaTransactionManager is sufficient.
* which are recommended to be used if appropriate: {@link WebLogicJtaTransactionManager}
* and {@link WebSphereUowTransactionManager}. For all other Java EE servers, the
* standard JtaTransactionManager is sufficient.
*
* <p>This pure JtaTransactionManager class supports timeouts but not per-transaction
* isolation levels. Custom subclasses may override the {@link #doJtaBegin} method for
* specific JTA extensions in order to provide this functionality; Spring includes
* corresponding {@link WebLogicJtaTransactionManager} and {@link OC4JJtaTransactionManager}
* classes, for BEA's WebLogic Server and Oracle's OC4J, respectively. Such adapters
* for specific Java EE transaction coordinators may also expose transaction names for
* monitoring; with standard JTA, transaction names will simply be ignored.
* specific JTA extensions in order to provide this functionality; Spring includes a
* corresponding {@link WebLogicJtaTransactionManager} class for WebLogic Server. Such
* adapters for specific Java EE transaction coordinators may also expose transaction
* names for monitoring; with standard JTA, transaction names will simply be ignored.
*
* <p><b>Consider using Spring's {@code tx:jta-transaction-manager} configuration
* element for automatically picking the appropriate JTA platform transaction manager
* (automatically detecting WebLogic, WebSphere and OC4J).</b>
* (automatically detecting WebLogic and WebSphere).</b>
*
* <p>JTA 1.1 adds the TransactionSynchronizationRegistry facility, as public Java EE 5
* API in addition to the standard JTA UserTransaction handle. As of Spring 2.5, this

View File

@@ -1,253 +0,0 @@
/*
* Copyright 2002-2012 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.jta;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.transaction.NotSupportedException;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
import javax.transaction.UserTransaction;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionSystemException;
import org.springframework.util.ClassUtils;
/**
* Special {@link JtaTransactionManager} variant for Oracle OC4J (10.1.3 and higher).
* Supports the full power of Spring's transaction definitions on OC4J's
* transaction coordinator, <i>beyond standard JTA</i>: transaction names
* and per-transaction isolation levels.
*
* <p>Uses OC4J's special {@code begin(name)} method to start a JTA transaction,
* in orderto make <b>Spring-driven transactions visible in OC4J's transaction
* monitor</b>. In case of Spring's declarative transactions, the exposed name will
* (by default) be the fully-qualified class name + "." + method name.
*
* <p>Supports a <b>per-transaction isolation level</b> through OC4J's corresponding
* {@code OC4JTransaction.setTransactionIsolation(int)} method. This will
* apply the specified isolation level (e.g. ISOLATION_SERIALIZABLE) to all
* JDBC Connections that participate in the given transaction.
*
* <p>Automatically detects the available OC4J server version and adapts accordingly.
* Supports the "com.evermind.server" package in OC4J 10.1.3.2 as well as the
* "oracle.j2ee.transaction" package in later OC4J versions.
*
* <p>By default, the JTA UserTransaction and TransactionManager handles are
* fetched directly from OC4J's {@code TransactionUtility} in 10.1.3.2+.
* This can be overridden by specifying "userTransaction"/"userTransactionName"
* and "transactionManager"/"transactionManagerName", passing in existing handles
* or specifying corresponding JNDI locations to look up.
*
* <p>Thanks to Oracle for donating the original version of this extended OC4J
* integration code to the Spring project!
*
* @author Paul Parkinson
* @author Juergen Hoeller
* @since 2.0.3
* @see org.springframework.transaction.TransactionDefinition#getName
* @see org.springframework.transaction.TransactionDefinition#getIsolationLevel
* @deprecated as of Spring 3.2, in favor of {@link WebLogicJtaTransactionManager}
* since Oracle end-of-lifed OC4J in favor of WebLogic
*/
@Deprecated
@SuppressWarnings("serial")
public class OC4JJtaTransactionManager extends JtaTransactionManager {
private static final String TRANSACTION_UTILITY_CLASS_NAME =
"oracle.j2ee.transaction.TransactionUtility";
private static final String TRANSACTION_MANAGER_CLASS_NAME =
"oracle.j2ee.transaction.OC4JTransactionManager";
private static final String TRANSACTION_CLASS_NAME =
"oracle.j2ee.transaction.OC4JTransaction";
private static final String FALLBACK_TRANSACTION_MANAGER_CLASS_NAME =
"com.evermind.server.ApplicationServerTransactionManager";
private static final String FALLBACK_TRANSACTION_CLASS_NAME =
"com.evermind.server.ApplicationServerTransaction";
private Method beginWithNameMethod;
private Method setTransactionIsolationMethod;
@Override
public void afterPropertiesSet() throws TransactionSystemException {
super.afterPropertiesSet();
loadOC4JTransactionClasses();
}
@Override
protected UserTransaction retrieveUserTransaction() throws TransactionSystemException {
try {
Class transactionUtilityClass = getClass().getClassLoader().loadClass(TRANSACTION_UTILITY_CLASS_NAME);
Method getInstanceMethod = transactionUtilityClass.getMethod("getInstance");
Object transactionUtility = getInstanceMethod.invoke(null);
logger.debug("Retrieving JTA UserTransaction from OC4J TransactionUtility");
Method getUserTransactionMethod =
transactionUtility.getClass().getMethod("getOC4JUserTransaction");
return (UserTransaction) getUserTransactionMethod.invoke(transactionUtility);
}
catch (ClassNotFoundException ex) {
logger.debug("Could not find OC4J 10.1.3.2 TransactionUtility: " + ex);
// Return null to make the superclass perform its standard J2EE lookup,
// which will work on earlier OC4J versions.
return null;
}
catch (InvocationTargetException ex) {
throw new TransactionSystemException(
"OC4J's TransactionUtility.getOC4JUserTransaction() method failed", ex.getTargetException());
}
catch (Exception ex) {
throw new TransactionSystemException(
"Could not invoke OC4J's TransactionUtility.getOC4JUserTransaction() method", ex);
}
}
private void loadOC4JTransactionClasses() throws TransactionSystemException {
// Find available OC4J API (in "oracle.j2ee.transaction" or "com.evermind.server")
Class transactionManagerClass = null;
Class transactionClass = null;
try {
transactionManagerClass = getClass().getClassLoader().loadClass(TRANSACTION_MANAGER_CLASS_NAME);
transactionClass = getClass().getClassLoader().loadClass(TRANSACTION_CLASS_NAME);
}
catch (ClassNotFoundException ex) {
try {
transactionManagerClass = getClass().getClassLoader().loadClass(FALLBACK_TRANSACTION_MANAGER_CLASS_NAME);
transactionClass = getClass().getClassLoader().loadClass(FALLBACK_TRANSACTION_CLASS_NAME);
}
catch (ClassNotFoundException ex2) {
throw new TransactionSystemException(
"Could not initialize OC4JJtaTransactionManager because OC4J API classes are not available", ex);
}
}
// Cache reflective Method references for later use.
if (transactionManagerClass.isInstance(getUserTransaction())) {
this.beginWithNameMethod = ClassUtils.getMethodIfAvailable(
transactionManagerClass, "begin", String.class);
this.setTransactionIsolationMethod = ClassUtils.getMethodIfAvailable(
transactionClass, "setTransactionIsolation", int.class);
logger.info("Support for OC4J transaction names and isolation levels available");
}
else {
logger.info("Support for OC4J transaction names and isolation levels not available");
}
}
@Override
protected void doJtaBegin(JtaTransactionObject txObject, TransactionDefinition definition)
throws NotSupportedException, SystemException {
int timeout = determineTimeout(definition);
applyTimeout(txObject, timeout);
// Apply transaction name, if any, through the extended OC4J transaction begin method.
if (this.beginWithNameMethod != null && definition.getName() != null) {
/*
oracle.j2ee.transaction.OC4JTransactionManager otm = (oracle.j2ee.transaction.OC4JTransactionManager) ut;
otm.begin(definition.getName());
*/
try {
this.beginWithNameMethod.invoke(txObject.getUserTransaction(), definition.getName());
}
catch (InvocationTargetException ex) {
throw new TransactionSystemException(
"OC4J's UserTransaction.begin(String) method failed", ex.getTargetException());
}
catch (Exception ex) {
throw new TransactionSystemException(
"Could not invoke OC4J's UserTransaction.begin(String) method", ex);
}
}
else {
// No OC4J UserTransaction available or no transaction name specified
// -> standard JTA begin call.
txObject.getUserTransaction().begin();
}
// Specify isolation level, if any, through the corresponding OC4J transaction method.
if (this.setTransactionIsolationMethod != null) {
if (definition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT) {
try {
Transaction tx = getTransactionManager().getTransaction();
/*
oracle.j2ee.transaction.OC4JTransaction otx = (oracle.j2ee.transaction.OC4JTransaction) tx;
otx.setTransactionIsolation(definition.getIsolationLevel());
*/
this.setTransactionIsolationMethod.invoke(tx, definition.getIsolationLevel());
}
catch (InvocationTargetException ex) {
throw new TransactionSystemException(
"OC4J's Transaction.setTransactionIsolation(int) method failed", ex.getTargetException());
}
catch (Exception ex) {
throw new TransactionSystemException(
"Could not invoke OC4J's Transaction.setTransactionIsolation(int) method", ex);
}
}
}
else {
applyIsolationLevel(txObject, definition.getIsolationLevel());
}
}
@Override
public Transaction createTransaction(String name, int timeout) throws NotSupportedException, SystemException {
if (this.beginWithNameMethod != null && name != null) {
UserTransaction ut = getUserTransaction();
if (timeout >= 0) {
ut.setTransactionTimeout(timeout);
}
try {
this.beginWithNameMethod.invoke(ut, name);
}
catch (InvocationTargetException ex) {
if (ex.getTargetException() instanceof NotSupportedException) {
throw (NotSupportedException) ex.getTargetException();
}
else if (ex.getTargetException() instanceof SystemException) {
throw (SystemException) ex.getTargetException();
}
else if (ex.getTargetException() instanceof RuntimeException) {
throw (RuntimeException) ex.getTargetException();
}
else {
throw new SystemException(
"OC4J's begin(String) method failed with an unexpected error: " + ex.getTargetException());
}
}
catch (Exception ex) {
throw new SystemException("Could not invoke OC4J's UserTransaction.begin(String) method: " + ex);
}
return new ManagedTransactionAdapter(getTransactionManager());
}
else {
// No name specified - standard JTA is sufficient.
return super.createTransaction(name, timeout);
}
}
}

View File

@@ -0,0 +1,247 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsd:schema xmlns="http://www.springframework.org/schema/tx"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:tool="http://www.springframework.org/schema/tool"
targetNamespace="http://www.springframework.org/schema/tx"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:import namespace="http://www.springframework.org/schema/beans" schemaLocation="http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"/>
<xsd:import namespace="http://www.springframework.org/schema/tool" schemaLocation="http://www.springframework.org/schema/tool/spring-tool-3.2.xsd"/>
<xsd:annotation>
<xsd:documentation><![CDATA[
Defines the elements used in the Spring Framework's declarative
transaction management infrastructure.
]]></xsd:documentation>
</xsd:annotation>
<xsd:element name="advice">
<xsd:complexType>
<xsd:annotation>
<xsd:documentation source="java:org.springframework.transaction.interceptor.TransactionInterceptor"><![CDATA[
Defines the transactional semantics of the AOP advice that is to be
executed.
That is, this advice element is where the transactional semantics of
any number of methods are defined (where transactional semantics
includes the propagation settings, the isolation level, the rollback
rules, and suchlike).
]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation>
<tool:exports type="org.springframework.transaction.interceptor.TransactionInterceptor"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="beans:identifiedType">
<xsd:sequence>
<xsd:element name="attributes" type="attributesType" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="transaction-manager" type="xsd:string" default="transactionManager">
<xsd:annotation>
<xsd:documentation source="java:org.springframework.transaction.PlatformTransactionManager"><![CDATA[
The bean name of the PlatformTransactionManager that is to be used
to drive transactions.
This attribute is not required, and only needs to be specified
explicitly if the bean name of the desired PlatformTransactionManager
is not 'transactionManager'.
]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.transaction.PlatformTransactionManager"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="annotation-driven">
<xsd:complexType>
<xsd:annotation>
<xsd:documentation source="java:org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"><![CDATA[
Indicates that transaction configuration is defined by Java 5
annotations on bean classes, and that proxies are automatically
to be created for the relevant annotated beans.
The default annotations supported are Spring's @Transactional
and EJB3's @TransactionAttribute (if available).
Transaction semantics such as propagation settings, the isolation level,
the rollback rules, etc are all defined in the annotation metadata.
See org.springframework.transaction.annotation.EnableTransactionManagement Javadoc
for information on code-based alternatives to this XML element.
]]></xsd:documentation>
</xsd:annotation>
<xsd:attribute name="transaction-manager" type="xsd:string" default="transactionManager">
<xsd:annotation>
<xsd:documentation source="java:org.springframework.transaction.PlatformTransactionManager"><![CDATA[
The bean name of the PlatformTransactionManager that is to be used
to drive transactions.
This attribute is not required, and only needs to be specified
explicitly if the bean name of the desired PlatformTransactionManager
is not 'transactionManager'.
]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.transaction.PlatformTransactionManager"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="mode" default="proxy">
<xsd:annotation>
<xsd:documentation><![CDATA[
Should annotated beans be proxied using Spring's AOP framework,
or should they rather be weaved with an AspectJ transaction aspect?
AspectJ weaving requires spring-aspects.jar on the classpath,
as well as load-time weaving (or compile-time weaving) enabled.
Note: The weaving-based aspect requires the @Transactional annotation to be
defined on the concrete class. Annotations in interfaces will not work
in that case (they will rather only work with interface-based proxies)!
]]></xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="proxy"/>
<xsd:enumeration value="aspectj"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="proxy-target-class" type="xsd:boolean" default="false">
<xsd:annotation>
<xsd:documentation><![CDATA[
Are class-based (CGLIB) proxies to be created? By default, standard
Java interface-based proxies are created.
Note: Class-based proxies require the @Transactional annotation to be
defined on the concrete class. Annotations in interfaces will not work
in that case (they will rather only work with interface-based proxies)!
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="order" type="xsd:int">
<xsd:annotation>
<xsd:documentation source="java:org.springframework.core.Ordered"><![CDATA[
Controls the ordering of the execution of the transaction advisor
when multiple advice executes at a specific joinpoint.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:element name="jta-transaction-manager">
<xsd:annotation>
<xsd:documentation><![CDATA[
Creates a default JtaTransactionManager bean with name "transactionManager",
matching the default bean name expected by the "annotation-driven" tag.
Automatically detects WebLogic and WebSphere: creating a WebLogicJtaTransactionManager
or WebSphereUowTransactionManager, respectively.
For customization needs, consider defining a JtaTransactionManager bean as a regular
Spring bean definition with name "transactionManager", replacing this element.
]]></xsd:documentation>
<xsd:appinfo>
<tool:annotation>
<tool:exports type="org.springframework.transaction.jta.JtaTransactionManager"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:complexType name="attributesType">
<xsd:sequence>
<xsd:element name="method" minOccurs="1" maxOccurs="unbounded">
<xsd:complexType>
<xsd:attribute name="name" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation><![CDATA[
The method name(s) with which the transaction attributes are to be
associated. The wildcard (*) character can be used to associate the
same transaction attribute settings with a number of methods; for
example, 'get*', 'handle*', '*Order', 'on*Event', etc.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="propagation" default="REQUIRED">
<xsd:annotation>
<xsd:documentation source="java:org.springframework.transaction.annotation.Propagation"><![CDATA[
The transaction propagation behavior.
]]></xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="REQUIRED"/>
<xsd:enumeration value="SUPPORTS"/>
<xsd:enumeration value="MANDATORY"/>
<xsd:enumeration value="REQUIRES_NEW"/>
<xsd:enumeration value="NOT_SUPPORTED"/>
<xsd:enumeration value="NEVER"/>
<xsd:enumeration value="NESTED"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="isolation" default="DEFAULT">
<xsd:annotation>
<xsd:documentation source="java:org.springframework.transaction.annotation.Isolation"><![CDATA[
The transaction isolation level.
]]></xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="DEFAULT"/>
<xsd:enumeration value="READ_UNCOMMITTED"/>
<xsd:enumeration value="READ_COMMITTED"/>
<xsd:enumeration value="REPEATABLE_READ"/>
<xsd:enumeration value="SERIALIZABLE"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="timeout" type="xsd:integer" default="-1">
<xsd:annotation>
<xsd:documentation><![CDATA[
The transaction timeout value (in seconds).
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="read-only" type="xsd:boolean" default="false">
<xsd:annotation>
<xsd:documentation><![CDATA[
Is this transaction read-only?
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="rollback-for" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The Exception(s) that will trigger rollback; comma-delimited.
For example, 'com.foo.MyBusinessException,ServletException'
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="no-rollback-for" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
The Exception(s) that will *not* trigger rollback; comma-delimited.
For example, 'com.foo.MyBusinessException,ServletException'
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>