You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by da...@apache.org on 2007/05/29 22:45:54 UTC
svn commit: r542647 - in
/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core:
entity/EntityEjbObjectHandler.java stateful/StatefulEjbObjectHandler.java
Author: dain
Date: Tue May 29 13:45:53 2007
New Revision: 542647
URL: http://svn.apache.org/viewvc?view=rev&rev=542647
Log:
Fix isIdentical method of stateful handle
Modified:
incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityEjbObjectHandler.java
incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulEjbObjectHandler.java
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityEjbObjectHandler.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityEjbObjectHandler.java?view=diff&rev=542647&r1=542646&r2=542647
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityEjbObjectHandler.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/entity/EntityEjbObjectHandler.java Tue May 29 13:45:53 2007
@@ -75,7 +75,6 @@
Object invocationHandler = ProxyManager.getInvocationHandler(that);
if (invocationHandler instanceof EntityEjbObjectHandler) {
-
EntityEjbObjectHandler handler = (EntityEjbObjectHandler) invocationHandler;
/*
@@ -83,12 +82,9 @@
* container id. It uniquely identifies the entity bean that is proxied by the EntityEjbObjectHandler
* within the IntraVM.
*/
- if (this.getRegistryId().equals(handler.getRegistryId())) {
- return Boolean.TRUE;
- }
+ return this.getRegistryId().equals(handler.getRegistryId());
}
- return Boolean.FALSE;
-
+ return false;
}
protected Object remove(Class interfce, Method method, Object[] args, Object proxy) throws Throwable {
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulEjbObjectHandler.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulEjbObjectHandler.java?view=diff&rev=542647&r1=542646&r2=542647
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulEjbObjectHandler.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulEjbObjectHandler.java Tue May 29 13:45:53 2007
@@ -18,6 +18,7 @@
import org.apache.openejb.InterfaceType;
import org.apache.openejb.DeploymentInfo;
+import org.apache.openejb.Container;
import org.apache.openejb.core.ivm.EjbObjectProxyHandler;
import org.apache.openejb.util.proxy.ProxyManager;
@@ -32,7 +33,7 @@
}
public Object getRegistryId() {
- return primaryKey;
+ return new RegistryId(container, deploymentID, primaryKey);
}
protected Object getPrimaryKey(Method method, Object[] args, Object proxy) throws Throwable {
@@ -41,8 +42,26 @@
protected Object isIdentical(Method method, Object[] args, Object proxy) throws Throwable {
checkAuthorization(method);
- EjbObjectProxyHandler handler = (EjbObjectProxyHandler) ProxyManager.getInvocationHandler(proxy);
- return new Boolean(primaryKey.equals(handler.primaryKey));
+
+ if (args.length != 1) {
+ throw new IllegalArgumentException("Expected one argument to isIdentical, but received " + args.length);
+ }
+
+ Object that = args[0];
+ Object invocationHandler = ProxyManager.getInvocationHandler(that);
+
+ if (invocationHandler instanceof StatefulEjbObjectHandler) {
+ StatefulEjbObjectHandler handler = (StatefulEjbObjectHandler) invocationHandler;
+
+ /*
+ * The registry id is a compound key composed of the bean's primary key, deployment id, and
+ * container id. It uniquely identifies the entity bean that is proxied by the EntityEjbObjectHandler
+ * within the IntraVM.
+ */
+ return this.getRegistryId().equals(handler.getRegistryId());
+ }
+
+ return false;
}
protected Object remove(Class interfce, Method method, Object[] args, Object proxy) throws Throwable {
@@ -53,4 +72,42 @@
return value;
}
+ private static class RegistryId {
+ private final Object containerId;
+ private final Object deploymentId;
+ private final Object primaryKey;
+
+ public RegistryId(Container container, Object deploymentId, Object primaryKey) {
+ if (container == null) throw new NullPointerException("container is null");
+ if (deploymentId == null) throw new NullPointerException("deploymentId is null");
+
+ this.containerId = container.getContainerID();
+ this.deploymentId = deploymentId;
+ this.primaryKey = primaryKey;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ RegistryId that = (RegistryId) o;
+
+ return containerId.equals(that.containerId) &&
+ deploymentId.equals(that.deploymentId) &&
+ !(primaryKey != null ? !primaryKey.equals(that.primaryKey) : that.primaryKey != null);
+ }
+
+ public int hashCode() {
+ int result;
+ result = containerId.hashCode();
+ result = 31 * result + deploymentId.hashCode();
+ result = 31 * result + (primaryKey != null ? primaryKey.hashCode() : 0);
+ return result;
+ }
+
+
+ public String toString() {
+ return "[" + containerId + ", " + deploymentId + ", " + primaryKey + "]";
+ }
+ }
}