Package wt.session

Class SessionThread

java.lang.Object
java.lang.Thread
wt.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:
  • Constructor Details

    • 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
    • SessionThread

      public SessionThread(Runnable target, SessionContext session_context, String name)
      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
      name - the name to give the resulting thread
  • Method Details

    • 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
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
      See Also: