public abstract class TopicsContext extends Object
TopicsContext is a per-application singleton tracking all registered topics.
It is erroneous to communicate with the Topic not registered via TopicsContext.
Application developer obtains instance of TopicsContext via static lookup() method.
When TopicsContext is being looked up for the first time, it triggers creation of PushContext
via
PushContextFactory
that is configured as RichFaces service.
Constructor and Description |
---|
TopicsContext() |
Modifier and Type | Method and Description |
---|---|
protected abstract Topic |
createTopic(TopicKey key)
Creates topic for given topic key
|
Topic |
getOrCreateTopic(TopicKey key)
Creates topic for given key or returns existing one when it was already created.
|
Topic |
getTopic(TopicKey key)
Returns topic for given key or null if no such topic was created yet.
|
protected TopicKey |
getTopicKeyWithResolvedExpressions(TopicKey key) |
static TopicsContext |
lookup()
Look-ups per-application singleton of
TopicsContext tracking all registered topics. |
void |
publish(TopicKey key,
Object data)
Publishes data through the topic with given key.
|
void |
removeTopic(TopicKey key)
Removes topic with given key or does nothing when no such topic was created yet.
|
public Topic getOrCreateTopic(TopicKey key)
Creates topic for given key or returns existing one when it was already created.
This method is thread-safe.
public Topic getTopic(TopicKey key)
public void removeTopic(TopicKey key)
public void publish(TopicKey key, Object data) throws MessageException
Publishes data through the topic with given key.
The provided topic key can contain expressions as the name of topic or its subtopic. In such case, the topic name or subtopic name will be first evaluated, which will form actual topic key that will be used to publish a message.
MessageException
- when topic with given key fails to publish given data object.public static TopicsContext lookup()
TopicsContext
tracking all registered topics.Copyright © 2014 JBoss by Red Hat. All Rights Reserved.