Class DefaultJavaScriptExecutor

  • All Implemented Interfaces:
    java.lang.Runnable, JavaScriptExecutor

    public class DefaultJavaScriptExecutor
    extends java.lang.Object
    implements JavaScriptExecutor
    An event loop to execute all the JavaScript jobs.
    • Field Detail

      • webClient_

        private final transient java.lang.ref.WeakReference<WebClient> webClient_
      • jobManagerList_

        private final transient java.util.List<java.lang.ref.WeakReference<JavaScriptJobManager>> jobManagerList_
      • shutdown_

        private final transient java.util.concurrent.atomic.AtomicBoolean shutdown_
      • eventLoopThread_

        private transient java.lang.Thread eventLoopThread_
      • LOG

        private static final org.apache.commons.logging.Log LOG
        Logging support.
    • Constructor Detail

      • DefaultJavaScriptExecutor

        public DefaultJavaScriptExecutor​(WebClient webClient)
        Creates an EventLoop for the webClient.
        Parameters:
        webClient - the provided webClient
    • Method Detail

      • startThreadIfNeeded

        protected void startThreadIfNeeded()
        Starts the eventLoopThread_.
      • getThreadName

        protected java.lang.String getThreadName()
        Defines the thread name; overload if needed.
        Returns:
        the name of the js executor thread
      • killThread

        private void killThread()
      • getJobManagerWithEarliestJob

        protected JavaScriptJobManager getJobManagerWithEarliestJob()
        Returns the JobExecutor corresponding to the earliest job.
        Returns:
        the JobExectuor with the earliest job.
      • run

        public void run()
        Runs the eventLoop.
        Specified by:
        run in interface java.lang.Runnable
      • addWindow

        public void addWindow​(WebWindow newWindow)
        Register a window with the eventLoop.
        Specified by:
        addWindow in interface JavaScriptExecutor
        Parameters:
        newWindow - the new web window
      • shutdown

        public void shutdown()
        Notes that this thread has been shutdown.
        Specified by:
        shutdown in interface JavaScriptExecutor