dblevins 2005/06/21 17:16:58
Modified: modules/core/src/java/org/openejb/entity/cmp
CMPCreateMethod.java CollectionValuedFinder.java
EnumerationValuedFinder.java SetValuedFinder.java
SingleValuedFinder.java
Log:
Removing 47 references to the SimpleInvocationResult constructor and
replacing with a factory method on EJBInvocatin interface. The
implementor of EJBInvocation should be able to decide the
implementation of InvocationResult.
Revision Changes Path
1.14 +5 -5
openejb/modules/core/src/java/org/openejb/entity/cmp/CMPCreateMethod.java
Index: CMPCreateMethod.java
===================================================================
RCS file:
/scm/openejb/openejb/modules/core/src/java/org/openejb/entity/cmp/CMPCreateMethod.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- CMPCreateMethod.java 25 Feb 2005 23:06:10 -0000 1.13
+++ CMPCreateMethod.java 21 Jun 2005 21:16:58 -0000 1.14
@@ -150,7 +150,7 @@
Throwable t = ite.getTargetException();
if (t instanceof Exception && t instanceof RuntimeException ==
false) {
// checked exception - which we simply include in the result
- return new SimpleInvocationResult(false, t);
+ return invocation.createExceptionResult((Exception)t);
} else {
// unchecked Exception - just throw it to indicate an
abnormal completion
throw t;
@@ -195,7 +195,7 @@
}
} catch (DuplicateIdentityException e) {
Object pk = primaryKeyTransform.getDomainIdentity(globalId);
- return new SimpleInvocationResult(false, new
DuplicateKeyException("ID=" + pk));
+ return invocation.createExceptionResult((Exception)new
DuplicateKeyException("ID=" + pk));
}
ctx.setCacheRow(cacheRow);
@@ -215,7 +215,7 @@
if (t instanceof Exception && t instanceof RuntimeException ==
false) {
// checked exception - which we simply include in the result
// we do not force rollback, that is up to the application
- return new SimpleInvocationResult(false, t);
+ return invocation.createExceptionResult((Exception)t);
} else {
// unchecked Exception - just throw it to indicate an
abnormal completion
throw t;
@@ -227,7 +227,7 @@
// return a new proxy
IdentityTransform transform = invocation.getType().isLocal() ?
localProxyTransform : remoteProxyTransform;
- return new SimpleInvocationResult(true,
transform.getDomainIdentity(globalId));
+ return
invocation.createResult(transform.getDomainIdentity(globalId));
}
private Object readResolve() {
1.7 +3 -3
openejb/modules/core/src/java/org/openejb/entity/cmp/CollectionValuedFinder.java
Index: CollectionValuedFinder.java
===================================================================
RCS file:
/scm/openejb/openejb/modules/core/src/java/org/openejb/entity/cmp/CollectionValuedFinder.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CollectionValuedFinder.java 2 Mar 2005 11:43:14 -0000 1.6
+++ CollectionValuedFinder.java 21 Jun 2005 21:16:58 -0000 1.7
@@ -79,9 +79,9 @@
Collection results = new ArrayList();
CollectionResultHandler handler = new
CollectionResultHandler(commandView.getView()[0]);
commandView.getQueryCommand().execute(handler, new
Row(invocation.getArguments()), results);
- return new SimpleInvocationResult(true, results);
+ return invocation.createResult(results);
} catch (QueryException e) {
- return new SimpleInvocationResult(false, new
FinderException(e.getMessage()).initCause(e));
+ return invocation.createExceptionResult((Exception)new
FinderException(e.getMessage()).initCause(e));
}
}
1.7 +3 -3
openejb/modules/core/src/java/org/openejb/entity/cmp/EnumerationValuedFinder.java
Index: EnumerationValuedFinder.java
===================================================================
RCS file:
/scm/openejb/openejb/modules/core/src/java/org/openejb/entity/cmp/EnumerationValuedFinder.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- EnumerationValuedFinder.java 2 Mar 2005 11:43:14 -0000 1.6
+++ EnumerationValuedFinder.java 21 Jun 2005 21:16:58 -0000 1.7
@@ -80,9 +80,9 @@
List results = new ArrayList();
CollectionResultHandler handler = new
CollectionResultHandler(commandView.getView()[0]);
commandView.getQueryCommand().execute(handler, new
Row(invocation.getArguments()), results);
- return new SimpleInvocationResult(true,
Collections.enumeration(results));
+ return invocation.createResult(Collections.enumeration(results));
} catch (QueryException e) {
- return new SimpleInvocationResult(false, new
FinderException(e.getMessage()).initCause(e));
+ return invocation.createExceptionResult((Exception)new
FinderException(e.getMessage()).initCause(e));
}
}
1.3 +3 -3
openejb/modules/core/src/java/org/openejb/entity/cmp/SetValuedFinder.java
Index: SetValuedFinder.java
===================================================================
RCS file:
/scm/openejb/openejb/modules/core/src/java/org/openejb/entity/cmp/SetValuedFinder.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SetValuedFinder.java 2 Mar 2005 11:43:14 -0000 1.2
+++ SetValuedFinder.java 21 Jun 2005 21:16:58 -0000 1.3
@@ -79,9 +79,9 @@
Set results = new HashSet();
CollectionResultHandler handler = new
CollectionResultHandler(commandView.getView()[0]);
commandView.getQueryCommand().execute(handler, new
Row(invocation.getArguments()), results);
- return new SimpleInvocationResult(true, results);
+ return invocation.createResult(results);
} catch (QueryException e) {
- return new SimpleInvocationResult(false, new
FinderException(e.getMessage()).initCause(e));
+ return invocation.createExceptionResult((Exception)new
FinderException(e.getMessage()).initCause(e));
}
}
1.7 +9 -7
openejb/modules/core/src/java/org/openejb/entity/cmp/SingleValuedFinder.java
Index: SingleValuedFinder.java
===================================================================
RCS file:
/scm/openejb/openejb/modules/core/src/java/org/openejb/entity/cmp/SingleValuedFinder.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SingleValuedFinder.java 2 Mar 2005 11:43:14 -0000 1.6
+++ SingleValuedFinder.java 21 Jun 2005 21:16:58 -0000 1.7
@@ -77,30 +77,32 @@
try {
QueryCommandView commandView = getCommand(invocation);
- SingleValuedResultHandler handler = new
SingleValuedResultHandler(commandView.getView()[0]);
+ SingleValuedResultHandler handler = new
SingleValuedResultHandler(commandView.getView()[0], invocation);
Object o = commandView.getQueryCommand().execute(handler, new
Row(invocation.getArguments()), NODATA);
- return o == NODATA ? new SimpleInvocationResult(false, new
ObjectNotFoundException()) : (InvocationResult) o;
+ return o == NODATA ?
invocation.createExceptionResult((Exception)new ObjectNotFoundException()) :
(InvocationResult) o;
} catch (QueryException e) {
- return new SimpleInvocationResult(false, new
FinderException(e.getMessage()).initCause(e));
+ return invocation.createExceptionResult((Exception)new
FinderException(e.getMessage()).initCause(e));
}
}
private class SingleValuedResultHandler implements ResultHandler {
+ private final EJBInvocation invocation;
private final FieldTransform accessor;
- public SingleValuedResultHandler(FieldTransform accessor) {
+ public SingleValuedResultHandler(FieldTransform accessor,
EJBInvocation invocation) {
this.accessor = accessor;
+ this.invocation = invocation;
}
public Object fetched(Row row, Object arg) throws QueryException {
if (arg == NODATA) {
try {
Object opaque = accessor.get(row);
- return new SimpleInvocationResult(true, opaque);
+ return invocation.createResult(opaque);
} catch (FieldTransformException e) {
throw new QueryException(e);
}
}
- return new SimpleInvocationResult(false, new
FinderException("More than one row returned from single valued finder"));
+ return invocation.createExceptionResult((Exception)new
FinderException("More than one row returned from single valued finder"));
}
}
}