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-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.
*
* <h2>Customizing the {@code LoadTimeWeaver}</h2>
* 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}.
*
* <p>To customize the weaver used, the {@code @Configuration} class annotated with
* {@code @EnableLoadTimeWeaving} may also implement the {@link LoadTimeWeavingConfigurer}

View File

@@ -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 {

View File

@@ -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
*
* <p>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);
}

View File

@@ -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);
}
}
}

View File

@@ -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.
*
* <p>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();
}
}

View File

@@ -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.
*
* <p>Many thanks to <a href="mailto:mike.keith@oracle.com">Mike Keith</a>
* 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();
}
}

View File

@@ -1,8 +0,0 @@
/**
*
* Support for class instrumentation on Oracle OC4J.
*
*/
package org.springframework.instrument.classloading.oc4j;

View File

@@ -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.
* <p>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()));
}
/**