Class AbstractBindingHarness
- java.lang.Object
-
- com.inductiveautomation.perspective.gateway.model.AbstractBindingHarness
-
- All Implemented Interfaces:
AuditingContext
,BindingContext
,LoggingContext
- Direct Known Subclasses:
ElementBindingHarness
public abstract class AbstractBindingHarness extends java.lang.Object implements BindingContext
Wraps up the logic of creating bindings and transform chains, and linking up the values as they get created, eventually making their way back onto the target property.
-
-
Field Summary
Fields Modifier and Type Field Description protected Binding
binding
protected boolean
shutdown
protected PerspectiveElement
targetComponent
protected PropertyKey
targetProperty
protected Transform[]
transforms
List of transforms or null if no transforms (never empty)protected java.lang.String
typeCode
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description AuditContext.Builder
getAuditSnapshot()
QualifiedValue
getLastValue()
LoggerEx
getLogger()
LoggingContext
getMdcParent()
PerspectiveElement
getTargetElement()
PropertyKey
getTargetProperty()
void
mdcSetup()
Set up the MDC keys for this contextvoid
mdcTeardown()
Tear down the MDC keys that are added in #mdcSetupprotected void
onBindingProducedValue(long sequence, QualifiedValue value)
protected void
onTransformProducedValue(int transformIndex, long sequence, QualifiedValue transformedValue)
void
processPublishedValue()
Takes the most recently published value from the binding and runs it through the transforms or delivers it to the target if there are no transforms.void
publish(QualifiedValue value, boolean pending)
Called from the binding when it has a value to push onto the target property ( or through its transforms )void
refresh()
void
shutdown()
Must be called on-queuevoid
startup()
Must be called on-queueprotected abstract java.lang.Runnable
subscribeToTarget(java.util.function.Consumer<PropertyTreeChangeEvent> callback)
Attempt to subscribe to the target property.protected abstract void
writeToTarget(QualifiedValue value)
Write the given value to the target property.-
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.AuditingContext
audit
-
Methods inherited from interface com.inductiveautomation.perspective.gateway.api.BindingContext
getAuditProfile, getExecutorService, getScheduler, getSession, publish
-
Methods inherited from interface com.inductiveautomation.perspective.gateway.api.LoggingContext
mdc, mdcSetupTree, mdcTeardownTree, mdcWrap
-
-
-
-
Field Detail
-
typeCode
protected final java.lang.String typeCode
-
binding
protected final Binding binding
-
targetComponent
protected final PerspectiveElement targetComponent
-
targetProperty
protected final PropertyKey targetProperty
-
transforms
@Nullable protected final Transform[] transforms
List of transforms or null if no transforms (never empty)
-
shutdown
protected boolean shutdown
-
-
Method Detail
-
getTargetElement
public PerspectiveElement getTargetElement()
- Specified by:
getTargetElement
in interfaceBindingContext
-
getLogger
public LoggerEx getLogger()
- Specified by:
getLogger
in interfaceLoggingContext
-
getMdcParent
@Nullable public LoggingContext getMdcParent()
- Specified by:
getMdcParent
in interfaceLoggingContext
-
mdcSetup
public void mdcSetup()
Description copied from interface:LoggingContext
Set up the MDC keys for this context- Specified by:
mdcSetup
in interfaceLoggingContext
-
mdcTeardown
public void mdcTeardown()
Description copied from interface:LoggingContext
Tear down the MDC keys that are added in #mdcSetup- Specified by:
mdcTeardown
in interfaceLoggingContext
-
getTargetProperty
public PropertyKey getTargetProperty()
- Specified by:
getTargetProperty
in interfaceBindingContext
-
startup
public void startup()
Must be called on-queue
-
subscribeToTarget
@Nullable protected abstract java.lang.Runnable subscribeToTarget(java.util.function.Consumer<PropertyTreeChangeEvent> callback)
Attempt to subscribe to the target property.- Parameters:
callback
- When the target property changes, call this consumer and give it a way to fetch the new value- Returns:
- A runnable which when called will tear down the subscription. May be null if the subscription wasn't able to be established.
-
shutdown
public void shutdown()
Must be called on-queue
-
publish
public void publish(QualifiedValue value, boolean pending)
Description copied from interface:BindingContext
Called from the binding when it has a value to push onto the target property ( or through its transforms )- Specified by:
publish
in interfaceBindingContext
pending
- true if this value is temporary and will be replaced (within a reasonable span of time) with a new value
-
processPublishedValue
public void processPublishedValue()
Description copied from interface:BindingContext
Takes the most recently published value from the binding and runs it through the transforms or delivers it to the target if there are no transforms.- Specified by:
processPublishedValue
in interfaceBindingContext
-
getLastValue
public QualifiedValue getLastValue()
- Specified by:
getLastValue
in interfaceBindingContext
-
refresh
public void refresh()
-
onBindingProducedValue
protected void onBindingProducedValue(long sequence, QualifiedValue value)
-
onTransformProducedValue
protected void onTransformProducedValue(int transformIndex, long sequence, QualifiedValue transformedValue)
-
writeToTarget
protected abstract void writeToTarget(QualifiedValue value)
Write the given value to the target property.
-
getAuditSnapshot
@Nonnull public AuditContext.Builder getAuditSnapshot()
- Specified by:
getAuditSnapshot
in interfaceAuditingContext
- Returns:
- A new, or extended,
AuditContext.Builder
, with qualified information about the current scope.
-
-