wjhk.jupload2.context
Class JavascriptHandler

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

public class JavascriptHandler
extends java.lang.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
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static java.lang.String COMMAND_START_UPLOAD
          Command code, for upload.
private  java.lang.String jsCommand
          The current command, or null if the thread is not currently running command.
private  JUploadPanel jUploadPanel
          Reference to the main panel of the applet.
static java.lang.String RETURN_BUSY
          One return code for doCommand: indicates that the thread is busy, and can execute this command.
static java.lang.String RETURN_STARTED
          One return code for doCommand: indicates that the thread is busy, and can execute this command.
private  UploadPolicy uploadPolicy
          Reference to the current upload policy.
 
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
 java.lang.String doCommand(java.lang.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()
 java.lang.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 java.lang.String COMMAND_START_UPLOAD
Command code, for upload.

See Also:
Constant Field Values

RETURN_BUSY

public static final java.lang.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 java.lang.String RETURN_STARTED
One return code for doCommand: indicates that the thread is busy, and can execute this command.

See Also:
Constant Field Values

uploadPolicy

private UploadPolicy uploadPolicy
Reference to the current upload policy.


jUploadPanel

private JUploadPanel jUploadPanel
Reference to the main panel of the applet.


jsCommand

private java.lang.String jsCommand
The current command, or null if the thread is not currently running command.

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 java.lang.String doCommand(java.lang.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 java.lang.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 java.lang.InterruptedException
Synchronized method to enable call to wait()

Throws:
java.lang.InterruptedException

run

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

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