dain 2004/04/06 14:41:47
Modified: modules/core/src/java/org/openejb/proxy
EJBMethodInterceptor.java EJBProxyHelper.java
Log:
Added an assembly module
Fixed remaining not serializable bugs
Added configuration files for itests to deploy into new assembly
Revision Changes Path
1.3 +5 -1
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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- EJBMethodInterceptor.java 21 Mar 2004 21:26:35 -0000 1.2
+++ EJBMethodInterceptor.java 6 Apr 2004 18:41:47 -0000 1.3
@@ -5,6 +5,7 @@
import java.rmi.RemoteException;
import javax.ejb.EJBException;
import javax.ejb.Handle;
+import javax.ejb.EJBObject;
import org.apache.geronimo.core.service.InvocationResult;
@@ -93,7 +94,10 @@
}
id = args[0];
if(id instanceof Handle && interfaceType == EJBInterfaceType.HOME) {
- id = EJBProxyHelper.getPrimaryKey((Handle)id);
+ HandleImpl handle = (HandleImpl) id;
+ EJBObject ejbObject = handle.getEJBObject();
+ EJBMethodInterceptor ejbHandler = ((BaseEJB)ejbObject).ejbHandler;
+ id = ejbHandler.getPrimaryKey();
}
}
1.3 +27 -21
openejb/modules/core/src/java/org/openejb/proxy/EJBProxyHelper.java
Index: EJBProxyHelper.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/proxy/EJBProxyHelper.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- EJBProxyHelper.java 21 Mar 2004 21:26:35 -0000 1.2
+++ EJBProxyHelper.java 6 Apr 2004 18:41:47 -0000 1.3
@@ -51,11 +51,6 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
-import javax.ejb.EJBHome;
-import javax.ejb.EJBLocalHome;
-import javax.ejb.EJBLocalObject;
-import javax.ejb.EJBObject;
-import javax.ejb.Handle;
import net.sf.cglib.reflect.FastClass;
import org.openejb.dispatch.InterfaceMethodSignature;
@@ -65,22 +60,8 @@
* @version $Revision$ $Date$
*/
public class EJBProxyHelper {
- public static Object getPrimaryKey(Handle h) {
- HandleImpl handle = (HandleImpl)h;
- EJBObject ejbObject = handle.getEJBObject();
- EJBMethodInterceptor ejbHandler = ((BaseEJB)ejbObject).ejbHandler;
- return ejbHandler.getPrimaryKey();
- }
-
public static int[] getOperationMap(Class proxyType, InterfaceMethodSignature[]
signatures) {
- boolean isHomeInterface;
- if(EJBHome.class.isAssignableFrom(proxyType) ||
EJBLocalHome.class.isAssignableFrom(proxyType)) {
- isHomeInterface = true;
- } else if (EJBObject.class.isAssignableFrom(proxyType) ||
EJBLocalObject.class.isAssignableFrom(proxyType)) {
- isHomeInterface = false;
- } else {
- throw new IllegalArgumentException("ProxyType must be an instance of
EJBHome, EJBLocalHome, EJBObject, or EJBLocalObject");
- }
+ boolean isHomeInterface = isHomeInterface(proxyType);
// get the map from method keys to the intercepted shadow index
Map proxyToShadowIndex = buildProxyToShadowIndex(proxyType,
isHomeInterface);
@@ -101,6 +82,31 @@
return shadowIndexToProxy;
}
+ private static boolean isHomeInterface(Class proxyType) {
+ //
+ // NOTE: We must load the ejb classes from the proxy's classloader because
during deployment the
+ // proxy's classloader is not a child of the classloader of this class
+ //
+ try {
+ ClassLoader cl = proxyType.getClassLoader();
+ Class ejbHomeClass = cl.loadClass("javax.ejb.EJBHome");
+ Class ejbLocalHomeClass = cl.loadClass("javax.ejb.EJBLocalHome");
+ if(ejbHomeClass.isAssignableFrom(proxyType) ||
ejbLocalHomeClass.isAssignableFrom(proxyType)) {
+ return true;
+ }
+
+ Class ejbObjectClass = cl.loadClass("javax.ejb.EJBObject");
+ Class ejbLocalObjectClass = cl.loadClass("javax.ejb.EJBLocalObject");
+ if (ejbObjectClass.isAssignableFrom(proxyType) ||
ejbLocalObjectClass.isAssignableFrom(proxyType)) {
+ return false;
+ }
+ } catch (ClassNotFoundException e) {
+ // ignore... exception thrown below
+ }
+
+ throw new IllegalArgumentException("ProxyType must be an instance of
EJBHome, EJBLocalHome, EJBObject, or EJBLocalObject");
+ }
+
/**
* Builds a map from the MethodKeys for the real method to the index of
* the shadow method, which is the same number returned from
MethodProxy.getSuperIndex().