Package org.glassfish.hk2.api.messaging
Interface Topic<T>
- Type Parameters:
T
- The type of event to be distributed to subscribers
- All Known Implementing Classes:
TopicImpl
public interface Topic<T>
This service is used for publishing events to subscribers. The type of the Topic is
the type of event that will be distributed
-
Method Summary
Modifier and TypeMethodDescriptionThe qualifiers associated with this Topic.Gets the type of the topic, in order to match the message to subscribersReturns an Topic that is further qualified with the given name<U> Topic
<U> Returns an Topic that is of the given type.void
Publishes a message to all subscribersqualifiedWith
(Annotation... qualifiers) A set of qualifiers to further restrict this Topic to.
-
Method Details
-
publish
Publishes a message to all subscribers- Parameters:
message
- The non-null message to send to all current subscribers- Throws:
IllegalStateException
- If there is no implementation ofTopicDistributionService
to do the distribution of the message
-
named
Returns an Topic that is further qualified with the given name- Parameters:
name
- The value field of the Named annotation parameter. Must not be null- Returns:
- A topic further qualified with the given name
-
ofType
Returns an Topic that is of the given type. This type must be more specific than the type of this Topic- Parameters:
type
- The type to restrict the returned Topic to- Returns:
- A Topic restricted to only producing messages of the given type
-
qualifiedWith
A set of qualifiers to further restrict this Topic to.- Parameters:
qualifiers
- The qualifiers to further restrict this Topic to- Returns:
- An Topic restricted with the given qualifiers
-
getTopicType
Type getTopicType()Gets the type of the topic, in order to match the message to subscribers- Returns:
- the Type of this topic. Will not return null
-
getTopicQualifiers
Set<Annotation> getTopicQualifiers()The qualifiers associated with this Topic. Messages should only be distributed to subscribers that have matching qualifiers- Returns:
- the non-null but possibly empty set of qualifiers associated with this Topic
-