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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.Set<java.lang.annotation.Annotation>getTopicQualifiers()The qualifiers associated with this Topic.java.lang.reflect.TypegetTopicType()Gets the type of the topic, in order to match the message to subscribersTopic<T>named(java.lang.String name)Returns an Topic that is further qualified with the given name<U> Topic<U>ofType(java.lang.reflect.Type type)Returns an Topic that is of the given type.voidpublish(T message)Publishes a message to all subscribersTopic<T>qualifiedWith(java.lang.annotation.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:
java.lang.IllegalStateException- If there is no implementation ofTopicDistributionServiceto do the distribution of the message
-
named
Topic<T> named(java.lang.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(java.lang.reflect.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(java.lang.annotation.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
java.lang.reflect.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
java.util.Set<java.lang.annotation.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
-
-