wt.session
Class SessionThread

java.lang.Object
  extended byjava.lang.Thread
      extended bywt.session.SessionThread
All Implemented Interfaces:
Runnable

public class SessionThread
extends Thread

A thread class for executing asynchronous server-side operations under a new or existing session context. A new method context is established for the thread and a new or existing session context is associated with the new method context.

For example, the following code shows creating a new thread to continue processing while the original thread returns method results to the caller.

    ...
    Runnable async_stuff = new Runnable ()
    {
       public void run ()
       {
          doAsyncStuff();
       }
    }
    new SessionThread(async_stuff).start();
    ...
 
The following code illustrates creating a new session context to perform a background operation as a different principle.
    ...
    Runnable admin_stuff = new Runnable ()
    {
       public void run ()
       {
          try
          {
             SessionMgr.setPrincipal(AdministrativeDomainHelper.ADMINISTRATOR_NAME);
             doAdminStuff();
          }
          catch (Exception e)
          {
             e.printStackTrace(System.err);
          }
       }
    }
    new SessionThread(admin_stuff, new SessionContext()).start();
    ...
 
For simple push/pop of a new session context within a single thread, see the newContext method in the SessionContext class.

Supported API: true
Extendable: false

See Also:
SessionContext, MethodContext

Field Summary
private  SessionContext sessionContext
           
private  Runnable target
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SessionThread(Runnable target)
          Construct a session thread that inherits the current session context.
SessionThread(Runnable target, SessionContext session_context)
          Construct a session thread for the given session context.
 
Method Summary
 void run()
          Execute target runnable.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, 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

target

private Runnable target

sessionContext

private SessionContext sessionContext
Constructor Detail

SessionThread

public SessionThread(Runnable target)
Construct a session thread that inherits the current session context.

Supported API: true

Parameters:
target - the Runnable target for the new thread

SessionThread

public SessionThread(Runnable target,
                     SessionContext session_context)
Construct a session thread for the given session context.

Supported API: true

Parameters:
target - the Runnable target for the new thread
session_context - the SessionContext object associated with the thread
Method Detail

run

public void run()
Execute target runnable. A new MethodContext is created which establishes the association between the executing thread and the desired SessionContext object.

Supported API: true

See Also:
MethodContext, SessionContext