public static class Sink.Config.Builder
extends java.lang.Object
Sink.Config with
the given parameters. The Builder's constructor contains the parameters that are required in order to construct a Sink.Config.
All other parameters are optional. However, at least one of setTopologyListener(org.opendof.datatransfer.sink.TopologyListener), setValueSetListener(org.opendof.datatransfer.sink.ValueSetListener) or
setEventListener(org.opendof.datatransfer.sink.EventListener) must be called with a non-null listener.| Constructor and Description |
|---|
Builder(org.opendof.core.oal.DOFSystem system,
org.opendof.core.oal.DOFObjectID sinkID,
org.opendof.datatransfer.StatusListener listener)
Constructs a new builder.
|
| Modifier and Type | Method and Description |
|---|---|
Sink.Config |
build()
Constructs and returns a
Sink.Config that contains all of the configuration parameters set in this Builder. |
static org.opendof.core.oal.DOFObjectID |
generateInstanceID()
Creates a unique instance ID using a randomly generated GUID.
|
Sink.Config.Builder |
setEventListener(EventListener listener)
Sets an optional
EventListener. |
Sink.Config.Builder |
setInstanceID(org.opendof.core.oal.DOFObjectID instanceID)
Set the unique instance identifier for the sink.
|
Sink.Config.Builder |
setOperationTimeout(int operationTimeout)
Set the timeout for networked Sink operations.
|
Sink.Config.Builder |
setThreadpoolSize(int size)
Sets the size of the sink's threadpool.
|
Sink.Config.Builder |
setTopologyListener(TopologyListener listener)
Sets an optional
TopologyListener. |
Sink.Config.Builder |
setValueSetListener(ValueSetListener listener)
Sets an optional
ValueSetListener. |
public Builder(org.opendof.core.oal.DOFSystem system,
org.opendof.core.oal.DOFObjectID sinkID,
org.opendof.datatransfer.StatusListener listener)
system - The DOFSystem instance allowing this class to use OpenDOF to facilitate network communications.
This must not be null.sinkID - The ID of the sink. If multiple, related instances use the same base ID then a unique
instance ID should be added to the sinkID. This can either be done by passing in a sinkID with
an added Provider attribute, or by calling setInstanceID(DOFObjectID) with an appropriate
unique instanceID.listener - The StatusListener for the sink. This must not be null.public static org.opendof.core.oal.DOFObjectID generateInstanceID()
setInstanceID(DOFObjectID) in order to uniquely identify a sink instance.public Sink.Config.Builder setThreadpoolSize(int size)
size - The size of the API's callback threadpool. Defaults to 10. Must be greater than 0 and less than 500.public Sink.Config.Builder setTopologyListener(TopologyListener listener)
TopologyListener. When set, topology changes will be sent to sinks created using this configuration.
By default, topology changes are not sent.
Calling this method multiple times causes the listener provided in the last call to be used.listener - The TopologyListener to use. If null, topology changes are not sent.public Sink.Config.Builder setValueSetListener(ValueSetListener listener)
ValueSetListener. When set, ValueSets sent from sources to sinks created using this configuration
will be delivered through the given ValueSetListener. This also includes ValueSets requested through the
Sink.requestValues(org.opendof.core.oal.DOFObjectID, long, org.opendof.core.oal.DOFObjectID, org.opendof.core.oal.DOFInterfaceID, int, java.util.Date, int, int) method. If not set, ValueSets sent to sinks created using this configuration will be
acknowledged, but immediately dropped.
Calling this method multiple times causes the listener provided in the last call to be used.listener - The ValueSetListener to use. If null, full-resolution data is not sent.public Sink.Config.Builder setEventListener(EventListener listener)
EventListener. When set, events will be sent to sinks created using this configuration.
If not set, events sent to sinks created using this configuration will be acknowledged, but immediately dropped.
Calling this method multiple times causes the listener provided in the last call to be used.listener - The EventListener to use. If null, events are not sent.public Sink.Config.Builder setInstanceID(org.opendof.core.oal.DOFObjectID instanceID)
generateInstanceID() may be used to create a unique instanceID using a randomly generated GUID.instanceID - The unique instance identifier for the sink.public Sink.Config.Builder setOperationTimeout(int operationTimeout)
operationTimeout - The timeout, in milliseconds, for networked Sink operations. operationTimeout defaults to
2 minutes if this method is not called. Must be greater than 0.public Sink.Config build() throws java.lang.Exception
Sink.Config that contains all of the configuration parameters set in this Builder.java.lang.Exception - Thrown if a valid Config cannot be constructed.