org.tranche.remote
Class RemoteCallback

java.lang.Object
  extended by org.tranche.commons.Debuggable
      extended by org.tranche.remote.RemoteCallback
Direct Known Subclasses:
ActivityArrayCallback, BooleanArrayCallback, BooleanCallback, CheckForErrorCallback, GetBytesCallback, GetHashesCallback, IntegerCallback, StatusTableCallback

public abstract class RemoteCallback
extends org.tranche.commons.Debuggable

Abstract remote callback with common functionality.

Author:
Jayson Falkner - jfalkner@umich.edu, Bryan E. Smith - bryanesmith@gmail.com, James "Augie" Hill - augman85@gmail.com

Field Summary
static long NOT_COMPLETED
          Flag meaning the callback is not fulfilled.
 
Constructor Summary
RemoteCallback(long id, RemoteTrancheServer rts, java.lang.String name, java.lang.String description)
           
 
Method Summary
abstract  void callback(byte[] bytes)
          Method to be implemented.
 java.lang.Exception getCachedException()
           
 java.lang.String getDescription()
          Returns the description of this callback.
 long getID()
           
 java.lang.String getName()
          Returns thename of this callback.
 java.lang.String getPurgeMsg()
          Returns the message that was given for purging this callback.
protected  RemoteTrancheServer getRemoteTrancheServer()
           
 long getTimeCompleted()
          Returns the UNIX timestamp for when the callback was fulfilled.
 long getTimeStarted()
           
 boolean isComplete()
          Returns whether this callback has been fulfilled.
protected  boolean isPurged()
          Returns whether purged.
 void keepAlive()
           
 void notifyTimedOut()
           
 void notifyWaiting()
          Notify caller waiting callback.
 void purge(java.lang.String reason)
          Purges callback, notifying waiting threads.
protected  void setCachedException(java.lang.Exception e)
           
 void waitForCallback()
          Caller blocks waiting for callback.
 
Methods inherited from class org.tranche.commons.Debuggable
debugErr, debugErr, debugOut, isDebug, setDebug
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOT_COMPLETED

public static final long NOT_COMPLETED

Flag meaning the callback is not fulfilled.

See Also:
Constant Field Values
Constructor Detail

RemoteCallback

public RemoteCallback(long id,
                      RemoteTrancheServer rts,
                      java.lang.String name,
                      java.lang.String description)
Parameters:
id -
rts -
name -
description -
Method Detail

callback

public abstract void callback(byte[] bytes)

Method to be implemented.

Parameters:
bytes -

keepAlive

public void keepAlive()

waitForCallback

public void waitForCallback()
                     throws java.lang.Exception

Caller blocks waiting for callback. Caller's execution blocked within RemoteTrancheServer.

Throws:
java.lang.Exception

notifyWaiting

public void notifyWaiting()

Notify caller waiting callback.


notifyTimedOut

public void notifyTimedOut()

getRemoteTrancheServer

protected RemoteTrancheServer getRemoteTrancheServer()
Returns:

getID

public long getID()
Returns:

isComplete

public boolean isComplete()

Returns whether this callback has been fulfilled.

Returns:

getTimeCompleted

public long getTimeCompleted()

Returns the UNIX timestamp for when the callback was fulfilled.

Returns:

getTimeStarted

public long getTimeStarted()
Returns:

purge

public void purge(java.lang.String reason)

Purges callback, notifying waiting threads. Sends a useful exception.

Parameters:
reason -

isPurged

protected boolean isPurged()

Returns whether purged. Used by callbacks for better exceptions.

Returns:

getPurgeMsg

public java.lang.String getPurgeMsg()

Returns the message that was given for purging this callback.

Returns:

getName

public java.lang.String getName()

Returns thename of this callback.

Returns:

getDescription

public java.lang.String getDescription()

Returns the description of this callback.

Returns:

getCachedException

public java.lang.Exception getCachedException()
Returns:

setCachedException

protected void setCachedException(java.lang.Exception e)
Parameters:
e -


This code is free for use both commercially and non-commercially as stated in the project's license