gdamour 2005/01/07 01:36:33
Modified: modules/core/src/java/org/openejb/entity/cmp CMPFinder.java
CollectionValuedFinder.java SingleValuedFinder.java
EnumerationValuedFinder.java
Log:
It is no more required to add found entities to the InTxCache. TranQL
adds them itself if they are not already in the InTxCache.
Revision Changes Path
1.11 +2 -45
openejb/modules/core/src/java/org/openejb/entity/cmp/CMPFinder.java
Index: CMPFinder.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/entity/cmp/CMPFinder.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- CMPFinder.java 15 Oct 2004 14:56:47 -0000 1.10
+++ CMPFinder.java 7 Jan 2005 06:36:32 -0000 1.11
@@ -51,33 +51,16 @@
import org.openejb.EJBInvocation;
import org.openejb.dispatch.VirtualOperation;
-import org.tranql.cache.AlreadyAssociatedException;
-import org.tranql.cache.CacheRow;
-import org.tranql.cache.CacheTable;
-import org.tranql.cache.InTxCache;
-import org.tranql.identity.GlobalIdentity;
-import org.tranql.identity.IdentityDefiner;
-import org.tranql.identity.IdentityTransform;
-import org.tranql.identity.IdentityTransformException;
import org.tranql.query.QueryCommandView;
/**
* @version $Revision$ $Date$
*/
public abstract class CMPFinder implements VirtualOperation, Serializable {
- private final CacheTable cacheTable;
- private final IdentityDefiner identityDefiner;
- private final IdentityTransform localProxyTransform;
- private final IdentityTransform remoteProxyTransform;
private final QueryCommandView localQueryView;
private final QueryCommandView remoteQueryView;
- public CMPFinder(CacheTable cacheTable, IdentityDefiner identityDefiner,
IdentityTransform localProxyTransform,
- IdentityTransform remoteProxyTransform, QueryCommandView
localQueryView, QueryCommandView remoteQueryView) {
- this.cacheTable = cacheTable;
- this.identityDefiner = identityDefiner;
- this.localProxyTransform = localProxyTransform;
- this.remoteProxyTransform = remoteProxyTransform;
+ public CMPFinder(QueryCommandView localQueryView, QueryCommandView
remoteQueryView) {
this.localQueryView = localQueryView;
this.remoteQueryView = remoteQueryView;
}
@@ -86,30 +69,4 @@
return invocation.getType().isLocal() ? localQueryView :
remoteQueryView;
}
- protected void checkInTxCache(EJBInvocation invocation, Object opaque) {
- InTxCache cache = invocation.getTransactionContext().getInTxCache();
-
- GlobalIdentity id;
- try {
- if (invocation.getType().isLocal()) {
- id = localProxyTransform.getGlobalIdentity(opaque);
- } else {
- id = remoteProxyTransform.getGlobalIdentity(opaque);
- }
- } catch (IdentityTransformException e1) {
- throw new AssertionError("Not a domain object.");
- }
-
- if ( null != cache.get(id) ) {
- return;
- }
-
- CacheRow row = id.getTable().emptyRow(id);
- identityDefiner.injectIdentity(row);
- try {
- cache.associate(row);
- } catch (AlreadyAssociatedException e) {
- throw new AssertionError("Concurrent access to InTxCache.");
- }
- }
}
1.5 +5 -16
openejb/modules/core/src/java/org/openejb/entity/cmp/CollectionValuedFinder.java
Index: CollectionValuedFinder.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/entity/cmp/CollectionValuedFinder.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CollectionValuedFinder.java 15 Oct 2004 14:56:47 -0000 1.4
+++ CollectionValuedFinder.java 7 Jan 2005 06:36:32 -0000 1.5
@@ -48,18 +48,14 @@
package org.openejb.entity.cmp;
import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
+import java.util.Collection;
import javax.ejb.FinderException;
import org.apache.geronimo.core.service.InvocationResult;
import org.apache.geronimo.core.service.SimpleInvocationResult;
import org.openejb.EJBInvocation;
-import org.tranql.cache.CacheTable;
import org.tranql.field.Row;
-import org.tranql.identity.IdentityDefiner;
-import org.tranql.identity.IdentityTransform;
import org.tranql.ql.QueryException;
import org.tranql.query.CollectionResultHandler;
import org.tranql.query.QueryCommandView;
@@ -71,23 +67,16 @@
*/
public class CollectionValuedFinder extends CMPFinder {
- public CollectionValuedFinder(CacheTable cacheTable, IdentityDefiner
identityDefiner,
- IdentityTransform localProxyTransform, IdentityTransform
remoteProxyTransform,
- QueryCommandView localQueryView, QueryCommandView
remoteQueryView) {
- super(cacheTable, identityDefiner, localProxyTransform,
remoteProxyTransform, localQueryView, remoteQueryView);
+ public CollectionValuedFinder(QueryCommandView localQueryView,
QueryCommandView remoteQueryView) {
+ super(localQueryView, remoteQueryView);
}
public InvocationResult execute(EJBInvocation invocation) throws
Throwable {
try {
QueryCommandView commandView = getCommand(invocation);
- List results = new ArrayList();
+ Collection results = new ArrayList();
CollectionResultHandler handler = new
CollectionResultHandler(commandView.getView()[0]);
commandView.getQueryCommand().execute(handler, new
Row(invocation.getArguments()), results);
-
- for (Iterator iter = results.iterator(); iter.hasNext();) {
- checkInTxCache(invocation, iter.next());
- }
-
return new SimpleInvocationResult(true, results);
} catch (QueryException e) {
return new SimpleInvocationResult(false, new
FinderException(e.getMessage()).initCause(e));
1.5 +6 -17
openejb/modules/core/src/java/org/openejb/entity/cmp/SingleValuedFinder.java
Index: SingleValuedFinder.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/entity/cmp/SingleValuedFinder.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SingleValuedFinder.java 15 Oct 2004 14:56:47 -0000 1.4
+++ SingleValuedFinder.java 7 Jan 2005 06:36:32 -0000 1.5
@@ -53,13 +53,9 @@
import org.apache.geronimo.core.service.InvocationResult;
import org.apache.geronimo.core.service.SimpleInvocationResult;
import org.openejb.EJBInvocation;
-import org.tranql.cache.CacheTable;
-import org.tranql.field.FieldAccessor;
import org.tranql.field.FieldTransform;
import org.tranql.field.FieldTransformException;
import org.tranql.field.Row;
-import org.tranql.identity.IdentityDefiner;
-import org.tranql.identity.IdentityTransform;
import org.tranql.ql.QueryException;
import org.tranql.query.QueryCommandView;
import org.tranql.query.ResultHandler;
@@ -72,17 +68,14 @@
public class SingleValuedFinder extends CMPFinder {
private static final Object NODATA = new Object();
- public SingleValuedFinder(CacheTable cacheTable, IdentityDefiner
identityDefiner,
- IdentityTransform localProxyTransform, IdentityTransform
remoteProxyTransform,
- QueryCommandView localQueryView, QueryCommandView
remoteQueryView) {
- super(cacheTable, identityDefiner, localProxyTransform,
remoteProxyTransform, localQueryView, remoteQueryView);
+ public SingleValuedFinder(QueryCommandView localQueryView,
QueryCommandView remoteQueryView) {
+ super(localQueryView, remoteQueryView);
}
public InvocationResult execute(EJBInvocation invocation) throws
Throwable {
try {
QueryCommandView commandView = getCommand(invocation);
- FieldAccessor accessor = new FieldAccessor(0, null);
- SingleValuedResultHandler handler = new
SingleValuedResultHandler(invocation, commandView.getView()[0]);
+ SingleValuedResultHandler handler = new
SingleValuedResultHandler(commandView.getView()[0]);
Object o = commandView.getQueryCommand().execute(handler, new
Row(invocation.getArguments()), NODATA);
return o == NODATA ? new SimpleInvocationResult(false, new
ObjectNotFoundException()) : (InvocationResult) o;
} catch (QueryException e) {
@@ -91,10 +84,8 @@
}
private class SingleValuedResultHandler implements ResultHandler {
- private final EJBInvocation invocation;
private final FieldTransform accessor;
- public SingleValuedResultHandler(EJBInvocation invocation,
FieldTransform accessor) {
- this.invocation = invocation;
+ public SingleValuedResultHandler(FieldTransform accessor) {
this.accessor = accessor;
}
@@ -102,14 +93,12 @@
if (arg == NODATA) {
try {
Object opaque = accessor.get(row);
- checkInTxCache(invocation, opaque);
return new SimpleInvocationResult(true, opaque);
} catch (FieldTransformException e) {
throw new QueryException(e);
}
- } else {
- return new SimpleInvocationResult(false, new
FinderException("More than one row returned from single valued finder"));
}
+ return new SimpleInvocationResult(false, new
FinderException("More than one row returned from single valued finder"));
}
}
}
1.5 +3 -14
openejb/modules/core/src/java/org/openejb/entity/cmp/EnumerationValuedFinder.java
Index: EnumerationValuedFinder.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/entity/cmp/EnumerationValuedFinder.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- EnumerationValuedFinder.java 15 Oct 2004 14:56:47 -0000 1.4
+++ EnumerationValuedFinder.java 7 Jan 2005 06:36:32 -0000 1.5
@@ -49,7 +49,6 @@
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import javax.ejb.FinderException;
@@ -57,10 +56,7 @@
import org.apache.geronimo.core.service.InvocationResult;
import org.apache.geronimo.core.service.SimpleInvocationResult;
import org.openejb.EJBInvocation;
-import org.tranql.cache.CacheTable;
import org.tranql.field.Row;
-import org.tranql.identity.IdentityDefiner;
-import org.tranql.identity.IdentityTransform;
import org.tranql.ql.QueryException;
import org.tranql.query.CollectionResultHandler;
import org.tranql.query.QueryCommandView;
@@ -72,10 +68,8 @@
*/
public class EnumerationValuedFinder extends CMPFinder {
- public EnumerationValuedFinder(CacheTable cacheTable, IdentityDefiner
identityDefiner,
- IdentityTransform localProxyTransform, IdentityTransform
remoteProxyTransform,
- QueryCommandView localQueryView, QueryCommandView
remoteQueryView) {
- super(cacheTable, identityDefiner, localProxyTransform,
remoteProxyTransform, localQueryView, remoteQueryView);
+ public EnumerationValuedFinder(QueryCommandView localQueryView,
QueryCommandView remoteQueryView) {
+ super(localQueryView, remoteQueryView);
}
public InvocationResult execute(EJBInvocation invocation) throws
Throwable {
@@ -84,11 +78,6 @@
List results = new ArrayList();
CollectionResultHandler handler = new
CollectionResultHandler(commandView.getView()[0]);
commandView.getQueryCommand().execute(handler, new
Row(invocation.getArguments()), results);
-
- for (Iterator iter = results.iterator(); iter.hasNext();) {
- checkInTxCache(invocation, iter.next());
- }
-
return new SimpleInvocationResult(true,
Collections.enumeration(results));
} catch (QueryException e) {
return new SimpleInvocationResult(false, new
FinderException(e.getMessage()).initCause(e));