dain 2005/02/08 21:07:56
Modified: modules/core/src/java/org/openejb/proxy BaseEJB.java
EJBMethodInterceptor.java EJBProxyFactory.java
SessionEJBHome.java
Log:
Changed ContainerIndex to throw ContainerNotFoundException when a container
looked up by name is not found.
The ContainerNorFoundException contains the container name which is a lot
more readable the "-1"
Revision Changes Path
1.5 +12 -4
openejb/modules/core/src/java/org/openejb/proxy/BaseEJB.java
Index: BaseEJB.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/proxy/BaseEJB.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- BaseEJB.java 13 Jan 2005 17:00:23 -0000 1.4
+++ BaseEJB.java 9 Feb 2005 02:07:55 -0000 1.5
@@ -90,6 +90,10 @@
import java.io.ObjectStreamException;
import java.io.Serializable;
+import javax.ejb.EJBException;
+
+import org.openejb.ContainerNotFoundException;
+
/**
* @version $Revision$ $Date$
@@ -104,8 +108,12 @@
}
public ProxyInfo getProxyInfo() {
- return ejbHandler.getProxyInfo();
- }
+ try {
+ return ejbHandler.getProxyInfo();
+ } catch (ContainerNotFoundException e) {
+ throw new EJBException("Container not found " + e.getMessage());
+ }
+ }
public EJBProxyFactory getProxyFactory() {
return ejbHandler.getProxyFactory();
1.9 +14 -3
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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- EJBMethodInterceptor.java 16 Apr 2004 02:34:06 -0000 1.8
+++ EJBMethodInterceptor.java 9 Feb 2005 02:07:55 -0000 1.9
@@ -3,9 +3,11 @@
import java.io.Serializable;
import java.lang.reflect.Method;
import java.rmi.RemoteException;
+import java.rmi.NoSuchObjectException;
import javax.ejb.EJBException;
import javax.ejb.Handle;
import javax.ejb.EJBObject;
+import javax.ejb.NoSuchObjectLocalException;
import org.apache.geronimo.core.service.InvocationResult;
@@ -16,6 +18,7 @@
import org.openejb.EJBInvocation;
import org.openejb.EJBInvocationImpl;
import org.openejb.EJBComponentType;
+import org.openejb.ContainerNotFoundException;
public class EJBMethodInterceptor implements MethodInterceptor,
EJBInterceptor, Serializable {
/**
@@ -82,7 +85,7 @@
return proxyFactory;
}
- public ProxyInfo getProxyInfo() {
+ public ProxyInfo getProxyInfo() throws ContainerNotFoundException {
if (proxyInfo == null) {
loadContainerInfo();
}
@@ -110,7 +113,15 @@
public Object intercept(Object proxy, Method method, Object[] args,
MethodProxy methodProxy) throws Throwable {
// fault in the operation map if we don't have it yet
if (operationMap == null) {
- loadContainerInfo();
+ try {
+ loadContainerInfo();
+ } catch (ContainerNotFoundException e) {
+ if (!interfaceType.isLocal()) {
+ throw new NoSuchObjectException(e.getMessage());
+ } else {
+ throw new NoSuchObjectLocalException(e.getMessage());
+ }
+ }
}
// extract the primary key from home ejb remove invocations
@@ -163,7 +174,7 @@
}
}
- private void loadContainerInfo() {
+ private void loadContainerInfo() throws ContainerNotFoundException {
container = proxyFactory.getContainer();
operationMap = proxyFactory.getOperationMap(interfaceType);
1.11 +1 -1
openejb/modules/core/src/java/org/openejb/proxy/EJBProxyFactory.java
Index: EJBProxyFactory.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/proxy/EJBProxyFactory.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- EJBProxyFactory.java 25 Jun 2004 21:35:12 -0000 1.10
+++ EJBProxyFactory.java 9 Feb 2005 02:07:55 -0000 1.11
@@ -1 +1 @@
-/**
* Redistribution and use of this software and associated documentation
* ("Software"), with or without modification, are permitted provided
* that the following conditions are met:
*
* 1. Redistributions of source code must retain copyright
* statements and notices. Redistributions must also contain a
* copy of this document.
*
* 2. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. The name "OpenEJB" must not be used to endorse or promote
* products derived from this Software without prior written
* permission of The OpenEJB Group. For written permission,
* please contact [EMAIL PROTECTED]
*
* 4. Products derived from this Software may not be called "OpenEJB"
* nor may "OpenEJB" appear in their names without prior written
* permission of The OpenEJB Group. OpenEJB is a registered
* trademark of The OpenEJB Group.
*
* 5. Due credit should be given to the OpenEJB Project
* (http://openejb.org/).
*
* THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Copyright 2001 (C) The OpenEJB Group. All Rights Reserved.
*
* $Id$
*/
package org.openejb.proxy;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Collections;
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 org.openejb.ContainerIndex;
import org.openejb.EJBContainer;
import org.openejb.EJBInterfaceType;
import org.openejb.dispatch.InterfaceMethodSignature;
public class EJBProxyFactory implements Serializable,
org.tranql.ejb.EJBProxyFactory {
private static final Class[] sessionBaseClasses =
new Class[]{SessionEJBObject.class, SessionEJBHome.class,
SessionEJBLocalObject.class, SessionEJBLocalHome.class};
private static final Class[] entityBaseClasses =
new Class[]{EntityEJBObject.class, EntityEJBHome.class,
EntityEJBLocalObject.class, EntityEJBLocalHome.class};
private final String containerId;
private final boolean isSessionBean;
private final Class remoteInterface;
private final Class homeInterface;
private final Class localInterface;
private final Class localHomeInterface;
private transient final CglibEJBProxyFactory remoteFactory;
private transient final CglibEJBProxyFactory homeFactory;
private transient final CglibEJBProxyFactory localFactory;
private transient final CglibEJBProxyFactory localHomeFactory;
private transient EJBContainer container;
private transient int[] remoteMap;
private transient int[] homeMap;
private transient int[] localMap;
private transient int[] localHomeMap;
private transient Map legacyMethodMap;
public EJBProxyFactory(EJBContainer container) {
this(container.getProxyInfo());
setContainer(container);
}
public EJBProxyFactory(ProxyInfo proxyInfo) {
this(
proxyInfo.getContainerID(),
proxyInfo.isSessionBean(),
proxyInfo.getRemoteInterface(),
proxyInfo.getHomeInterface(),
proxyInfo.getLocalInterface(),
proxyInfo.getLocalHomeInterface());
}
public EJBProxyFactory(
String containerId,
boolean sessionBean,
Class remoteInterface,
Class homeInterface,
Class localInterface,
Class localHomeInterface) {
this.containerId = containerId;
isSessionBean = sessionBean;
// JNB: these are temporarily disabled due to classloader issues during
deployment
// assert remoteInterface == null || (remoteInterface.isInterface() &&
EJBObject.class.isAssignableFrom(remoteInterface));
this.remoteInterface = remoteInterface;
// assert homeInterface == null || (homeInterface.isInterface() &&
EJBHome.class.isAssignableFrom(homeInterface));
this.homeInterface = homeInterface;
// assert localInterface == null || (localInterface.isInterface() &&
EJBLocalObject.class.isAssignableFrom(localInterface));
this.localInterface = localInterface;
// assert localHomeInterface == null ||
(localHomeInterface.isInterface() &&
EJBLocalHome.class.isAssignableFrom(localHomeInterface));
this.localHomeInterface = localHomeInterface;
this.remoteFactory = getFactory(EJBInterfaceType.REMOTE.getOrdinal(),
remoteInterface);
this.homeFactory = getFactory(EJBInterfaceType.HOME.getOrdinal(),
homeInterface);
this.localFactory = getFactory(EJBInterfaceType.LOCAL.getOrdinal(),
localInterface);
this.localHomeFactory =
getFactory(EJBInterfaceType.LOCALHOME.getOrdinal(), localHomeInterface);
}
public String getEJBName() {
return container.getEJBName();
}
EJBContainer getContainer() {
if (container == null) {
locateContainer();
}
return container;
}
private void setContainer(EJBContainer container) {
assert container != null: "container is null";
this.container = container;
ProxyInfo proxyInfo = container.getProxyInfo();
InterfaceMethodSignature[] signatures = container.getSignatures();
// build the legacy map
Map map = new HashMap();
addLegacyMethods(map, proxyInfo.getRemoteInterface(), signatures);
addLegacyMethods(map, proxyInfo.getHomeInterface(), signatures);
addLegacyMethods(map, proxyInfo.getLocalInterface(), signatures);
addLegacyMethods(map, proxyInfo.getLocalHomeInterface(), signatures);
legacyMethodMap = Collections.unmodifiableMap(map);
remoteMap = createOperationsMap(remoteFactory, signatures);
homeMap = createOperationsMap(homeFactory, signatures);
localMap = createOperationsMap(localFactory, signatures);
localHomeMap = createOperationsMap(localHomeFactory, signatures);
}
int[] getOperationMap(EJBInterfaceType type) {
if (container == null) {
locateContainer();
}
if (type == EJBInterfaceType.REMOTE) {
return remoteMap;
} else if (type == EJBInterfaceType.HOME) {
return homeMap;
} else if (type == EJBInterfaceType.LOCAL) {
return localMap;
} else if (type == EJBInterfaceType.LOCALHOME) {
return localHomeMap;
} else {
throw new IllegalArgumentException("Unsupported interface type " +
type);
}
}
public int getMethodIndex(Method method) {
Integer index = (Integer) legacyMethodMap.get(method);
if (index == null) {
index = new Integer(-1);
}
return index.intValue();
}
public Class getLocalInterfaceClass() {
return localInterface;
}
public Class getRemoteInterfaceClass() {
return remoteInterface;
}
/**
* Return a proxy for the EJB's remote interface. This can be passed back
* to any client that wishes to access the EJB (e.g. in response to a
* call to SessionContext.getEJBObject() )
* @return the proxy for this EJB's home interface
*/
public EJBObject getEJBObject(Object primaryKey) {
EJBMethodInterceptor handler = new EJBMethodInterceptor(
this,
EJBInterfaceType.REMOTE,
container,
remoteMap,
primaryKey);
return (EJBObject) remoteFactory.create(handler);
}
/**
* Return a proxy for the EJB's home interface. This can be passed back
* to any client that wishes to access the EJB (e.g. in response to a
* call to EJBContext.getEJBHome() )
* @return the proxy for this EJB's home interface
*/
public EJBHome getEJBHome() {
EJBMethodInterceptor handler = new EJBMethodInterceptor(
this,
EJBInterfaceType.HOME,
container,
homeMap);
return (EJBHome) homeFactory.create(handler);
}
/**
* Return a proxy for the EJB's local interface. This can be passed back
* to any client that wishes to access the EJB (e.g. in response to a
* call to SessionContext.getEJBLocalObject() )
* @return the proxy for this EJB's local interface
*/
public EJBLocalObject getEJBLocalObject(Object primaryKey) {
EJBMethodInterceptor handler = new EJBMethodInterceptor(
this,
EJBInterfaceType.LOCAL,
container,
localMap,
primaryKey);
return (EJBLocalObject) localFactory.create(handler);
}
/**
* Return a proxy for the EJB's local home interface. This can be
* passed back to any client that wishes to access the EJB
* (e.g. in response to a call to EJBContext.getEJBLocalHome() )
* @return the proxy for this EJB's local home interface
*/
public EJBLocalHome getEJBLocalHome() {
EJBMethodInterceptor handler = new EJBMethodInterceptor(
this,
EJBInterfaceType.LOCALHOME,
container,
localHomeMap);
return (EJBLocalHome) localHomeFactory.create(handler);
}
private int[] createOperationsMap(CglibEJBProxyFactory factory,
InterfaceMethodSignature[] signatures) {
if (factory == null) return new int[0];
return EJBProxyHelper.getOperationMap(factory.getType(), signatures,
false);
}
private CglibEJBProxyFactory getFactory(int interfaceType, Class
interfaceClass) {
if (interfaceClass == null) {
return null;
}
Class baseClass;
if (isSessionBean) {
baseClass = sessionBaseClasses[interfaceType];
} else {
baseClass = entityBaseClasses[interfaceType];
}
return new CglibEJBProxyFactory(baseClass, interfaceClass);
}
private static void addLegacyMethods(Map legacyMethodMap, Class clazz,
InterfaceMethodSignature[] signatures) {
if (clazz == null) {
return;
}
for (int i = 0; i < signatures.length; i++) {
InterfaceMethodSignature signature = signatures[i];
Method method = signature.getMethod(clazz);
if (method != null) {
legacyMethodMap.put(method, new Integer(i));
}
}
}
private void locateContainer() {
ContainerIndex containerIndex = ContainerIndex.getInstance();
EJBContainer c = containerIndex.getContainer(containerId);
if (c == null) {
throw new IllegalStateException("Contianer not found: " +
containerId);
}
setContainer(c);
}
private Object readResolve() {
return new EJBProxyFactory(
containerId,
isSessionBean,
remoteInterface,
homeInterface,
localInterface,
localHomeInterface);
}
}
\ No newline at end of file
+/**
* Redistribution and use of this software and associated documentation
* ("Software"), with or without modification, are permitted provided
* that the following conditions are met:
*
* 1. Redistributions of source code must retain copyright
* statements and notices. Redistributions must also contain a
* copy of this document.
*
* 2. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. The name "OpenEJB" must not be used to endorse or promote
* products derived from this Software without prior written
* permission of The OpenEJB Group. For written permission,
* please contact [EMAIL PROTECTED]
*
* 4. Products derived from this Software may not be called "OpenEJB"
* nor may "OpenEJB" appear in their names without prior written
* permission of The OpenEJB Group. OpenEJB is a registered
* trademark of The OpenEJB Group.
*
* 5. Due credit should be given to the OpenEJB Project
* (http://openejb.org/).
*
* THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Copyright 2001 (C) The OpenEJB Group. All Rights Reserved.
*
* $Id$
*/
package org.openejb.proxy;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Collections;
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 org.openejb.ContainerIndex;
import org.openejb.EJBContainer;
import org.openejb.EJBInterfaceType;
import org.openejb.ContainerNotFoundException;
import org.openejb.dispatch.InterfaceMethodSignature;
public class EJBProxyFactory implements Serializable,
org.tranql.ejb.EJBProxyFactory {
private static final Class[] sessionBaseClasses =
new Class[]{SessionEJBObject.class, SessionEJBHome.class,
SessionEJBLocalObject.class, SessionEJBLocalHome.class};
private static final Class[] entityBaseClasses =
new Class[]{EntityEJBObject.class, EntityEJBHome.class,
EntityEJBLocalObject.class, EntityEJBLocalHome.class};
private final String containerId;
private final boolean isSessionBean;
private final Class remoteInterface;
private final Class homeInterface;
private final Class localInterface;
private final Class localHomeInterface;
private transient final CglibEJBProxyFactory remoteFactory;
private transient final CglibEJBProxyFactory homeFactory;
private transient final CglibEJBProxyFactory localFactory;
private transient final CglibEJBProxyFactory localHomeFactory;
private transient EJBContainer container;
private transient int[] remoteMap;
private transient int[] homeMap;
private transient int[] localMap;
private transient int[] localHomeMap;
private transient Map legacyMethodMap;
public EJBProxyFactory(EJBContainer container) {
this(container.getProxyInfo());
setContainer(container);
}
public EJBProxyFactory(ProxyInfo proxyInfo) {
this(
proxyInfo.getContainerID(),
proxyInfo.isSessionBean(),
proxyInfo.getRemoteInterface(),
proxyInfo.getHomeInterface(),
proxyInfo.getLocalInterface(),
proxyInfo.getLocalHomeInterface());
}
public EJBProxyFactory(
String containerId,
boolean sessionBean,
Class remoteInterface,
Class homeInterface,
Class localInterface,
Class localHomeInterface) {
this.containerId = containerId;
isSessionBean = sessionBean;
// JNB: these are temporarily disabled due to classloader issues during
deployment
// assert remoteInterface == null || (remoteInterface.isInterface() &&
EJBObject.class.isAssignableFrom(remoteInterface));
this.remoteInterface = remoteInterface;
// assert homeInterface == null || (homeInterface.isInterface() &&
EJBHome.class.isAssignableFrom(homeInterface));
this.homeInterface = homeInterface;
// assert localInterface == null || (localInterface.isInterface() &&
EJBLocalObject.class.isAssignableFrom(localInterface));
this.localInterface = localInterface;
// assert localHomeInterface == null ||
(localHomeInterface.isInterface() &&
EJBLocalHome.class.isAssignableFrom(localHomeInterface));
this.localHomeInterface = localHomeInterface;
this.remoteFactory = getFactory(EJBInterfaceType.REMOTE.getOrdinal(),
remoteInterface);
this.homeFactory = getFactory(EJBInterfaceType.HOME.getOrdinal(),
homeInterface);
this.localFactory = getFactory(EJBInterfaceType.LOCAL.getOrdinal(),
localInterface);
this.localHomeFactory =
getFactory(EJBInterfaceType.LOCALHOME.getOrdinal(), localHomeInterface);
}
public String getEJBName() {
return container.getEJBName();
}
EJBContainer getContainer() throws ContainerNotFoundException {
if (container == null) {
locateContainer();
}
return container;
}
private void setContainer(EJBContainer container) {
assert container != null: "container is null";
this.container = container;
ProxyInfo proxyInfo = container.getProxyInfo();
InterfaceMethodSignature[] signatures = container.getSignatures();
// build the legacy map
Map map = new HashMap();
addLegacyMethods(map, proxyInfo.getRemoteInterface(), signatures);
addLegacyMethods(map, proxyInfo.getHomeInterface(), signatures);
addLegacyMethods(map, proxyInfo.getLocalInterface(), signatures);
addLegacyMethods(map, proxyInfo.getLocalHomeInterface(), signatures);
legacyMethodMap = Collections.unmodifiableMap(map);
remoteMap = createOperationsMap(remoteFactory, signatures);
homeMap = createOperationsMap(homeFactory, signatures);
localMap = createOperationsMap(localFactory, signatures);
localHomeMap = createOperationsMap(localHomeFactory, signatures);
}
int[] getOperationMap(EJBInterfaceType type) throws
ContainerNotFoundException {
if (container == null) {
locateContainer();
}
if (type == EJBInterfaceType.REMOTE) {
return remoteMap;
} else if (type == EJBInterfaceType.HOME) {
return homeMap;
} else if (type == EJBInterfaceType.LOCAL) {
return localMap;
} else if (type == EJBInterfaceType.LOCALHOME) {
return localHomeMap;
} else {
throw new IllegalArgumentException("Unsupported interface type " +
type);
}
}
public int getMethodIndex(Method method) {
Integer index = (Integer) legacyMethodMap.get(method);
if (index == null) {
index = new Integer(-1);
}
return index.intValue();
}
public Class getLocalInterfaceClass() {
return localInterface;
}
public Class getRemoteInterfaceClass() {
return remoteInterface;
}
/**
* Return a proxy for the EJB's remote interface. This can be passed back
* to any client that wishes to access the EJB (e.g. in response to a
* call to SessionContext.getEJBObject() )
* @return the proxy for this EJB's home interface
*/
public EJBObject getEJBObject(Object primaryKey) {
EJBMethodInterceptor handler = new EJBMethodInterceptor(
this,
EJBInterfaceType.REMOTE,
container,
remoteMap,
primaryKey);
return (EJBObject) remoteFactory.create(handler);
}
/**
* Return a proxy for the EJB's home interface. This can be passed back
* to any client that wishes to access the EJB (e.g. in response to a
* call to EJBContext.getEJBHome() )
* @return the proxy for this EJB's home interface
*/
public EJBHome getEJBHome() {
EJBMethodInterceptor handler = new EJBMethodInterceptor(
this,
EJBInterfaceType.HOME,
container,
homeMap);
return (EJBHome) homeFactory.create(handler);
}
/**
* Return a proxy for the EJB's local interface. This can be passed back
* to any client that wishes to access the EJB (e.g. in response to a
* call to SessionContext.getEJBLocalObject() )
* @return the proxy for this EJB's local interface
*/
public EJBLocalObject getEJBLocalObject(Object primaryKey) {
EJBMethodInterceptor handler = new EJBMethodInterceptor(
this,
EJBInterfaceType.LOCAL,
container,
localMap,
primaryKey);
return (EJBLocalObject) localFactory.create(handler);
}
/**
* Return a proxy for the EJB's local home interface. This can be
* passed back to any client that wishes to access the EJB
* (e.g. in response to a call to EJBContext.getEJBLocalHome() )
* @return the proxy for this EJB's local home interface
*/
public EJBLocalHome getEJBLocalHome() {
EJBMethodInterceptor handler = new EJBMethodInterceptor(
this,
EJBInterfaceType.LOCALHOME,
container,
localHomeMap);
return (EJBLocalHome) localHomeFactory.create(handler);
}
private int[] createOperationsMap(CglibEJBProxyFactory factory,
InterfaceMethodSignature[] signatures) {
if (factory == null) return new int[0];
return EJBProxyHelper.getOperationMap(factory.getType(), signatures,
false);
}
private CglibEJBProxyFactory getFactory(int interfaceType, Class
interfaceClass) {
if (interfaceClass == null) {
return null;
}
Class baseClass;
if (isSessionBean) {
baseClass = sessionBaseClasses[interfaceType];
} else {
baseClass = entityBaseClasses[interfaceType];
}
return new CglibEJBProxyFactory(baseClass, interfaceClass);
}
private static void addLegacyMethods(Map legacyMethodMap, Class clazz,
InterfaceMethodSignature[] signatures) {
if (clazz == null) {
return;
}
for (int i = 0; i < signatures.length; i++) {
InterfaceMethodSignature signature = signatures[i];
Method method = signature.getMethod(clazz);
if (method != null) {
legacyMethodMap.put(method, new Integer(i));
}
}
}
private void locateContainer() throws ContainerNotFoundException {
ContainerIndex containerIndex = ContainerIndex.getInstance();
EJBContainer c = containerIndex.getContainer(containerId);
if (c == null) {
throw new IllegalStateException("Contianer not found: " +
containerId);
}
setContainer(c);
}
private Object readResolve() {
return new EJBProxyFactory(
containerId,
isSessionBean,
remoteInterface,
homeInterface,
localInterface,
localHomeInterface);
}
}
\ No newline at end of file
1.2 +11 -2
openejb/modules/core/src/java/org/openejb/proxy/SessionEJBHome.java
Index: SessionEJBHome.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/proxy/SessionEJBHome.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SessionEJBHome.java 13 Apr 2004 18:13:16 -0000 1.1
+++ SessionEJBHome.java 9 Feb 2005 02:07:56 -0000 1.2
@@ -45,11 +45,14 @@
package org.openejb.proxy;
import java.rmi.RemoteException;
+import java.rmi.NoSuchObjectException;
import javax.ejb.EJBObject;
import javax.ejb.Handle;
import javax.ejb.RemoveException;
+import org.openejb.ContainerNotFoundException;
+
/**
*
@@ -65,7 +68,13 @@
if (handle == null) {
throw new RemoveException("Handle is null");
}
- Class remoteInterface =
ejbHandler.getProxyInfo().getRemoteInterface();
+ ProxyInfo proxyInfo = null;
+ try {
+ proxyInfo = ejbHandler.getProxyInfo();
+ } catch (ContainerNotFoundException e) {
+ throw new NoSuchObjectException(e.getMessage());
+ }
+ Class remoteInterface = proxyInfo.getRemoteInterface();
if (!remoteInterface.isInstance(handle.getEJBObject())) {
throw new RemoteException("Handle does not hold a " +
remoteInterface.getName());
}