public interface SingleValueTopicData extends PublishingTopicData
The advantage of using such Topic data rather than simply attaching an object to the Topic is that the Topic data handles data locking, Topic Load caching and automated publishing of changes in a similar way to other forms of Topic Data.
A number of different data types are supported (as defined by
MDataType
) including custom data where the handling of the data is
user defined.
An instance of this type of data can be created using
TopicDataFactory.newSingleValueData(MField)
.
The initial value of such a data object will be set according to the data
type but may be explicitly set using initialise(Object)
before
creating the Topic.
To update the value within a standard update block the
update(Object)
method can be used. A simpler mechanism is to use the
updateAndPublish(Object)
method which will update the value and
publish a delta to all subscribed Clients if (and only if) the value has
changed.
The type of object specified when updating may be any type that can be parsed
for the data type
.
Modifier and Type | Method and Description |
---|---|
MDataType |
getDataType()
Returns the data type of the encapsulated value.
|
MField |
getMetadata()
Metadata Field describing the TopicData.
|
Object |
getValue()
Returns the current value of the data.
|
void |
initialise(Object value)
Initialises the data to a specified value.
|
boolean |
update(Object value)
Updates the data from a object.
|
boolean |
updateAndPublish(Object value)
As
PublishingTopicData.updateAndPublish(com.pushtechnology.diffusion.api.message.TopicMessage)
but calling update(Object) to perform the updating. |
abortUpdate, addListener, asString, endUpdate, generateAckDeltaMessage, generateDeltaMessage, getInitialiser, getLastUpdateTimeMillis, getLoadHeaders, getLoadMessage, hasChanges, hasSlaves, initialise, isDeltaAckRequired, isLoadAckRequired, isSlave, publishExclusiveMessage, publishExclusiveMessage, publishMessage, publishMessage, removeListener, setDeltaAckRequired, setInitialiser, setLoadAckRequired, setLoadHeaders, startUpdate, update, updateAndPublish, updateAndPublish, updateAndPublishFromDelta
getDeltaEncoding, getLoadEncoding, getLoadMessage, getTopic, getType, hasSubscribers, isCommand, isLockedByCurrentThread, isPaged, isPublishing, isRouting, isService, lock, setDeltaEncoding, setLoadEncoding, unlock
getMetadataNode, isMetadataMandatory, setMetadataNode
MDataType getDataType()
MField getMetadata()
This metadata can be tailored if required, for example to
allow empty values
.
void initialise(Object value) throws APIException
value
- the value which may be of any type that can be parsed
according to the data type
. Note that supplying a value
of null is the same as setting the data to the default value for the
type which is what the data would be initialised to anyway.APIException
- if unable to initialise the data.boolean update(Object value) throws APIException
This is similar to the
PublishingTopicData.update(com.pushtechnology.diffusion.api.message.TopicMessage)
method except that it updates by parsing from an input object rather than
from the content of a Message.
This may only be called from within an update block (see
PublishingTopicData.startUpdate()
).
value
- the object to update the data from. This object will be
parsed according to the data type
of the data.
Note that specifying a value of null is the same as setting the
data to the default value for the data type.APIException
- if unable to perform the update. After such an
exception the update can not continue and when
endUpdate
is called the data state will be
reverted to its state before startUpdate
was called.boolean updateAndPublish(Object value) throws TimeoutException, APIException
PublishingTopicData.updateAndPublish(com.pushtechnology.diffusion.api.message.TopicMessage)
but calling update(Object)
to perform the updating.value
- the object to parse the new value from according to the
data type
.TimeoutException
- if the lock
timeout
period for the Topic has been exceeded whilst waiting to
obtain a lock on the data.APIException
- if unable to perform the update or publish a delta.
If this occurs then the data will still be in the same state as
before the call.Copyright © 2016 Push Technology Ltd. All Rights Reserved.