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- Author:
- jwells
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Set<Annotation>
getTopicQualifiers()
The qualifiers associated with this Topic.Type
getTopicType()
Gets the type of the topic, in order to match the message to subscribersTopic<T>
named(String name)
Returns an Topic that is further qualified with the given name<U> Topic<U>
ofType(Type type)
Returns an Topic that is of the given type.void
publish(T message)
Publishes a message to all subscribersTopic<T>
qualifiedWith(Annotation... qualifiers)
A set of qualifiers to further restrict this Topic to.
-
-
-
Method Detail
-
publish
void publish(T message)
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
Topic<T> named(String name)
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
<U> Topic<U> ofType(Type type)
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
Topic<T> qualifiedWith(Annotation... qualifiers)
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
-
-