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; +}