com.gargoylesoftware.htmlunit.javascript.background
Class JavaScriptExecutor

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.javascript.background.JavaScriptExecutor
All Implemented Interfaces:
Serializable, Runnable
Direct Known Subclasses:
GAEJavaScriptExecutor

public class JavaScriptExecutor
extends Object
implements Runnable, Serializable

An event loop to execute all the JavaScript jobs.

Version:
$Revision: 5920 $
Author:
Amit Manjhi
See Also:
Serialized Form

Nested Class Summary
protected  class JavaScriptExecutor.JobExecutor
          A simple class to store a JavaScriptJobManager and its earliest job.
 
Constructor Summary
JavaScriptExecutor(WebClient webClient)
          Creates an EventLoop for the webClient.
 
Method Summary
 void addWindow(WebWindow newWindow)
          Register a window with the eventLoop.
protected  JavaScriptExecutor.JobExecutor getEarliestJob()
          Returns the JobExecutor corresponding to the earliest job.
 int pumpEventLoop(long timeoutMillis)
          Executes the jobs in the eventLoop till timeoutMillis expires or the eventLoop becomes empty.
 void run()
          Runs the eventLoop.
 void shutdown()
          Notes that this thread has been shutdown.
protected  void startThreadIfNeeded()
          Starts the eventLoopThread_.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaScriptExecutor

public JavaScriptExecutor(WebClient webClient)
Creates an EventLoop for the webClient.

Parameters:
webClient - the provided webClient
Method Detail

startThreadIfNeeded

protected void startThreadIfNeeded()
Starts the eventLoopThread_.


getEarliestJob

protected JavaScriptExecutor.JobExecutor getEarliestJob()
Returns the JobExecutor corresponding to the earliest job.

Returns:
the JobExectuor with the earliest job.

pumpEventLoop

public int pumpEventLoop(long timeoutMillis)
Executes the jobs in the eventLoop till timeoutMillis expires or the eventLoop becomes empty. No use in non-GAE mode.

Parameters:
timeoutMillis - the timeout in milliseconds
Returns:
the number of jobs executed

run

public void run()
Runs the eventLoop.

Specified by:
run in interface Runnable

addWindow

public void addWindow(WebWindow newWindow)
Register a window with the eventLoop.

Parameters:
newWindow - the new web window

shutdown

public void shutdown()
Notes that this thread has been shutdown.



Copyright © 2002-2011 Gargoyle Software Inc.. All Rights Reserved.