From b2ec1d4a8a6b7dc4700afbeeeffa012bf6121afe Mon Sep 17 00:00:00 2001 From: "ray.j.greenwell" Date: Wed, 2 Sep 2009 01:12:33 +0000 Subject: [PATCH] I kinda want to usher in a brave new era of unit usage. But I haven't done it yet. And I've learned recently that since we're not synchronizing we're not guaranteeing that each thread is seeing the latest result. But these all seem to work for us. So I'll commit this now, from Charlie Groves, and we can fiddle in the future. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2627 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- src/java/com/samskivert/jdbc/ResultUnit.java | 40 ++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/java/com/samskivert/jdbc/ResultUnit.java diff --git a/src/java/com/samskivert/jdbc/ResultUnit.java b/src/java/com/samskivert/jdbc/ResultUnit.java new file mode 100644 index 00000000..61b6209c --- /dev/null +++ b/src/java/com/samskivert/jdbc/ResultUnit.java @@ -0,0 +1,40 @@ +package com.samskivert.jdbc; + + +/** + * A RepositoryUnit that returns a single result from its database operations and operates on that. + */ +public abstract class ResultUnit extends RepositoryUnit +{ + public ResultUnit (String name) + { + super(name); + } + + /** + * Performs actions on the database and returns exciting data. + */ + public abstract T getResult () + throws Exception; + + /** + * Operates on the result from getResult back on the main thread, if + * getResult succeeded. + */ + public abstract void handleResult (T result); + + @Override + public void handleSuccess () + { + handleResult(_result); + } + + @Override + public void invokePersist () + throws Exception + { + _result = getResult(); + } + + protected T _result; +}