public abstract class WebPoller
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
WebPoller.Factory |
| Modifier | Constructor and Description |
|---|---|
protected |
WebPoller(EventBus eventBus) |
| Modifier and Type | Method and Description |
|---|---|
HandlerRegistration |
addErrorHandler(ErrorEvent.Handler handler) |
HandlerRegistration |
addMessageHandler(MessageEvent.Handler handler) |
HandlerRegistration |
addStartHandler(StartEvent.Handler handler) |
HandlerRegistration |
addStopHandler(StopEvent.Handler handler) |
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() |
protected EventBus |
getEventBus() |
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 |
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 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 final EventBus getEventBus()
protected void doStop()
protected void doStart()
protected final void onEmptyPollResult()
@Nonnull
public final HandlerRegistration addStartHandler(@Nonnull
StartEvent.Handler handler)
@Nonnull
public final HandlerRegistration addStopHandler(@Nonnull
StopEvent.Handler handler)
@Nonnull
public final HandlerRegistration addMessageHandler(@Nonnull
MessageEvent.Handler handler)
@Nonnull
public final HandlerRegistration addErrorHandler(@Nonnull
ErrorEvent.Handler handler)
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()