diff --git a/spring-context/src/main/java/org/springframework/context/annotation/EnableLoadTimeWeaving.java b/spring-context/src/main/java/org/springframework/context/annotation/EnableLoadTimeWeaving.java index 3c8abd8066..eb8776cf9b 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/EnableLoadTimeWeaving.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/EnableLoadTimeWeaving.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 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. @@ -55,13 +55,7 @@ import org.springframework.instrument.classloading.LoadTimeWeaver; * Spring's JPA bootstrap support. * *
To customize the weaver used, the {@code @Configuration} class annotated with * {@code @EnableLoadTimeWeaving} may also implement the {@link LoadTimeWeavingConfigurer} diff --git a/spring-context/src/main/java/org/springframework/context/weaving/AspectJWeavingEnabler.java b/spring-context/src/main/java/org/springframework/context/weaving/AspectJWeavingEnabler.java index 9037014488..4cb6567faf 100644 --- a/spring-context/src/main/java/org/springframework/context/weaving/AspectJWeavingEnabler.java +++ b/spring-context/src/main/java/org/springframework/context/weaving/AspectJWeavingEnabler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 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. @@ -22,6 +22,7 @@ import java.lang.instrument.IllegalClassFormatException; import java.security.ProtectionDomain; import org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter; + import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; @@ -82,9 +83,7 @@ public class AspectJWeavingEnabler /** * ClassFileTransformer decorator that suppresses processing of AspectJ - * classes in order to avoid potential LinkageErrors. Required especially for OC4J and - * Tomcat (in Glassfish). - * + * classes in order to avoid potential LinkageErrors. * @see org.springframework.context.annotation.LoadTimeWeavingConfiguration */ private static class AspectJClassBypassingClassFileTransformer implements ClassFileTransformer { diff --git a/spring-context/src/main/java/org/springframework/context/weaving/DefaultContextLoadTimeWeaver.java b/spring-context/src/main/java/org/springframework/context/weaving/DefaultContextLoadTimeWeaver.java index 495f3c7025..1cc0ab6b4f 100644 --- a/spring-context/src/main/java/org/springframework/context/weaving/DefaultContextLoadTimeWeaver.java +++ b/spring-context/src/main/java/org/springframework/context/weaving/DefaultContextLoadTimeWeaver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 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. @@ -29,7 +29,6 @@ import org.springframework.instrument.classloading.LoadTimeWeaver; import org.springframework.instrument.classloading.ReflectiveLoadTimeWeaver; import org.springframework.instrument.classloading.glassfish.GlassFishLoadTimeWeaver; import org.springframework.instrument.classloading.jboss.JBossLoadTimeWeaver; -import org.springframework.instrument.classloading.oc4j.OC4JLoadTimeWeaver; import org.springframework.instrument.classloading.weblogic.WebLogicLoadTimeWeaver; import org.springframework.instrument.classloading.websphere.WebSphereLoadTimeWeaver; @@ -43,12 +42,11 @@ import org.springframework.instrument.classloading.websphere.WebSphereLoadTimeWe * *
This class implements a runtime environment check for obtaining * the appropriate weaver implementation: As of Spring 3.1, it detects - * Oracle WebLogic 10, Oracle OC4J 10, GlassFish 3, JBoss AS 5, 6 and 7, - * IBM WebSphere 7 and 8, {@link InstrumentationSavingAgent Spring's VM agent} - * and any {@link ClassLoader} supported by Spring's {@link ReflectiveLoadTimeWeaver} - * (for example the + * Oracle WebLogic 10, GlassFish 3, JBoss AS 5, 6 and 7, IBM WebSphere 7 and 8, + * {@link InstrumentationSavingAgent Spring's VM agent}, and any {@link ClassLoader} + * supported by Spring's {@link ReflectiveLoadTimeWeaver} (for example the * {@link org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader} - * for Tomcat 5, 6 and 7). + * for Tomcat 6 and 7). * * @author Juergen Hoeller * @author Ramnivas Laddad @@ -112,9 +110,6 @@ public class DefaultContextLoadTimeWeaver implements LoadTimeWeaver, BeanClassLo if (name.startsWith("weblogic")) { return new WebLogicLoadTimeWeaver(classLoader); } - else if (name.startsWith("oracle")) { - return new OC4JLoadTimeWeaver(classLoader); - } else if (name.startsWith("com.sun.enterprise") || name.startsWith("org.glassfish")) { return new GlassFishLoadTimeWeaver(classLoader); } diff --git a/spring-context/src/main/java/org/springframework/instrument/classloading/oc4j/OC4JClassLoaderAdapter.java b/spring-context/src/main/java/org/springframework/instrument/classloading/oc4j/OC4JClassLoaderAdapter.java deleted file mode 100644 index b1300d699b..0000000000 --- a/spring-context/src/main/java/org/springframework/instrument/classloading/oc4j/OC4JClassLoaderAdapter.java +++ /dev/null @@ -1,88 +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.instrument.classloading.oc4j; - -import java.lang.instrument.ClassFileTransformer; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; - -import org.springframework.util.Assert; - -/** - * Reflective wrapper around a OC4J class loader. Used to - * encapsulate the classloader-specific methods (discovered and - * called through reflection) from the load-time weaver. - * - * @author Costin Leau - */ -class OC4JClassLoaderAdapter { - - private static final String CL_UTILS = "oracle.classloader.util.ClassLoaderUtilities"; - private static final String PREPROCESS_UTILS = "oracle.classloader.util.ClassPreprocessor"; - - private final ClassLoader classLoader; - private final Class> processorClass; - private final Method addTransformer; - private final Method copy; - - public OC4JClassLoaderAdapter(ClassLoader classLoader) { - try { - // Since OC4J 10.1.3's PolicyClassLoader is going to be removed, - // we rely on the ClassLoaderUtilities API instead. - Class> utilClass = classLoader.loadClass(CL_UTILS); - this.processorClass = classLoader.loadClass(PREPROCESS_UTILS); - - this.addTransformer = utilClass.getMethod("addPreprocessor", new Class[] { ClassLoader.class, - this.processorClass }); - this.copy = utilClass.getMethod("copy", new Class[] { ClassLoader.class }); - - } catch (Exception ex) { - throw new IllegalStateException( - "Could not initialize OC4J LoadTimeWeaver because OC4J API classes are not available", ex); - } - - this.classLoader = classLoader; - } - - public void addTransformer(ClassFileTransformer transformer) { - Assert.notNull(transformer, "ClassFileTransformer must not be null"); - try { - OC4JClassPreprocessorAdapter adapter = new OC4JClassPreprocessorAdapter(transformer); - Object adapterInstance = Proxy.newProxyInstance(this.processorClass.getClassLoader(), - new Class[] { this.processorClass }, adapter); - this.addTransformer.invoke(null, new Object[] { this.classLoader, adapterInstance }); - } catch (InvocationTargetException ex) { - throw new IllegalStateException("OC4J addPreprocessor method threw exception", ex.getCause()); - } catch (Exception ex) { - throw new IllegalStateException("Could not invoke OC4J addPreprocessor method", ex); - } - } - - public ClassLoader getClassLoader() { - return this.classLoader; - } - - public ClassLoader getThrowawayClassLoader() { - try { - return (ClassLoader) this.copy.invoke(null, new Object[] { this.classLoader }); - } catch (InvocationTargetException ex) { - throw new IllegalStateException("OC4J copy method failed", ex.getCause()); - } catch (Exception ex) { - throw new IllegalStateException("Could not copy OC4J classloader", ex); - } - } -} diff --git a/spring-context/src/main/java/org/springframework/instrument/classloading/oc4j/OC4JClassPreprocessorAdapter.java b/spring-context/src/main/java/org/springframework/instrument/classloading/oc4j/OC4JClassPreprocessorAdapter.java deleted file mode 100644 index 5b56adf42c..0000000000 --- a/spring-context/src/main/java/org/springframework/instrument/classloading/oc4j/OC4JClassPreprocessorAdapter.java +++ /dev/null @@ -1,95 +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.instrument.classloading.oc4j; - -import java.lang.instrument.ClassFileTransformer; -import java.lang.instrument.IllegalClassFormatException; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.security.ProtectionDomain; - -/** - * Adapter that implements OC4J ClassPreProcessor interface, delegating to a - * standard JDK {@link ClassFileTransformer} underneath. - * - *
To avoid compile time checks again the vendor API, a dynamic proxy is - * being used. - * - * @author Costin Leau - */ -class OC4JClassPreprocessorAdapter implements InvocationHandler { - - private final ClassFileTransformer transformer; - - /** - * Creates a new {@link OC4JClassPreprocessorAdapter}. - * @param transformer the {@link ClassFileTransformer} to be adapted (must - * not be {@code null}) - */ - public OC4JClassPreprocessorAdapter(ClassFileTransformer transformer) { - this.transformer = transformer; - } - - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - String name = method.getName(); - - if ("equals".equals(name)) { - return (Boolean.valueOf(proxy == args[0])); - } else if ("hashCode".equals(name)) { - return hashCode(); - } else if ("toString".equals(name)) { - return toString(); - } else if ("initialize".equals(name)) { - initialize(proxy, (ClassLoader) args[0]); - return null; - } else if ("processClass".equals(name)) { - return processClass((String) args[0], (byte[]) args[1], (Integer) args[2], (Integer) args[3], - (ProtectionDomain) args[4], (ClassLoader) args[5]); - } else { - throw new IllegalArgumentException("Unknown method: " + method); - } - } - - // maps to oracle.classloader.util.ClassPreprocessor#initialize - // the proxy is passed since it implements the Oracle interface which - // is asked as a return type - public Object initialize(Object proxy, ClassLoader loader) { - return proxy; - } - - public byte[] processClass(String className, byte origClassBytes[], int offset, int length, ProtectionDomain pd, - ClassLoader loader) { - try { - byte[] tempArray = new byte[length]; - System.arraycopy(origClassBytes, offset, tempArray, 0, length); - - // NB: OC4J passes className as "." without class while the - // transformer expects a VM, "/" format - byte[] result = this.transformer.transform(loader, className.replace('.', '/'), null, pd, tempArray); - return (result != null ? result : origClassBytes); - } catch (IllegalClassFormatException ex) { - throw new IllegalStateException("Cannot transform because of illegal class format", ex); - } - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(getClass().getName()); - builder.append(" for transformer: "); - builder.append(this.transformer); - return builder.toString(); - } -} diff --git a/spring-context/src/main/java/org/springframework/instrument/classloading/oc4j/OC4JLoadTimeWeaver.java b/spring-context/src/main/java/org/springframework/instrument/classloading/oc4j/OC4JLoadTimeWeaver.java deleted file mode 100644 index 54211b00d6..0000000000 --- a/spring-context/src/main/java/org/springframework/instrument/classloading/oc4j/OC4JLoadTimeWeaver.java +++ /dev/null @@ -1,79 +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.instrument.classloading.oc4j; - -import java.lang.instrument.ClassFileTransformer; - -import org.springframework.instrument.classloading.LoadTimeWeaver; -import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; - -/** - * {@link LoadTimeWeaver} implementation for OC4J's instrumentable ClassLoader. - * Requires Oracle OC4J version 10.1.3.1 or higher. - * - *
Many thanks to Mike Keith - * for his assistance. - * - * @author Costin Leau - * @author Juergen Hoeller - * @since 2.0 - * @deprecated as of Spring 3.2, in favor of - * {@link org.springframework.instrument.classloading.weblogic.WebLogicLoadTimeWeaver} - * since Oracle end-of-lifed OC4J in favor of WebLogic - */ -@Deprecated -public class OC4JLoadTimeWeaver implements LoadTimeWeaver { - - private final OC4JClassLoaderAdapter classLoader; - - - /** - * Creates a new instance of thie {@link OC4JLoadTimeWeaver} class - * using the default {@link ClassLoader class loader}. - * @see org.springframework.util.ClassUtils#getDefaultClassLoader() - */ - public OC4JLoadTimeWeaver() { - this(ClassUtils.getDefaultClassLoader()); - } - - /** - * Creates a new instance of the {@link OC4JLoadTimeWeaver} class - * using the supplied {@link ClassLoader}. - * @param classLoader the {@code ClassLoader} to delegate to for weaving - */ - public OC4JLoadTimeWeaver(ClassLoader classLoader) { - Assert.notNull(classLoader, "ClassLoader must not be null"); - this.classLoader = new OC4JClassLoaderAdapter(classLoader); - } - - - public void addTransformer(ClassFileTransformer transformer) { - Assert.notNull(transformer, "Transformer must not be null"); - // Since OC4J 10.1.3's PolicyClassLoader is going to be removed, - // we rely on the ClassLoaderUtilities API instead. - this.classLoader.addTransformer(transformer); - } - - public ClassLoader getInstrumentableClassLoader() { - return this.classLoader.getClassLoader(); - } - - public ClassLoader getThrowawayClassLoader() { - return this.classLoader.getThrowawayClassLoader(); - } -} diff --git a/spring-context/src/main/java/org/springframework/instrument/classloading/oc4j/package-info.java b/spring-context/src/main/java/org/springframework/instrument/classloading/oc4j/package-info.java deleted file mode 100644 index 6ee3fb7dc0..0000000000 --- a/spring-context/src/main/java/org/springframework/instrument/classloading/oc4j/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ - -/** - * - * Support for class instrumentation on Oracle OC4J. - * - */ -package org.springframework.instrument.classloading.oc4j; - diff --git a/spring-context/src/main/java/org/springframework/remoting/rmi/RmiClientInterceptorUtils.java b/spring-context/src/main/java/org/springframework/remoting/rmi/RmiClientInterceptorUtils.java index 1a9d8413a3..d057bb682b 100644 --- a/spring-context/src/main/java/org/springframework/remoting/rmi/RmiClientInterceptorUtils.java +++ b/spring-context/src/main/java/org/springframework/remoting/rmi/RmiClientInterceptorUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 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. @@ -51,8 +51,6 @@ import org.springframework.util.ReflectionUtils; */ public abstract class RmiClientInterceptorUtils { - private static final String ORACLE_CONNECTION_EXCEPTION = "com.evermind.server.rmi.RMIConnectionException"; - private static final Log logger = LogFactory.getLog(RmiClientInterceptorUtils.class); @@ -198,9 +196,7 @@ public abstract class RmiClientInterceptorUtils { /** * Determine whether the given RMI exception indicates a connect failure. *
Treats RMI's ConnectException, ConnectIOException, UnknownHostException,
- * NoSuchObjectException and StubNotFoundException as connect failure,
- * as well as Oracle's OC4J {@code com.evermind.server.rmi.RMIConnectionException}
- * (which doesn't derive from from any well-known RMI connect exception).
+ * NoSuchObjectException and StubNotFoundException as connect failure.
* @param ex the RMI exception to check
* @return whether the exception should be treated as connect failure
* @see java.rmi.ConnectException
@@ -213,7 +209,7 @@ public abstract class RmiClientInterceptorUtils {
return (ex instanceof ConnectException || ex instanceof ConnectIOException ||
ex instanceof UnknownHostException || ex instanceof NoSuchObjectException ||
ex instanceof StubNotFoundException || ex.getCause() instanceof SocketException ||
- isCorbaConnectFailure(ex.getCause()) || ORACLE_CONNECTION_EXCEPTION.equals(ex.getClass().getName()));
+ isCorbaConnectFailure(ex.getCause()));
}
/**
diff --git a/spring-context/src/main/resources/org/springframework/context/config/spring-context-4.0.xsd b/spring-context/src/main/resources/org/springframework/context/config/spring-context-4.0.xsd
new file mode 100644
index 0000000000..d71bf4beea
--- /dev/null
+++ b/spring-context/src/main/resources/org/springframework/context/config/spring-context-4.0.xsd
@@ -0,0 +1,531 @@
+
+
+
"zip" and "wsjar" are used by BEA WebLogic Server and IBM WebSphere, respectively, - * but can be treated like jar files. The same applies to "code-source" URLs on Oracle - * OC4J, provided that the path contains a jar separator. + *
"zip" and "wsjar" are used by WebLogic Server and WebSphere, respectively, + * but can be treated like jar files. * @param url the URL to check * @return whether the URL has been identified as a JAR URL */ public static boolean isJarURL(URL url) { - String protocol = url.getProtocol(); - return (URL_PROTOCOL_JAR.equals(protocol) || - URL_PROTOCOL_ZIP.equals(protocol) || - URL_PROTOCOL_WSJAR.equals(protocol) || - (URL_PROTOCOL_CODE_SOURCE.equals(protocol) && url.getPath().contains(JAR_URL_SEPARATOR))); + String up = url.getProtocol(); + return (URL_PROTOCOL_JAR.equals(up) || URL_PROTOCOL_ZIP.equals(up) || URL_PROTOCOL_WSJAR.equals(up)); } /** diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/nativejdbc/SimpleNativeJdbcExtractor.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/nativejdbc/SimpleNativeJdbcExtractor.java index 0d00da4d9f..fa0a1efc9d 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/nativejdbc/SimpleNativeJdbcExtractor.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/nativejdbc/SimpleNativeJdbcExtractor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 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. @@ -38,22 +38,14 @@ package org.springframework.jdbc.support.nativejdbc; *
SimpleNativeJdbcExtractor is a common choice for use with OracleLobHandler, * which just needs Connection unwrapping via the * {@link #getNativeConnectionFromStatement} method. This usage will work - * with almost any connection pool. Known to work are, for example: - *
For full usage with JdbcTemplate, i.e. to also provide Statement unwrapping: *
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. * *
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). + * (automatically detecting WebLogic and WebSphere). * *
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 diff --git a/spring-tx/src/main/java/org/springframework/transaction/jta/OC4JJtaTransactionManager.java b/spring-tx/src/main/java/org/springframework/transaction/jta/OC4JJtaTransactionManager.java deleted file mode 100644 index 738dcec8ab..0000000000 --- a/spring-tx/src/main/java/org/springframework/transaction/jta/OC4JJtaTransactionManager.java +++ /dev/null @@ -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, beyond standard JTA: transaction names - * and per-transaction isolation levels. - * - *
Uses OC4J's special {@code begin(name)} method to start a JTA transaction, - * in orderto make Spring-driven transactions visible in OC4J's transaction - * monitor. In case of Spring's declarative transactions, the exposed name will - * (by default) be the fully-qualified class name + "." + method name. - * - *
Supports a per-transaction isolation level 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. - * - *
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. - * - *
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. - * - *
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);
- }
- }
-
-}
diff --git a/spring-tx/src/main/resources/org/springframework/transaction/config/spring-tx-4.0.xsd b/spring-tx/src/main/resources/org/springframework/transaction/config/spring-tx-4.0.xsd
new file mode 100644
index 0000000000..427d723249
--- /dev/null
+++ b/spring-tx/src/main/resources/org/springframework/transaction/config/spring-tx-4.0.xsd
@@ -0,0 +1,247 @@
+
+
+