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. * *

Customizing the {@code LoadTimeWeaver}

- * The default weaver is determined automatically. As of Spring 3.1: detecting - * Sun's GlassFish, Oracle's OC4J, Spring's VM agent and any ClassLoader supported by - * Spring's {@link - * org.springframework.instrument.classloading.ReflectiveLoadTimeWeaver - * ReflectiveLoadTimeWeaver} (for example, the {@link - * org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader - * TomcatInstrumentableClassLoader}). + * The default weaver is determined automatically: see {@link DefaultContextLoadTimeWeaver}. * *

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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + tag for that purpose. + + See Javadoc for org.springframework.context.annotation.AnnotationConfigApplicationContext + for information on code-based alternatives to bootstrapping annotation-driven support. + from XML. + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-core/src/main/java/org/springframework/util/ResourceUtils.java b/spring-core/src/main/java/org/springframework/util/ResourceUtils.java index 8acebff9ab..b695e2f85a 100644 --- a/spring-core/src/main/java/org/springframework/util/ResourceUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ResourceUtils.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. @@ -75,9 +75,6 @@ public abstract class ResourceUtils { /** URL protocol for an entry from a WebSphere jar file: "wsjar" */ public static final String URL_PROTOCOL_WSJAR = "wsjar"; - /** URL protocol for an entry from an OC4J jar file: "code-source" */ - public static final String URL_PROTOCOL_CODE_SOURCE = "code-source"; - /** Separator between JAR URL and file path within the JAR */ public static final String JAR_URL_SEPARATOR = "!/"; @@ -261,18 +258,14 @@ public abstract class ResourceUtils { /** * Determine whether the given URL points to a resource in a jar file, * that is, has protocol "jar", "zip", "wsjar" or "code-source". - *

"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: - *

+ * with almost any connection pool. * *

For full usage with JdbcTemplate, i.e. to also provide Statement unwrapping: *