com.gargoylesoftware.htmlunit.javascript.background
Class DefaultJavaScriptExecutor

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.javascript.background.DefaultJavaScriptExecutor
All Implemented Interfaces:
JavaScriptExecutor, Serializable, Runnable

public class DefaultJavaScriptExecutor
extends Object
implements JavaScriptExecutor

An event loop to execute all the JavaScript jobs.

Version:
$Revision: 7305 $
Author:
Amit Manjhi, Kostadin Chikov, Ronald Brill
See Also:
Serialized Form

Constructor Summary
DefaultJavaScriptExecutor(WebClient webClient)
          Creates an EventLoop for the webClient.
 
Method Summary
 void addWindow(WebWindow newWindow)
          Register a window with the eventLoop.
protected  JavaScriptJobManager getJobManagerWithEarliestJob()
          Returns the JobExecutor corresponding to the earliest job.
protected  String getThreadName()
          Defines the thread name; overload if needed.
 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

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 String getThreadName()
Defines the thread name; overload if needed.

Returns:
the name of the js executor thread

getJobManagerWithEarliestJob

protected JavaScriptJobManager getJobManagerWithEarliestJob()
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.

Specified by:
pumpEventLoop in interface JavaScriptExecutor
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.

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


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