public abstract class WebPoller
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
WebPoller.Factory |
| Constructor and Description |
|---|
WebPoller() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
deregister(WebPoller.Factory factory) |
protected void |
doPoll()
Sub-classes should override to perform actual polling.
|
protected void |
doStart()
Sub-classes should override this method to provide functionality.
|
protected void |
doStop()
Sub-classes should override this method to provide functionality.
|
int |
getErrorCountThreshold() |
int |
getPollDuration() |
protected RequestContext |
getRequestContext() |
RequestFactory |
getRequestFactory() |
boolean |
inError() |
boolean |
isActive() |
protected boolean |
isInPoll() |
boolean |
isLongPoll() |
boolean |
isPaused() |
static WebPoller |
newWebPoller() |
protected void |
onEmptyPollResult()
Invoked after a successful poll returning no data.
|
protected void |
onError(java.lang.Throwable exception)
Fire an Error event.
|
protected void |
onMessage(java.util.Map<java.lang.String,java.lang.String> context,
java.lang.String data)
Fire a Message event.
|
protected void |
onStart()
Fire a Start event.
|
protected void |
onStop()
Fire a Stop event.
|
void |
pause()
Pause the active poller.
|
protected void |
poll()
Orchestrate the polling.
|
protected void |
pollReturned()
This should be invoked when the poll has completed.
|
static void |
register(WebPoller.Factory factory) |
void |
resume()
Resume an already paused poller.
|
void |
setErrorCountThreshold(int errorCountThreshold)
Set the number of errors before poller is stopped.
|
void |
setListener(WebPollerListener listener) |
void |
setLongPoll(boolean longPoll) |
void |
setPollDuration(int pollDuration) |
void |
setRequestFactory(RequestFactory requestFactory) |
void |
start()
Start polling.
|
void |
stop()
Stop polling.
|
public static WebPoller newWebPoller()
public static void register(@Nonnull
WebPoller.Factory factory)
public static boolean deregister(@Nonnull
WebPoller.Factory factory)
public boolean isActive()
public boolean inError()
public final void start()
throws java.lang.IllegalStateException
java.lang.IllegalStateException - if the poller is already active.public final void stop()
throws java.lang.IllegalStateException
java.lang.IllegalStateException - if the poller is not active.public void setRequestFactory(@Nullable
RequestFactory requestFactory)
public final RequestFactory getRequestFactory()
public final int getErrorCountThreshold()
public void setErrorCountThreshold(int errorCountThreshold)
public final int getPollDuration()
public final void setPollDuration(int pollDuration)
public final boolean isLongPoll()
public void setLongPoll(boolean longPoll)
throws java.lang.IllegalStateException
java.lang.IllegalStateExceptionpublic void setListener(@Nullable
WebPollerListener listener)
public void pause()
java.lang.IllegalStateException - if poller is not active or poller is already pausedpublic void resume()
java.lang.IllegalStateException - if poller is not active or poller is not paused.public boolean isPaused()
protected void doStop()
protected void doStart()
protected final void onEmptyPollResult()
protected final void onStart()
protected final void onStop()
protected final void onMessage(@Nonnull
java.util.Map<java.lang.String,java.lang.String> context,
@Nonnull
java.lang.String data)
protected final void onError(@Nonnull
java.lang.Throwable exception)
protected final boolean isInPoll()
protected void pollReturned()
protected final void poll()
protected final RequestContext getRequestContext()
protected void doPoll()