proai.service
Class CacheSession<T>

java.lang.Object
  extended by java.lang.Thread
      extended by proai.service.CacheSession<T>
All Implemented Interfaces:
java.lang.Runnable, Session

public class CacheSession<T>
extends java.lang.Thread
implements Session


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
CacheSession(SessionManager manager, java.io.File baseDir, int secondsBetweenRequests, ListProvider<T> provider)
           
 
Method Summary
 void clean()
          Do all possible cleanup for this session.
 void finalize()
           
 ResponseData getResponseData(int partNum)
          Get the named response, wait for it, or throw any exception that has popped up while generating parts.
 boolean hasExpired()
          Has the session expired? If this is true, the session will be cleaned by the reaper thread of the session manager.
 void run()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CacheSession

public CacheSession(SessionManager manager,
                    java.io.File baseDir,
                    int secondsBetweenRequests,
                    ListProvider<T> provider)
Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

hasExpired

public boolean hasExpired()
Has the session expired? If this is true, the session will be cleaned by the reaper thread of the session manager.

Specified by:
hasExpired in interface Session

clean

public void clean()
Do all possible cleanup for this session. This includes signaling to its thread to stop asap, waiting for it to stop, and removing any files/directories that remain. The implementation should be fail-safe, as a session may be asked to clean itself more than once. Clean must *not* be called from this session's thread.

Specified by:
clean in interface Session

getResponseData

public ResponseData getResponseData(int partNum)
                             throws ServerException,
                                    BadResumptionTokenException
Get the named response, wait for it, or throw any exception that has popped up while generating parts.

Specified by:
getResponseData in interface Session
Throws:
ServerException
BadResumptionTokenException

finalize

public void finalize()
Overrides:
finalize in class java.lang.Object