public abstract class CachedTopicLoader extends SimpleTopicLoader
The first time load
is
called then SimpleTopicLoader.populateMessage(TopicMessage)
is called to generate a
message and send to the client in the same way as the superclass but the
message is then cached and on subsequent calls the same message will be sent
to the client. At any time the setDirty()
method may be called to
force regeneration of the message on the next load call.
This simple cached Topic loader only supports caching for a single topic. A single instance should not be used for more than one topic. When adding it to a publisher a selector pattern that matches more then one topic should not be used.
Constructor and Description |
---|
CachedTopicLoader() |
Modifier and Type | Method and Description |
---|---|
TopicMessage |
getTopicStateMessage(Topic topic)
Get the current state of the Topic
|
boolean |
load(TopicClient client,
Topic topic)
Cached Topic load implementation.
|
void |
setDirty()
Set the loader as dirty
This method will make sure that the populateMessage is called
|
populateMessage
public boolean load(TopicClient client, Topic topic) throws APIException
The first time this is called then SimpleTopicLoader.populateMessage(TopicMessage)
is called to generate a message and send to the client in the same way as
the superclass but the message is then cached and on subsequent calls the
same message will be sent to the client. At any time the
setDirty()
method may be called to force regeneration of the
message on the next call.
load
in interface TopicLoader
load
in class SimpleTopicLoader
client
- the Client.topic
- the Topic.APIException
- reports failure to load.SimpleTopicLoader.load(com.pushtechnology.diffusion.api.topic.TopicClient,
com.pushtechnology.diffusion.api.topic.Topic)
public final void setDirty()
public TopicMessage getTopicStateMessage(Topic topic) throws APIException
topic
- the TopicAPIException
- if unable to generate load messageCopyright © 2016 Push Technology Ltd. All Rights Reserved.