[jboss-cvs] JBossAS SVN: r73457 - projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat May 17 08:42:54 EDT 2008
Author: bstansberry at jboss.com
Date: 2008-05-17 08:42:54 -0400 (Sat, 17 May 2008)
New Revision: 73457
Modified:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/ProxiedStatefulBeanContext.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContext.java
Log:
[EJBTHREE-1368] Override equals/hashcode
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/ProxiedStatefulBeanContext.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/ProxiedStatefulBeanContext.java 2008-05-17 12:41:54 UTC (rev 73456)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/ProxiedStatefulBeanContext.java 2008-05-17 12:42:54 UTC (rev 73457)
@@ -30,6 +30,7 @@
import java.util.concurrent.locks.ReentrantLock;
import javax.ejb.EJBContext;
+import javax.ejb.NoSuchEJBException;
import javax.persistence.EntityManager;
import org.jboss.aop.metadata.SimpleMetaData;
@@ -61,6 +62,9 @@
{
this.delegate = delegate;
oid = delegate.getId();
+
+ assert oid != null : "delegate.getId() is null";
+
containerId = delegate.getContainer().getObjectName().getCanonicalName();
parentRef = new StatefulBeanContextReference(delegate.getContainedIn());
}
@@ -274,7 +278,19 @@
@Override
public void remove()
{
- getDelegate().remove();
+ StatefulBeanContext del = null;
+ try
+ {
+ del = getDelegate();
+ }
+ catch (NoSuchEJBException gone)
+ {
+ // Assume this is due to EJBTHREE-1367/8 where an invalid
+ // proxy is left sitting around in InfinitePool
+ return;
+ }
+
+ del.remove();
}
// @Override
@@ -388,6 +404,9 @@
public boolean getCanRemoveFromCache()
{
return getDelegate().getCanRemoveFromCache();
+ // Always return true if we've had remove called -- a proxy
+ // that's had remove called is useless
+// return isRemoved();
}
@Override
@@ -441,7 +460,28 @@
{
getDelegate().initialiseInterceptorInstances();
}
-
-
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+
+ if (obj instanceof ProxiedStatefulBeanContext)
+ {
+ ProxiedStatefulBeanContext other = (ProxiedStatefulBeanContext) obj;
+ return (containerId.equals(other.containerId) && oid.equals(other.oid));
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = 11;
+ result = 29 * result + containerId.hashCode();
+ result = 29 * result + oid.hashCode();
+ return result;
+ }
+
}
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContext.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContext.java 2008-05-17 12:41:54 UTC (rev 73456)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContext.java 2008-05-17 12:42:54 UTC (rev 73457)
@@ -980,29 +980,29 @@
return this.getId();
}
-// @Override
-// public boolean equals(Object obj)
-// {
-// if (this == obj)
-// return true;
-//
-// // Don't use instanceof check here as subclasses w/ same id are not equal
-// if (obj != null && obj.getClass() == getClass())
-// {
-// StatefulBeanContext other = (StatefulBeanContext) obj;
-// return (containerClusterUid.equals(other.containerClusterUid) && id.equals(other.id));
-// }
-// return false;
-// }
-//
-// @Override
-// public int hashCode()
-// {
-// int result = 11;
-// result = 29 * result + containerClusterUid.hashCode();
-// result = 29 * result + id.hashCode();
-// return result;
-// }
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+
+ // Don't use instanceof check here as subclasses w/ same id are not equal
+ if (obj != null && obj.getClass() == getClass())
+ {
+ StatefulBeanContext other = (StatefulBeanContext) obj;
+ return (containerClusterUid.equals(other.containerClusterUid) && id.equals(other.id));
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = 11;
+ result = 29 * result + containerClusterUid.hashCode();
+ result = 29 * result + id.hashCode();
+ return result;
+ }
private static class XPCCloseSynchronization implements Synchronization
{
More information about the jboss-cvs-commits
mailing list