com.pushtotest.tool.protocolhandler
Class ProtocolThread

java.lang.Object
  extended by java.lang.Thread
      extended by com.pushtotest.tool.protocolhandler.ProtocolThread
All Implemented Interfaces:
java.lang.Runnable

public class ProtocolThread
extends java.lang.Thread

This is a class that wraps around a Protocol object to make it run in its own thread. This will allow the Protocol implementations themselves to be rather simple and not have to deal with timeouts and the like. Instead, the ProtocolThread will handle that stuff.


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
ProtocolThread(Protocol protocol)
          This constrcuts a new ProtocolThread that wraps around the passed in Protocol Object.
 
Method Summary
 Response getResponse()
          This should only be called if the Protocol is run as a Thread.
 boolean isRunning()
          Is the current thread runnign or has it completed?
 void run()
          This is the method called when protocolthread.start() is called.
 boolean timedOut()
          This method will tell whether or not the Protocol attempt timed out before it was successfully completed or not.
 
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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProtocolThread

public ProtocolThread(Protocol protocol)
This constrcuts a new ProtocolThread that wraps around the passed in Protocol Object.

Parameters:
protocol - The Protocol object that should be wrapped in this thread and run.
Method Detail

timedOut

public boolean timedOut()
This method will tell whether or not the Protocol attempt timed out before it was successfully completed or not.

Returns:
Whether or not the connection timed out before everything was done.

isRunning

public boolean isRunning()
Is the current thread runnign or has it completed?

Returns:
Whether the current thread is still running.

getResponse

public Response getResponse()
This should only be called if the Protocol is run as a Thread. Otherwise the connect() method can be called directly. synchronized monitor so that the thread will just sleep while it waits for the response to be available. Good ol' spinlock.

Returns:
The Response object generated.

run

public void run()
This is the method called when protocolthread.start() is called. All the stuff in here is run in it's own thread.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread