TaskBean API
0.5

glogic.jthin.app
Class JThinWorker

java.lang.Object
  extended byglogic.jthin.app.JThinWorker

public abstract class JThinWorker
extends java.lang.Object

Manages thread that is invoked by GUI code to process both the remote call and then process the reply and consume the results into the GUI. Normally all remote requests should use this class to handle both the remote processing and how the application is suspended during the remote processing. During remote processing the ControlBar will display corresponding status messages and status. An hour glass will prevent the user from performing mouse/key events until the remote request has returned or the user has "Stop" the remote processing.

Author:
Sam Taha

Field Summary
static int COMPLETED
           
static int DISPLAY_FAILURE
           
static int PROCESSING
           
static int REMOTE_FAILURE
           
 
Constructor Summary
JThinWorker(JThinFrame frame, java.lang.String stOperationName)
          Perform a remote server call and then update the gui once the remove call has returned.
 
Method Summary
 long getCompletedTime()
           
 java.lang.Throwable getException()
           
 JThinFrame getJThinFrame()
           
 java.lang.Object getLogicOpResult()
          Return the value created by the remoteOperation method.
 java.lang.String getOperationName()
           
 int getRequestStatus()
           
 long getScreenID()
           
 long getStartTime()
           
 long getStopRequestTime()
           
protected  java.lang.Object getValue()
          Get the value produced by the worker thread, or null if it hasn't been constructed yet.
 void guiOperation()
          Called on the event dispatching thread (not on the worker thread) after the remoteOperation method has returned.
 void interrupt()
          A new method that interrupts the worker thread.
 boolean isStopRequested()
           
abstract  java.lang.Object remoteOperation()
          Compute the value to be returned by the get method.
 void start()
          Start the worker thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROCESSING

public static final int PROCESSING
See Also:
Constant Field Values

COMPLETED

public static final int COMPLETED
See Also:
Constant Field Values

REMOTE_FAILURE

public static final int REMOTE_FAILURE
See Also:
Constant Field Values

DISPLAY_FAILURE

public static final int DISPLAY_FAILURE
See Also:
Constant Field Values
Constructor Detail

JThinWorker

public JThinWorker(JThinFrame frame,
                   java.lang.String stOperationName)
Perform a remote server call and then update the gui once the remove call has returned. Updating GUI is optional. Put up hourglass until remote server call complete and GUI operations are also complete. If you do not wish to perform a remote server call but still want to backgroud (and hourglass) a long running GUI call, then do not implement the guiOperation method.

Parameters:
frame - Description of the Parameter
Method Detail

getValue

protected java.lang.Object getValue()
Get the value produced by the worker thread, or null if it hasn't been constructed yet.

Returns:
The _oReturnValue value

remoteOperation

public abstract java.lang.Object remoteOperation()
                                          throws WServiceAccessException,
                                                 ClientInvokeException
Compute the value to be returned by the get method. Every remote operation can throw the declared exceptions shown here. Normally these exceptions will be handled by the JThinWorker exception handling logic. If either one of these exceptions occur (or an uncaught RuntimeExcpetion or Error exception) then the guiOperation() method will not be called. The implementor of this method should NOT catch these exceptions. In rare cases you can catch these exceptions if you need display specific error or status information but normally you should not, and if you do you should rethrow them. If the implentation of this method can throw additional exceptions they should be caught within the implementation and passed to the guiOperation() method as necessary.

Returns:
Description of the optional Return Value
Throws:
WServiceAccessException
ClientInvokeException

guiOperation

public void guiOperation()
Called on the event dispatching thread (not on the worker thread) after the remoteOperation method has returned. If the remote call throws additional execptions that are caught in the body of the remoteOperation method then those exceptions should be checked for at the begining of the this method and rethrown as necessary. Note, if the user manaully stops thre request or their is a failure in the remoteOperation method (WServiceAccessException or ClientInvokeException) then this method will not be called but instead an error message displayed in the control bar.


interrupt

public void interrupt()
A new method that interrupts the worker thread. Call this method to force the worker to stop what it's doing (only if it is in a wait or encounters a wait). Otherwise this does nothing.


getLogicOpResult

public java.lang.Object getLogicOpResult()
Return the value created by the remoteOperation method. Returns null if either the constructing thread or the current thread was interrupted before a value was produced.

Returns:
the value created by the remoteOperation method

start

public void start()
Start the worker thread.


getScreenID

public final long getScreenID()

getOperationName

public final java.lang.String getOperationName()

getJThinFrame

public final JThinFrame getJThinFrame()

getException

public final java.lang.Throwable getException()

getRequestStatus

public final int getRequestStatus()

getStartTime

public final long getStartTime()

getCompletedTime

public final long getCompletedTime()

getStopRequestTime

public final long getStopRequestTime()

isStopRequested

public final boolean isStopRequested()

TaskBean API
0.5

Copyright © Grand Logic, Inc. All Rights Reserved.