public interface TopicData
This represents thread-safe data that can be associated with a Topic
to represent the state of that Topic.
Different types
of data are supported and empty
instances of the data may be created using TopicDataFactory
.
Topic Data must be associated with the Topic when the Topic is created using
TopicProvider.addTopic(String, TopicData)
. Topic Data can not be used with Topics that are registered via entries in
Publishers.xml.
A Topic Load representing the current state may be obtained at any time using
getLoadMessage()
. The load message will be sent automatically
to each Client that subscribes to the Topic.
The majority of data types are publishing
and may be
cast to PublishingTopicData
to provide an updating and publishing
framework. The Topic
has convenience methods to determine whether it
has publishing data
and to
get the data
.
Another significant type of data is command data
which
provides command based functionality (depending upon subtype) but does not
provide data.
Modifier and Type | Method and Description |
---|---|
Encoding |
getDeltaEncoding()
Deprecated.
since 5.5 can be obtained from
getTopic() .
getDefinition() |
Encoding |
getLoadEncoding()
Deprecated.
since 5.5 can be obtained from
getTopic() .
getDefinition() |
TopicMessage |
getLoadMessage()
This returns the current data state as a Topic Load message.
|
TopicMessage |
getLoadMessage(TopicClient client)
This returns the current data state as a Topic Load message.
|
Topic |
getTopic()
Returns the Topic that the data belongs to.
|
TopicDataType |
getType()
Returns the type of Topic Data.
|
boolean |
hasSubscribers()
Deprecated.
since 5.5 use
getTopic() .
hasSubscribers() |
boolean |
isCommand()
Deprecated.
since 5.5 use instanceof
CommandTopicData |
boolean |
isLockedByCurrentThread()
Deprecated.
since 5.5. All API topic locking methods are deprecated and
will be removed in a future release, see
lock() for
details. |
boolean |
isPaged()
Deprecated.
since 5.5 use instanceof
PagedTopicData |
boolean |
isPublishing()
Deprecated.
since 5.5 use instanceof
PublishingTopicData |
boolean |
isRouting()
Deprecated.
since 5.5 use instanceof
RoutingTopicData |
boolean |
isService()
Deprecated.
since 5.5 use instanceof
ServiceTopicData |
void |
lock()
Deprecated.
since 5.5. All API topic locking methods are deprecated and
will be removed in a future release. There is no reason for
applications to lock topics with topic data. Multiple updates
to topic data can be grouped using
PublishingTopicData.startUpdate() /
PublishingTopicData.endUpdate() . |
void |
setDeltaEncoding(Encoding encoding)
Deprecated.
since 5.5 if non default encoding required then create topic
using a
TopicDefinition |
void |
setLoadEncoding(Encoding encoding)
Deprecated.
since 5.5 if non default encoding required then create topic
using a
TopicDefinition |
void |
unlock()
Deprecated.
since 5.5. All API topic locking methods are deprecated and
will be removed in a future release, see
lock() for
details. |
TopicDataType getType()
There are many different types of Topic Data that perform different functions.
Topic getTopic()
TopicMessage getLoadMessage() throws TimeoutException, APIException
This may be used when a Client subscribes to return the current state.
This may only be called after the data has been (optionally initialised and) associated with a Topic.
A Topic Load Message is cached for repeat calls, so the returned message should not be changed in any way.
Whenever an update occurs the cached Topic Load Message is recreated.
The returned Message will be positioned at the start of the data ready for reading.
Types that maintain no state would return an empty load message.
Note that this method can not be used on routing
data
and therefore if there is any doubt whether routing data is in use
then it is always safer to use getLoadMessage(TopicClient)
.
TimeoutException
- if the lock timeout
period for the Topic has been exceeded whilst waiting to
obtain a lock on the dataAPIException
- if the data has not been attached to a Topic or
generation of a Topic Load Message failsTopicMessage getLoadMessage(TopicClient client) throws TimeoutException, APIException
This is a variant of getLoadMessage()
which must be used for
routing data
. If in doubt then this method may
always be used as the client will be ignored if not required.
This may be used when a Client subscribes to return the current state.
This may only be called after the data has been (optionally initialised and) associated with a Topic.
A Topic Load Message is cached for repeat calls, so the returned message should not be changed in any way.
Whenever an update occurs the cached Topic Load Message is recreated.
The returned Message will be positioned at the start of the data ready for reading.
Types that maintain no state would return an empty load message.
client
- the Client to return the state for. If the data does not
maintain different state per Client then this would be ignored.TimeoutException
- if the lock timeout
period for the Topic has been exceeded whilst waiting to
obtain a lock on the dataAPIException
- if the data has not been attached to a Topic or
generation of a Topic Load Message fails@Deprecated void setLoadEncoding(Encoding encoding)
TopicDefinition
This will cause all load messages (see getLoadMessage()
)
generated by this TopicData to have the specified encoding applied.
By default no encoding will be applied to load messages.
encoding
- the encoding value@Deprecated Encoding getLoadEncoding()
setLoadEncoding(Encoding)
) or
null if no encoding has been specified@Deprecated void setDeltaEncoding(Encoding encoding)
TopicDefinition
This will cause any delta messages generated by this TopicData to have the specified encoding applied.
By default no encoding will be applied to delta messages.
encoding
- the encoding value@Deprecated Encoding getDeltaEncoding()
setDeltaEncoding(Encoding)
) or
null if no encoding has been specified@Deprecated boolean isPublishing()
PublishingTopicData
PublishingTopicData
.@Deprecated boolean isCommand()
CommandTopicData
CommandTopicData
.@Deprecated boolean isService()
ServiceTopicData
ServiceTopicData
.@Deprecated boolean isPaged()
PagedTopicData
PagedTopicData
.@Deprecated boolean isRouting()
RoutingTopicData
RoutingTopicData
.@Deprecated boolean hasSubscribers()
Since 5.5, the behavior for slave topic data has changed. This method
will only return true if there are direct subscriptions to the slave,
regardless of subscriptions to the master. This matches
Topic.hasSubscribers()
, which should be preferred.
@Deprecated void lock() throws TimeoutException
PublishingTopicData.startUpdate()
/
PublishingTopicData.endUpdate()
.TimeoutException
- if timeout expired before acquiring the lockTopic.lock()
@Deprecated void unlock()
lock()
for
details.Topic.unlock()
@Deprecated boolean isLockedByCurrentThread()
lock()
for
details.Topic.isLockedByCurrentThread()
Copyright © 2016 Push Technology Ltd. All Rights Reserved.