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.Thread
eventLoopThread_
private java.util.List<java.lang.ref.WeakReference<JavaScriptJobManager>>
jobManagerList_
private static org.apache.commons.logging.Log
LOG
Logging support.private java.util.concurrent.atomic.AtomicBoolean
shutdown_
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 void
addWindow(WebWindow newWindow)
Register a window with the eventLoop.protected JavaScriptJobManager
getJobManagerWithEarliestJob()
Returns the JobExecutor corresponding to the earliest job.protected java.lang.String
getThreadName()
Defines the thread name; overload if needed.private void
killThread()
void
run()
Runs the eventLoop.void
shutdown()
Notes that this thread has been shutdown.protected void
startThreadIfNeeded()
Starts the eventLoopThread_.private void
updateJobMangerList(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:
run
in interfacejava.lang.Runnable
-
addWindow
public void addWindow(WebWindow newWindow)
Register a window with the eventLoop.- Specified by:
addWindow
in 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:
shutdown
in interfaceJavaScriptExecutor
-
-