Package org.htmlunit
Class NicelyResynchronizingAjaxController
java.lang.Object
org.htmlunit.AjaxController
org.htmlunit.NicelyResynchronizingAjaxController
- All Implemented Interfaces:
Serializable
This
AjaxController
resynchronizes calls calling from the main thread.
The idea is that asynchronous AJAX calls performed directly in response to a user
action (therefore in the "main" thread and not in the thread of a background task)
are directly useful for the user. To easily have a testable state, these calls
are performed synchronously.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.apache.commons.logging.Log
private WeakReference
<Thread> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
init()
Initializes this instance.(package private) boolean
Indicates if the currently executing thread is the one in which this instance has been created.boolean
processSynchron
(HtmlPage page, WebRequest settings, boolean async) Resynchronizes calls performed from the thread where this instance has been created.private void
readObject
(ObjectInputStream stream) Custom deserialization logic.
-
Field Details
-
LOG
private static final org.apache.commons.logging.Log LOG -
originatedThread_
-
-
Constructor Details
-
NicelyResynchronizingAjaxController
public NicelyResynchronizingAjaxController()Creates an instance.
-
-
Method Details
-
init
private void init()Initializes this instance. -
processSynchron
Resynchronizes calls performed from the thread where this instance has been created.Gets notified of an AJAX call to determine how it should be processed.
- Overrides:
processSynchron
in classAjaxController
- Parameters:
page
- the page the request comes fromsettings
- the request that should be performedasync
- indicates if the request should originally be asynchronous- Returns:
- if the call should be synchronous or not; here just like the original call
-
isInOriginalThread
boolean isInOriginalThread()Indicates if the currently executing thread is the one in which this instance has been created.- Returns:
true
if it's the same thread
-
readObject
Custom deserialization logic.- Parameters:
stream
- the stream from which to read the object- Throws:
IOException
- if an IO error occursClassNotFoundException
- if a class cannot be found
-