Class ContextRunnable

java.lang.Object
org.adempiere.util.ContextRunnable
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
GridTab.Loader, MLookup.MLoader, ZkContextRunnable

public abstract class ContextRunnable extends Object implements Runnable
Base class to implement runnable that will execute code in session context.
Example usage:
     ContextRunnable runnable = new ContextRunnable() {
         protected void doRun() {
            ....
         }
     };
     Adempiere.getThreadPoolExecutor().submit(runnable);
 
Author:
hengsin
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Properties
    current session context
  • Constructor Summary

    Constructors
    Constructor
    Description
    Capture reference to current session context.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    clean up thread local context
    protected abstract void
    override to execute code in session context
    void
    run()
    Set captured session context as current thread local context and call doRun() to perform actual work.
    protected void
    setup thread local context

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • context

      protected Properties context
      current session context
  • Constructor Details

    • ContextRunnable

      public ContextRunnable()
      Capture reference to current session context.
  • Method Details

    • run

      public void run()
      Set captured session context as current thread local context and call doRun() to perform actual work.
      Specified by:
      run in interface Runnable
    • setup

      protected void setup()
      setup thread local context
    • cleanup

      protected void cleanup()
      clean up thread local context
    • doRun

      protected abstract void doRun()
      override to execute code in session context