gdamour 2005/03/02 06:43:14
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-580
o add an itests test verifying the correct behavior of the implementation.
GERONIMO-598
o add the flush-cache-before-query optional element, which identifies if
the transactional cache should be flushed before the execution of the
associated finder or select operation; and
o update the various XValuedFinder and XValuedSelect in order to flush
the transaction cache if required.
Revision Changes Path
1.12 +13 -2
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.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- CMPFinder.java 7 Jan 2005 06:36:32 -0000 1.11
+++ CMPFinder.java 2 Mar 2005 11:43:13 -0000 1.12
@@ -51,6 +51,8 @@
import org.openejb.EJBInvocation;
import org.openejb.dispatch.VirtualOperation;
+import org.tranql.cache.InTxCache;
+import org.tranql.ql.QueryException;
import org.tranql.query.QueryCommandView;
/**
@@ -59,14 +61,23 @@
public abstract class CMPFinder implements VirtualOperation, Serializable {
private final QueryCommandView localQueryView;
private final QueryCommandView remoteQueryView;
+ private final boolean flushCache;
- public CMPFinder(QueryCommandView localQueryView, QueryCommandView
remoteQueryView) {
+ public CMPFinder(QueryCommandView localQueryView, QueryCommandView
remoteQueryView, boolean flushCache) {
this.localQueryView = localQueryView;
this.remoteQueryView = remoteQueryView;
+ this.flushCache = flushCache;
}
protected QueryCommandView getCommand(EJBInvocation invocation) {
return invocation.getType().isLocal() ? localQueryView :
remoteQueryView;
+ }
+
+ protected void flushCache(EJBInvocation invocation) throws
QueryException {
+ InTxCache cache = invocation.getTransactionContext().getInTxCache();
+ if (flushCache) {
+ cache.flush();
+ }
}
}
1.6 +5 -3
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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CollectionValuedFinder.java 7 Jan 2005 06:36:32 -0000 1.5
+++ CollectionValuedFinder.java 2 Mar 2005 11:43:14 -0000 1.6
@@ -67,11 +67,13 @@
*/
public class CollectionValuedFinder extends CMPFinder {
- public CollectionValuedFinder(QueryCommandView localQueryView,
QueryCommandView remoteQueryView) {
- super(localQueryView, remoteQueryView);
+ public CollectionValuedFinder(QueryCommandView localQueryView,
QueryCommandView remoteQueryView, boolean flushCache) {
+ super(localQueryView, remoteQueryView, flushCache);
}
public InvocationResult execute(EJBInvocation invocation) throws
Throwable {
+ flushCache(invocation);
+
try {
QueryCommandView commandView = getCommand(invocation);
Collection results = new ArrayList();
1.4 +8 -2
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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CollectionValuedSelect.java 5 Feb 2005 11:26:53 -0000 1.3
+++ CollectionValuedSelect.java 2 Mar 2005 11:43:14 -0000 1.4
@@ -65,12 +65,18 @@
*/
public class CollectionValuedSelect implements InstanceOperation {
private final QueryCommandView commandView;
+ private final boolean flushCache;
- public CollectionValuedSelect(QueryCommandView commandView) {
+ public CollectionValuedSelect(QueryCommandView commandView, boolean
flushCache) {
this.commandView = commandView;
+ this.flushCache = flushCache;
}
public Object invokeInstance(CMPInstanceContext ctx, Object[] args)
throws Exception {
+ if (flushCache) {
+ ctx.getTransactionContext().getInTxCache().flush();
+ }
+
Collection results = new ArrayList();
try {
CollectionResultHandler handler = new
CollectionResultHandler(commandView.getView()[0]);
1.6 +5 -3
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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- EnumerationValuedFinder.java 7 Jan 2005 06:36:32 -0000 1.5
+++ EnumerationValuedFinder.java 2 Mar 2005 11:43:14 -0000 1.6
@@ -68,11 +68,13 @@
*/
public class EnumerationValuedFinder extends CMPFinder {
- public EnumerationValuedFinder(QueryCommandView localQueryView,
QueryCommandView remoteQueryView) {
- super(localQueryView, remoteQueryView);
+ public EnumerationValuedFinder(QueryCommandView localQueryView,
QueryCommandView remoteQueryView, boolean flushCache) {
+ super(localQueryView, remoteQueryView, flushCache);
}
public InvocationResult execute(EJBInvocation invocation) throws
Throwable {
+ flushCache(invocation);
+
try {
QueryCommandView commandView = getCommand(invocation);
List results = new ArrayList();
1.2 +5 -3
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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SetValuedFinder.java 7 Jan 2005 06:37:52 -0000 1.1
+++ SetValuedFinder.java 2 Mar 2005 11:43:14 -0000 1.2
@@ -67,11 +67,13 @@
*/
public class SetValuedFinder extends CMPFinder {
- public SetValuedFinder(QueryCommandView localQueryView, QueryCommandView
remoteQueryView) {
- super(localQueryView, remoteQueryView);
+ public SetValuedFinder(QueryCommandView localQueryView, QueryCommandView
remoteQueryView, boolean flushCache) {
+ super(localQueryView, remoteQueryView, flushCache);
}
public InvocationResult execute(EJBInvocation invocation) throws
Throwable {
+ flushCache(invocation);
+
try {
QueryCommandView commandView = getCommand(invocation);
Set results = new HashSet();
1.4 +8 -2
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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SetValuedSelect.java 5 Feb 2005 11:26:53 -0000 1.3
+++ SetValuedSelect.java 2 Mar 2005 11:43:14 -0000 1.4
@@ -64,12 +64,18 @@
*/
public class SetValuedSelect implements InstanceOperation {
private final QueryCommandView commandView;
+ private final boolean flushCache;
- public SetValuedSelect(QueryCommandView commandView) {
+ public SetValuedSelect(QueryCommandView commandView, boolean flushCache)
{
this.commandView = commandView;
+ this.flushCache = flushCache;
}
public Object invokeInstance(CMPInstanceContext ctx, Object[] args)
throws Exception {
+ if (flushCache) {
+ ctx.getTransactionContext().getInTxCache().flush();
+ }
+
Set results = new HashSet();
try {
CollectionResultHandler handler = new
CollectionResultHandler(commandView.getView()[0]);
1.6 +5 -3
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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- SingleValuedFinder.java 7 Jan 2005 06:36:32 -0000 1.5
+++ SingleValuedFinder.java 2 Mar 2005 11:43:14 -0000 1.6
@@ -68,11 +68,13 @@
public class SingleValuedFinder extends CMPFinder {
private static final Object NODATA = new Object();
- public SingleValuedFinder(QueryCommandView localQueryView,
QueryCommandView remoteQueryView) {
- super(localQueryView, remoteQueryView);
+ public SingleValuedFinder(QueryCommandView localQueryView,
QueryCommandView remoteQueryView, boolean flushCache) {
+ super(localQueryView, remoteQueryView, flushCache);
}
public InvocationResult execute(EJBInvocation invocation) throws
Throwable {
+ flushCache(invocation);
+
try {
QueryCommandView commandView = getCommand(invocation);
SingleValuedResultHandler handler = new
SingleValuedResultHandler(commandView.getView()[0]);
1.4 +11 -3
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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SingleValuedSelect.java 5 Feb 2005 11:26:53 -0000 1.3
+++ SingleValuedSelect.java 2 Mar 2005 11:43:14 -0000 1.4
@@ -50,6 +50,8 @@
import javax.ejb.FinderException;
import javax.ejb.ObjectNotFoundException;
+import org.openejb.EJBInvocation;
+import org.tranql.cache.InTxCache;
import org.tranql.field.FieldTransform;
import org.tranql.field.FieldTransformException;
import org.tranql.field.Row;
@@ -66,12 +68,18 @@
private static final Object NODATA = new Object();
private final QueryCommandView commandView;
-
- public SingleValuedSelect(QueryCommandView commandView) {
+ private final boolean flushCache;
+
+ public SingleValuedSelect(QueryCommandView commandView, boolean
flushCache) {
this.commandView = commandView;
+ this.flushCache = flushCache;
}
public Object invokeInstance(CMPInstanceContext ctx, Object[] args)
throws Exception {
+ if (flushCache) {
+ ctx.getTransactionContext().getInTxCache().flush();
+ }
+
Object o;
try {
SingleValuedResultHandler handler = new
SingleValuedResultHandler(commandView.getView()[0]);