gdamour 2005/06/22 07:27:17
Modified: modules/core/src/java/org/openejb/entity/cmp CMPFinder.java
CollectionValuedFinder.java
CollectionValuedSelect.java
EnumerationValuedFinder.java SetValuedFinder.java
SetValuedSelect.java SingleValuedFinder.java
SingleValuedSelect.java
Log:
GERONIMO-665, checkpoint.
Prefetching works for finders, selects and CMR.
For CMR, it works as expected only if the entity is already defined by the
transactional cache.
Proper prefetching capabilities for CMR and CMP still need to be implemented.
Revision Changes Path
1.13 +11 -11
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.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- CMPFinder.java 2 Mar 2005 11:43:13 -0000 1.12
+++ CMPFinder.java 22 Jun 2005 11:27:17 -0000 1.13
@@ -53,31 +53,31 @@
import org.openejb.dispatch.VirtualOperation;
import org.tranql.cache.InTxCache;
import org.tranql.ql.QueryException;
-import org.tranql.query.QueryCommandView;
+import org.tranql.query.QueryCommand;
/**
* @version $Revision$ $Date$
*/
public abstract class CMPFinder implements VirtualOperation, Serializable {
- private final QueryCommandView localQueryView;
- private final QueryCommandView remoteQueryView;
+ private final QueryCommand localCommand;
+ private final QueryCommand remoteCommand;
private final boolean flushCache;
- public CMPFinder(QueryCommandView localQueryView, QueryCommandView
remoteQueryView, boolean flushCache) {
- this.localQueryView = localQueryView;
- this.remoteQueryView = remoteQueryView;
+ public CMPFinder(QueryCommand localCommand, QueryCommand remoteCommand,
boolean flushCache) {
+ this.localCommand = localCommand;
+ this.remoteCommand = remoteCommand;
this.flushCache = flushCache;
}
- protected QueryCommandView getCommand(EJBInvocation invocation) {
- return invocation.getType().isLocal() ? localQueryView :
remoteQueryView;
+ protected QueryCommand getCommand(EJBInvocation invocation) {
+ return invocation.getType().isLocal() ? localCommand : remoteCommand;
}
- protected void flushCache(EJBInvocation invocation) throws
QueryException {
+ protected InTxCache flushCache(EJBInvocation invocation) throws
QueryException {
InTxCache cache = invocation.getTransactionContext().getInTxCache();
if (flushCache) {
cache.flush();
}
+ return cache;
}
-
}
1.8 +19 -9
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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- CollectionValuedFinder.java 21 Jun 2005 21:16:58 -0000 1.7
+++ CollectionValuedFinder.java 22 Jun 2005 11:27:17 -0000 1.8
@@ -53,12 +53,14 @@
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.InTxCache;
+import org.tranql.field.FieldTransform;
import org.tranql.field.Row;
import org.tranql.ql.QueryException;
import org.tranql.query.CollectionResultHandler;
-import org.tranql.query.QueryCommandView;
+import org.tranql.query.QueryCommand;
+import org.tranql.sql.prefetch.PrefetchGroupHandler;
/**
*
@@ -67,18 +69,26 @@
*/
public class CollectionValuedFinder extends CMPFinder {
- public CollectionValuedFinder(QueryCommandView localQueryView,
QueryCommandView remoteQueryView, boolean flushCache) {
- super(localQueryView, remoteQueryView, flushCache);
+ public CollectionValuedFinder(QueryCommand localCommand, QueryCommand
remoteCommand, boolean flushCache) {
+ super(localCommand, remoteCommand, flushCache);
}
public InvocationResult execute(EJBInvocation invocation) throws
Throwable {
- flushCache(invocation);
+ InTxCache cache = flushCache(invocation);
try {
- QueryCommandView commandView = getCommand(invocation);
+ QueryCommand command = getCommand(invocation);
Collection results = new ArrayList();
- CollectionResultHandler handler = new
CollectionResultHandler(commandView.getView()[0]);
- commandView.getQueryCommand().execute(handler, new
Row(invocation.getArguments()), results);
+ FieldTransform resultAccessor =
command.getQuery().getResultAccessors()[0];
+ CollectionResultHandler handler = new
CollectionResultHandler(resultAccessor);
+ Row arguments = new Row(invocation.getArguments());
+ PrefetchGroupHandler groupHandler =
command.getQuery().getPrefetchGroupHandler();
+ if (null != groupHandler) {
+ groupHandler = new PrefetchGroupHandler(groupHandler,
handler);
+ groupHandler.execute(cache, command, arguments, results);
+ } else {
+ command.execute(handler, arguments, results);
+ }
return invocation.createResult(results);
} catch (QueryException e) {
return invocation.createExceptionResult((Exception)new
FinderException(e.getMessage()).initCause(e));
1.5 +25 -8
openejb/modules/core/src/java/org/openejb/entity/cmp/CollectionValuedSelect.java
Index: CollectionValuedSelect.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/entity/cmp/CollectionValuedSelect.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CollectionValuedSelect.java 2 Mar 2005 11:43:14 -0000 1.4
+++ CollectionValuedSelect.java 22 Jun 2005 11:27:17 -0000 1.5
@@ -52,10 +52,15 @@
import javax.ejb.FinderException;
+import org.tranql.cache.InTxCache;
+import org.tranql.sql.prefetch.PrefetchGroupHandler;
+import org.tranql.field.FieldTransform;
import org.tranql.field.Row;
+import org.tranql.ql.Query;
import org.tranql.ql.QueryException;
import org.tranql.query.CollectionResultHandler;
-import org.tranql.query.QueryCommandView;
+import org.tranql.query.QueryCommand;
+import org.tranql.query.ResultHandler;
/**
@@ -64,23 +69,35 @@
* @version $Revision$ $Date$
*/
public class CollectionValuedSelect implements InstanceOperation {
- private final QueryCommandView commandView;
+ private final QueryCommand command;
+ private final FieldTransform resultAccessor;
+ private final PrefetchGroupHandler groupHandler;
private final boolean flushCache;
- public CollectionValuedSelect(QueryCommandView commandView, boolean
flushCache) {
- this.commandView = commandView;
+ public CollectionValuedSelect(QueryCommand command, boolean flushCache) {
+ this.command = command;
this.flushCache = flushCache;
+
+ Query query = command.getQuery();
+ resultAccessor = query.getResultAccessors()[0];
+ groupHandler = query.getPrefetchGroupHandler();
}
public Object invokeInstance(CMPInstanceContext ctx, Object[] args)
throws Exception {
+ InTxCache cache = ctx.getTransactionContext().getInTxCache();
if (flushCache) {
- ctx.getTransactionContext().getInTxCache().flush();
+ cache.flush();
}
Collection results = new ArrayList();
try {
- CollectionResultHandler handler = new
CollectionResultHandler(commandView.getView()[0]);
- commandView.getQueryCommand().execute(handler, new Row(args),
results);
+ ResultHandler handler = new
CollectionResultHandler(resultAccessor);
+ if (null != groupHandler) {
+ PrefetchGroupHandler newHandler = new
PrefetchGroupHandler(groupHandler, handler);
+ newHandler.execute(cache, command, new Row(args), results);
+ } else {
+ command.execute(handler, new Row(args), results);
+ }
} catch (QueryException e) {
throw (FinderException) new
FinderException(e.getMessage()).initCause(e);
}
1.8 +19 -9
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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- EnumerationValuedFinder.java 21 Jun 2005 21:16:58 -0000 1.7
+++ EnumerationValuedFinder.java 22 Jun 2005 11:27:17 -0000 1.8
@@ -54,12 +54,14 @@
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.InTxCache;
+import org.tranql.field.FieldTransform;
import org.tranql.field.Row;
import org.tranql.ql.QueryException;
import org.tranql.query.CollectionResultHandler;
-import org.tranql.query.QueryCommandView;
+import org.tranql.query.QueryCommand;
+import org.tranql.sql.prefetch.PrefetchGroupHandler;
/**
*
@@ -68,18 +70,26 @@
*/
public class EnumerationValuedFinder extends CMPFinder {
- public EnumerationValuedFinder(QueryCommandView localQueryView,
QueryCommandView remoteQueryView, boolean flushCache) {
- super(localQueryView, remoteQueryView, flushCache);
+ public EnumerationValuedFinder(QueryCommand localCommand, QueryCommand
remoteCommand, boolean flushCache) {
+ super(localCommand, remoteCommand, flushCache);
}
public InvocationResult execute(EJBInvocation invocation) throws
Throwable {
- flushCache(invocation);
+ InTxCache cache = flushCache(invocation);
try {
- QueryCommandView commandView = getCommand(invocation);
+ QueryCommand command = getCommand(invocation);
List results = new ArrayList();
- CollectionResultHandler handler = new
CollectionResultHandler(commandView.getView()[0]);
- commandView.getQueryCommand().execute(handler, new
Row(invocation.getArguments()), results);
+ FieldTransform resultAccessor =
command.getQuery().getResultAccessors()[0];
+ CollectionResultHandler handler = new
CollectionResultHandler(resultAccessor);
+ Row arguments = new Row(invocation.getArguments());
+ PrefetchGroupHandler groupHandler =
command.getQuery().getPrefetchGroupHandler();
+ if (null != groupHandler) {
+ groupHandler = new PrefetchGroupHandler(groupHandler,
handler);
+ groupHandler.execute(cache, command, arguments, results);
+ } else {
+ command.execute(handler, arguments, results);
+ }
return invocation.createResult(Collections.enumeration(results));
} catch (QueryException e) {
return invocation.createExceptionResult((Exception)new
FinderException(e.getMessage()).initCause(e));
1.4 +19 -9
openejb/modules/core/src/java/org/openejb/entity/cmp/SetValuedFinder.java
Index: SetValuedFinder.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/entity/cmp/SetValuedFinder.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SetValuedFinder.java 21 Jun 2005 21:16:58 -0000 1.3
+++ SetValuedFinder.java 22 Jun 2005 11:27:17 -0000 1.4
@@ -53,12 +53,14 @@
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.InTxCache;
+import org.tranql.field.FieldTransform;
import org.tranql.field.Row;
import org.tranql.ql.QueryException;
import org.tranql.query.CollectionResultHandler;
-import org.tranql.query.QueryCommandView;
+import org.tranql.query.QueryCommand;
+import org.tranql.sql.prefetch.PrefetchGroupHandler;
/**
*
@@ -67,18 +69,26 @@
*/
public class SetValuedFinder extends CMPFinder {
- public SetValuedFinder(QueryCommandView localQueryView, QueryCommandView
remoteQueryView, boolean flushCache) {
- super(localQueryView, remoteQueryView, flushCache);
+ public SetValuedFinder(QueryCommand localCommand, QueryCommand
remoteCommand, boolean flushCache) {
+ super(localCommand, remoteCommand, flushCache);
}
public InvocationResult execute(EJBInvocation invocation) throws
Throwable {
- flushCache(invocation);
+ InTxCache cache = flushCache(invocation);
try {
- QueryCommandView commandView = getCommand(invocation);
+ QueryCommand command = getCommand(invocation);
Set results = new HashSet();
- CollectionResultHandler handler = new
CollectionResultHandler(commandView.getView()[0]);
- commandView.getQueryCommand().execute(handler, new
Row(invocation.getArguments()), results);
+ FieldTransform resultAccessor =
command.getQuery().getResultAccessors()[0];
+ CollectionResultHandler handler = new
CollectionResultHandler(resultAccessor);
+ Row arguments = new Row(invocation.getArguments());
+ PrefetchGroupHandler groupHandler =
command.getQuery().getPrefetchGroupHandler();
+ if (null != groupHandler) {
+ groupHandler = new PrefetchGroupHandler(groupHandler,
handler);
+ groupHandler.execute(cache, command, arguments, results);
+ } else {
+ command.execute(handler, arguments, results);
+ }
return invocation.createResult(results);
} catch (QueryException e) {
return invocation.createExceptionResult((Exception)new
FinderException(e.getMessage()).initCause(e));
1.5 +25 -8
openejb/modules/core/src/java/org/openejb/entity/cmp/SetValuedSelect.java
Index: SetValuedSelect.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/entity/cmp/SetValuedSelect.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SetValuedSelect.java 2 Mar 2005 11:43:14 -0000 1.4
+++ SetValuedSelect.java 22 Jun 2005 11:27:17 -0000 1.5
@@ -52,10 +52,15 @@
import javax.ejb.FinderException;
+import org.tranql.cache.InTxCache;
+import org.tranql.sql.prefetch.PrefetchGroupHandler;
+import org.tranql.field.FieldTransform;
import org.tranql.field.Row;
+import org.tranql.ql.Query;
import org.tranql.ql.QueryException;
import org.tranql.query.CollectionResultHandler;
-import org.tranql.query.QueryCommandView;
+import org.tranql.query.QueryCommand;
+import org.tranql.query.ResultHandler;
/**
*
@@ -63,23 +68,35 @@
* @version $Revision$ $Date$
*/
public class SetValuedSelect implements InstanceOperation {
- private final QueryCommandView commandView;
+ private final QueryCommand command;
+ private final FieldTransform resultAccessor;
+ private final PrefetchGroupHandler groupHandler;
private final boolean flushCache;
- public SetValuedSelect(QueryCommandView commandView, boolean flushCache)
{
- this.commandView = commandView;
+ public SetValuedSelect(QueryCommand command, boolean flushCache) {
+ this.command = command;
this.flushCache = flushCache;
+
+ Query query = command.getQuery();
+ resultAccessor = query.getResultAccessors()[0];
+ groupHandler = query.getPrefetchGroupHandler();
}
public Object invokeInstance(CMPInstanceContext ctx, Object[] args)
throws Exception {
+ InTxCache cache = ctx.getTransactionContext().getInTxCache();
if (flushCache) {
- ctx.getTransactionContext().getInTxCache().flush();
+ cache.flush();
}
Set results = new HashSet();
try {
- CollectionResultHandler handler = new
CollectionResultHandler(commandView.getView()[0]);
- commandView.getQueryCommand().execute(handler, new Row(args),
results);
+ ResultHandler handler = new
CollectionResultHandler(resultAccessor);
+ if (null != groupHandler) {
+ PrefetchGroupHandler newHandler = new
PrefetchGroupHandler(groupHandler, handler);
+ newHandler.execute(cache, command, new Row(args), results);
+ } else {
+ command.execute(handler, new Row(args), results);
+ }
} catch (QueryException e) {
throw (FinderException) new
FinderException(e.getMessage()).initCause(e);
}
1.8 +19 -9
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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SingleValuedFinder.java 21 Jun 2005 21:16:58 -0000 1.7
+++ SingleValuedFinder.java 22 Jun 2005 11:27:17 -0000 1.8
@@ -51,14 +51,15 @@
import javax.ejb.ObjectNotFoundException;
import org.apache.geronimo.core.service.InvocationResult;
-import org.apache.geronimo.core.service.SimpleInvocationResult;
import org.openejb.EJBInvocation;
+import org.tranql.cache.InTxCache;
import org.tranql.field.FieldTransform;
import org.tranql.field.FieldTransformException;
import org.tranql.field.Row;
import org.tranql.ql.QueryException;
-import org.tranql.query.QueryCommandView;
+import org.tranql.query.QueryCommand;
import org.tranql.query.ResultHandler;
+import org.tranql.sql.prefetch.PrefetchGroupHandler;
/**
*
@@ -68,17 +69,26 @@
public class SingleValuedFinder extends CMPFinder {
private static final Object NODATA = new Object();
- public SingleValuedFinder(QueryCommandView localQueryView,
QueryCommandView remoteQueryView, boolean flushCache) {
- super(localQueryView, remoteQueryView, flushCache);
+ public SingleValuedFinder(QueryCommand localCommand, QueryCommand
remoteCommand, boolean flushCache) {
+ super(localCommand, remoteCommand, flushCache);
}
public InvocationResult execute(EJBInvocation invocation) throws
Throwable {
- flushCache(invocation);
+ InTxCache cache = flushCache(invocation);
try {
- QueryCommandView commandView = getCommand(invocation);
- SingleValuedResultHandler handler = new
SingleValuedResultHandler(commandView.getView()[0], invocation);
- Object o = commandView.getQueryCommand().execute(handler, new
Row(invocation.getArguments()), NODATA);
+ QueryCommand command = getCommand(invocation);
+ FieldTransform resultAccessor =
command.getQuery().getResultAccessors()[0];
+ SingleValuedResultHandler handler =new
SingleValuedResultHandler(resultAccessor, invocation);
+ Row arguments = new Row(invocation.getArguments());
+ PrefetchGroupHandler groupHandler =
command.getQuery().getPrefetchGroupHandler();
+ Object o;
+ if (null != groupHandler) {
+ groupHandler = new PrefetchGroupHandler(groupHandler,
handler);
+ o = groupHandler.execute(cache, command, arguments, NODATA);
+ } else {
+ o = command.execute(handler, arguments, NODATA);
+ }
return o == NODATA ?
invocation.createExceptionResult((Exception)new ObjectNotFoundException()) :
(InvocationResult) o;
} catch (QueryException e) {
return invocation.createExceptionResult((Exception)new
FinderException(e.getMessage()).initCause(e));
1.5 +22 -9
openejb/modules/core/src/java/org/openejb/entity/cmp/SingleValuedSelect.java
Index: SingleValuedSelect.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/entity/cmp/SingleValuedSelect.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SingleValuedSelect.java 2 Mar 2005 11:43:14 -0000 1.4
+++ SingleValuedSelect.java 22 Jun 2005 11:27:17 -0000 1.5
@@ -50,13 +50,14 @@
import javax.ejb.FinderException;
import javax.ejb.ObjectNotFoundException;
-import org.openejb.EJBInvocation;
import org.tranql.cache.InTxCache;
+import org.tranql.sql.prefetch.PrefetchGroupHandler;
import org.tranql.field.FieldTransform;
import org.tranql.field.FieldTransformException;
import org.tranql.field.Row;
+import org.tranql.ql.Query;
import org.tranql.ql.QueryException;
-import org.tranql.query.QueryCommandView;
+import org.tranql.query.QueryCommand;
import org.tranql.query.ResultHandler;
/**
@@ -67,23 +68,35 @@
public class SingleValuedSelect implements InstanceOperation {
private static final Object NODATA = new Object();
- private final QueryCommandView commandView;
+ private final QueryCommand command;
+ private final FieldTransform resultAccessor;
+ private final PrefetchGroupHandler groupHandler;
private final boolean flushCache;
- public SingleValuedSelect(QueryCommandView commandView, boolean
flushCache) {
- this.commandView = commandView;
+ public SingleValuedSelect(QueryCommand command, boolean flushCache) {
+ this.command = command;
this.flushCache = flushCache;
+
+ Query query = command.getQuery();
+ resultAccessor = query.getResultAccessors()[0];
+ groupHandler = query.getPrefetchGroupHandler();
}
public Object invokeInstance(CMPInstanceContext ctx, Object[] args)
throws Exception {
+ InTxCache cache = ctx.getTransactionContext().getInTxCache();
if (flushCache) {
- ctx.getTransactionContext().getInTxCache().flush();
+ cache.flush();
}
Object o;
try {
- SingleValuedResultHandler handler = new
SingleValuedResultHandler(commandView.getView()[0]);
- o = commandView.getQueryCommand().execute(handler, new
Row(args), NODATA);
+ ResultHandler handler = new
SingleValuedResultHandler(resultAccessor);
+ if (null != groupHandler) {
+ PrefetchGroupHandler newHandler = new
PrefetchGroupHandler(groupHandler, handler);
+ o = newHandler.execute(cache, command, new Row(args),
NODATA);
+ } else {
+ o = command.execute(handler, new Row(args), NODATA);
+ }
} catch (QueryException e) {
throw (FinderException) new
FinderException(e.getMessage()).initCause(e);
}