Class DefaultJavaScriptExecutor
- java.lang.Object
-
- org.htmlunit.javascript.background.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 Summary
Fields Modifier and Type Field Description private java.lang.ThreadeventLoopThread_private java.util.List<java.lang.ref.WeakReference<JavaScriptJobManager>>jobManagerList_private static org.apache.commons.logging.LogLOGLogging support.private java.util.concurrent.atomic.AtomicBooleanshutdown_private java.lang.ref.WeakReference<WebClient>webClient_
-
Constructor Summary
Constructors Constructor Description DefaultJavaScriptExecutor(WebClient webClient)Creates an EventLoop for the webClient.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddWindow(WebWindow newWindow)Register a window with the eventLoop.protected JavaScriptJobManagergetJobManagerWithEarliestJob()Returns the JobExecutor corresponding to the earliest job.protected java.lang.StringgetThreadName()Defines the thread name; overload if needed.private voidkillThread()voidrun()Runs the eventLoop.voidshutdown()Notes that this thread has been shutdown.protected voidstartThreadIfNeeded()Starts the eventLoopThread_.private voidupdateJobMangerList(JavaScriptJobManager newJobManager)
-
-
-
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:
runin interfacejava.lang.Runnable
-
addWindow
public void addWindow(WebWindow newWindow)
Register a window with the eventLoop.- Specified by:
addWindowin interfaceJavaScriptExecutor- Parameters:
newWindow- the new web window
-
updateJobMangerList
private void updateJobMangerList(JavaScriptJobManager newJobManager)
-
shutdown
public void shutdown()
Notes that this thread has been shutdown.- Specified by:
shutdownin interfaceJavaScriptExecutor
-
-