|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.samskivert.util.Invoker.Unit
com.threerings.presents.util.PersistingUnit
public abstract class PersistingUnit
Simplifies a common pattern which is to post an Invoker unit which does some database
operation and then calls back to an InvocationService.InvocationListener of some
sort. If the database operation fails, the error will be logged and the result listener will be
replied to with InvocationCodes.INTERNAL_ERROR.
| Field Summary | |
|---|---|
protected Object[] |
_args
|
protected Exception |
_error
|
protected InvocationService.InvocationListener |
_listener
|
protected Object |
_result
|
protected boolean |
_resultSet
|
| Fields inherited from class com.samskivert.util.Invoker.Unit |
|---|
_name, queueStamp |
| Constructor Summary | |
|---|---|
PersistingUnit(InvocationService.InvocationListener listener)
|
|
PersistingUnit(String name,
InvocationService.InvocationListener listener)
|
|
PersistingUnit(String name,
InvocationService.InvocationListener listener,
Object... args)
Creates a persisting unit with the supplied name and listener and a set of key/value pairs that will be included in the failure message if this unit fails. |
|
| Method Summary | |
|---|---|
protected String |
getFailureMessage()
Provides a custom failure message in the event that the persistent action fails. |
void |
handleFailure(Exception error)
Handles the failure case by logging the error and reporting an internal error to the listener. |
void |
handleResult()
|
void |
handleSuccess()
Handles the success case, which by default posts a response to a ConfirmListener. |
boolean |
invoke()
|
abstract void |
invokePersistent()
This method is where the unit performs its persistent actions. |
protected void |
reportRequestProcessed()
If the listener is known to be a ConfirmListener, this will cast it and report that the request was processed. |
protected void |
reportRequestProcessed(Object result)
If the listener is known to be a ResultListener, this will cast it and report that the request was processed. |
protected void |
setResult(Object result)
If the service listener is a ResultListener and this method is called, then the given result will be passed along to the listener on success. |
| Methods inherited from class com.samskivert.util.Invoker.Unit |
|---|
getDetail, getLongThreshold, run, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected InvocationService.InvocationListener _listener
protected Exception _error
protected Object[] _args
protected boolean _resultSet
protected Object _result
| Constructor Detail |
|---|
public PersistingUnit(InvocationService.InvocationListener listener)
public PersistingUnit(String name,
InvocationService.InvocationListener listener)
public PersistingUnit(String name,
InvocationService.InvocationListener listener,
Object... args)
| Method Detail |
|---|
public abstract void invokePersistent()
throws Exception
getFailureMessage(), if any.
Exceptionpublic void handleSuccess()
public void handleFailure(Exception error)
public boolean invoke()
invoke in class Invoker.Unitpublic void handleResult()
handleResult in class Invoker.Unitprotected void reportRequestProcessed()
protected void reportRequestProcessed(Object result)
protected String getFailureMessage()
protected void setResult(Object result)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||