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
This commit is contained in:
@@ -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<T> 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 <code>getResult</code> back on the main thread, if
|
||||
* <code>getResult</code> succeeded.
|
||||
*/
|
||||
public abstract void handleResult (T result);
|
||||
|
||||
@Override
|
||||
public void handleSuccess ()
|
||||
{
|
||||
handleResult(_result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invokePersist ()
|
||||
throws Exception
|
||||
{
|
||||
_result = getResult();
|
||||
}
|
||||
|
||||
protected T _result;
|
||||
}
|
||||
Reference in New Issue
Block a user