dain 2005/03/15 01:03:05
Modified: modules/core/src/java/org/openejb/proxy
EJBMethodInterceptor.java
Log:
Invocations arguments should be coppied into the target ejb container's
classloader.
Revision Changes Path
1.12 +15 -8
openejb/modules/core/src/java/org/openejb/proxy/EJBMethodInterceptor.java
Index: EJBMethodInterceptor.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/proxy/EJBMethodInterceptor.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- EJBMethodInterceptor.java 10 Feb 2005 11:00:00 -0000 1.11
+++ EJBMethodInterceptor.java 15 Mar 2005 06:03:05 -0000 1.12
@@ -62,6 +62,11 @@
private transient ClassLoader sourceClassLoader;
/**
+ * The classloader of the target ejb container
+ */
+ private transient ClassLoader targetClassLoader;
+
+ /**
* Does this proxy target a container in a differenct classloader?
*/
private transient boolean crossClassLoader;
@@ -79,7 +84,8 @@
if (container != null) {
sourceClassLoader = proxyFactory.getClassLoader();
- crossClassLoader = isCrossClassLoader(sourceClassLoader,
container.getClassLoader());
+ targetClassLoader = container.getClassLoader();
+ crossClassLoader = isCrossClassLoader(sourceClassLoader,
targetClassLoader);
// @todo REMOVE: this is a dirty dirty dirty hack to make the
old openejb code work
// this lets really stupid clients get access to the primary key
of the proxy, which is readily
@@ -114,7 +120,7 @@
// copy the arguments into the target classloader
if (shouldCopy) {
args = invocation.getArguments();
- copyArgs(args);
+ copyArgsToTargetCL(args);
}
// invoke the EJB container
@@ -145,7 +151,7 @@
}
if (shouldCopy && returnObj != null) {
- returnObj = copyObject(returnObj);
+ returnObj = copyReturnToSourceCL(returnObj);
}
if (normal) {
@@ -197,14 +203,14 @@
return new EJBInvocationImpl(interfaceType, id, methodIndex, args);
}
- private void copyArgs(Object[] args) throws IOException,
ClassNotFoundException {
+ private void copyArgsToTargetCL(Object[] args) throws IOException,
ClassNotFoundException {
if (args != null && args.length > 0) {
ClassLoader oldCl =
Thread.currentThread().getContextClassLoader();
try {
-
Thread.currentThread().setContextClassLoader(sourceClassLoader);
+
Thread.currentThread().setContextClassLoader(targetClassLoader);
if (crossClassLoader) {
SerializationHanlder.setStrategy(ReplacementStrategy.IN_VM_REPLACE);
- SerializationHanlder.copyArgs(sourceClassLoader, args);
+ SerializationHanlder.copyArgs(targetClassLoader, args);
} else {
SerializationHanlder.setStrategy(ReplacementStrategy.COPY);
SerializationHanlder.copyArgs(args);
@@ -216,7 +222,7 @@
}
}
- private Object copyObject(Object returnObj) throws IOException,
ClassNotFoundException {
+ private Object copyReturnToSourceCL(Object returnObj) throws
IOException, ClassNotFoundException {
if (returnObj == null) {
return null;
}
@@ -243,7 +249,8 @@
operationMap = proxyFactory.getOperationMap(interfaceType);
sourceClassLoader = proxyFactory.getClassLoader();
- crossClassLoader = isCrossClassLoader(sourceClassLoader,
container.getClassLoader());
+ targetClassLoader = container.getClassLoader();
+ crossClassLoader = isCrossClassLoader(sourceClassLoader,
targetClassLoader);
// @todo REMOVE: this is a dirty dirty dirty hack to make the old
openejb code work
// this lets really stupid clients get access to the primary key of
the proxy, which is readily