Class AbstractPollingBinding
- java.lang.Object
-
- com.inductiveautomation.perspective.gateway.binding.AbstractPollingBinding
-
- All Implemented Interfaces:
Binding
- Direct Known Subclasses:
HttpBinding
,QueryBinding
public abstract class AbstractPollingBinding extends java.lang.Object implements Binding
Abstract base class which takes care of executing bindings which have a polling option in a thread-safe manner. Also has a debouncing feature built in.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractPollingBinding.State
-
Field Summary
Fields Modifier and Type Field Description protected BindingContext
context
protected AbstractPollingBinding.State
state
-
Fields inherited from interface com.inductiveautomation.perspective.gateway.api.Binding
BAD_CONFIG, BAD_REF, BIDIRECTIONAL_KEY, INITIAL_VALUE, MDC_BINDING_TARGET, NOT_FOUND
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractPollingBinding(BindingContext bindingContext, java.lang.String pollingRateExpression)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract QualifiedValue
execute()
Perform the blocking execution of this polling binding.protected abstract boolean
isDirty()
If any dependencies of the implementation have changed, this method should return true, which will kick off another execution if dependencies have changed while the execution was running.protected abstract boolean
isReady()
Indicates whether or not the instance of the underlying implementation is ready for execution.void
onUserRefresh()
Called to prompt the binding to produce a value as soon as possible.protected void
preExecutionPrep()
This method will be called beforeexecute()
is called to give implementations the opportunity to prepare any data before execution begins.protected void
scheduleNow()
Schedule the next execution immediately.void
shutdown()
Shut down the binding.void
startup()
Start up the binding.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.inductiveautomation.perspective.gateway.api.Binding
isBidirectional, onTargetUpdated
-
-
-
-
Field Detail
-
context
protected final BindingContext context
-
state
protected volatile AbstractPollingBinding.State state
-
-
Constructor Detail
-
AbstractPollingBinding
protected AbstractPollingBinding(@Nonnull BindingContext bindingContext, @Nullable java.lang.String pollingRateExpression) throws ConfigurationException
- Throws:
ConfigurationException
-
-
Method Detail
-
startup
public void startup()
Description copied from interface:Binding
Start up the binding. Will be called on-queue
-
shutdown
public void shutdown()
Description copied from interface:Binding
Shut down the binding. Will be called on-queue
-
isReady
protected abstract boolean isReady()
Indicates whether or not the instance of the underlying implementation is ready for execution.
-
isDirty
protected abstract boolean isDirty()
If any dependencies of the implementation have changed, this method should return true, which will kick off another execution if dependencies have changed while the execution was running.
-
execute
protected abstract QualifiedValue execute() throws java.lang.Exception
Perform the blocking execution of this polling binding. This should always execute on the _executor service_- Returns:
- The resulting
QualifiedValue
from the binding execution - Throws:
java.lang.Exception
- If there is a problem executing the binding
-
preExecutionPrep
protected void preExecutionPrep()
This method will be called beforeexecute()
is called to give implementations the opportunity to prepare any data before execution begins. This method will be called within a synchronized block holding this lock.
-
scheduleNow
protected void scheduleNow()
Schedule the next execution immediately. This method is debounced.
-
onUserRefresh
public void onUserRefresh()
Description copied from interface:Binding
Called to prompt the binding to produce a value as soon as possible. This _not_ the normal way that bindings work. Bindings are expected to produce a value un-prompted after startup, and then again whenever they feel is appropriate. This is there to allow the user to call component.refreshBinding(property) and prompt a non-polling binding to run.- Specified by:
onUserRefresh
in interfaceBinding
-
-