org.richfaces.application.push

## Class TopicsContext

- java.lang.Object
- - org.richfaces.application.push.TopicsContext

- Direct Known Subclasses:
    TopicsContextImpl

      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.

  Author:
    Nick Belaevski

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TopicsContext()`

  - ### Method Summary

    Methods
    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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### TopicsContext

          public TopicsContext()

  - ### Method Detail

    - #### createTopic

          protected abstract Topic createTopic(TopicKey key)

      Creates topic for given topic key

    - #### getOrCreateTopic

          public Topic getOrCreateTopic(TopicKey key)

      Creates topic for given key or returns existing one when it was already created.

      This method is thread-safe.

    - #### getTopic

          public Topic getTopic(TopicKey key)

      Returns topic for given key or null if no such topic was created yet.

    - #### removeTopic

          public void removeTopic(TopicKey key)

      Removes topic with given key or does nothing when no such topic was created yet.

    - #### publish

          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.

      Throws:
        `MessageException` - when topic with given key fails to publish given data object.

    - #### lookup

          public static TopicsContext lookup()

      Look-ups per-application singleton of `TopicsContext` tracking all registered topics.

    - #### getTopicKeyWithResolvedExpressions

          protected TopicKey getTopicKeyWithResolvedExpressions(TopicKey key)

Copyright © 2015 JBoss by Red Hat. All Rights Reserved.