wjhk.jupload2
Class JavascriptHandler

java.lang.Object
  extended by java.lang.Thread
      extended by wjhk.jupload2.JavascriptHandler
All Implemented Interfaces:
Runnable

public class JavascriptHandler
extends Thread

Separate thread spawned by the (signed) applet at initialization time so it will run in a context with the same privileges. Does nothing but wait to be notified of the presence of a command to be executed in the jsCommand String variable.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static String COMMAND_START_UPLOAD
          Command code, for upload.
static String RETURN_BUSY
          One return code for doCommand: indicates that the thread is busy, and can execute this command.
static String RETURN_STARTED
          One return code for doCommand: indicates that the thread is busy, and can execute this command.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
JavascriptHandler(UploadPolicy uploadPolicy, JUploadPanel theJUploadPanel)
          Constructor for JavascriptHandler
 
Method Summary
 void clearCommand()
          Synchronized method allows for safely clearing jsCommand string
 String doCommand(String command)
          Method for passing a command (String) to be executed (asynchronously) by the run() method of this object's thread.
 void doWait()
          Synchronized method to enable call to wait()
 String getCommand()
          Synchronized method allows for safely accessing jsCommand string
 void run()
          Method to run when thread is started.
 
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
 

Field Detail

COMMAND_START_UPLOAD

public static final String COMMAND_START_UPLOAD
Command code, for upload.

See Also:
Constant Field Values

RETURN_BUSY

public static final String RETURN_BUSY
One return code for doCommand: indicates that the thread is busy, and can execute this command.

See Also:
Constant Field Values

RETURN_STARTED

public static final String RETURN_STARTED
One return code for doCommand: indicates that the thread is busy, and can execute this command.

See Also:
Constant Field Values
Constructor Detail

JavascriptHandler

public JavascriptHandler(UploadPolicy uploadPolicy,
                         JUploadPanel theJUploadPanel)
Constructor for JavascriptHandler

Parameters:
uploadPolicy - The current upload policy. Used for debug output.
theJUploadPanel - Whose methods will will be invoked in order to execute the received commands
Method Detail

doCommand

public String doCommand(String command)
Method for passing a command (String) to be executed (asynchronously) by the run() method of this object's thread. Commands are accepted only if there is no previous command still executing. (Commands are not queued.) Return value indicates if command was successfully submitted.

Parameters:
command -
Returns:
the command string argument on success, empty string on failure.

getCommand

public String getCommand()
Synchronized method allows for safely accessing jsCommand string

Returns:
Returns the current command

clearCommand

public void clearCommand()
Synchronized method allows for safely clearing jsCommand string


doWait

public void doWait()
            throws InterruptedException
Synchronized method to enable call to wait()

Throws:
InterruptedException

run

public void run()
Method to run when thread is started.

Specified by:
run in interface Runnable
Overrides:
run in class Thread