Top Description Methods
org.glassfish.hk2.api.messaging

public Interface Topic<T>

Type Parameters
<T>
The type of event to be distributed to subscribers
Imports
java.lang.annotation.Annotation, java.lang.reflect.Type, java.util.Set

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

Modifier and TypeMethod and Description
public Set<Annotation>

Returns:

the non-null but possibly empty set of qualifiers associated with this Topic
getTopicQualifiers
()

The qualifiers associated with this Topic.

public Type

Returns:

the Type of this topic. Will not return null
getTopicType
()

Gets the type of the topic, in order to match the message to subscribers

public Topic<T>

Returns:

A topic further qualified with the given name
named
(String
The value field of the Named annotation parameter. Must not be null
name
)

Returns an Topic that is further qualified with the given name

public <U> Topic<U>

Returns:

A Topic restricted to only producing messages of the given type
ofType
(Type
The type to restrict the returned Topic to
type
)

Returns an Topic that is of the given type.

public void
publish(T
The non-null message to send to all current subscribers
message
)

Publishes a message to all subscribers

public Topic<T>

Returns:

An Topic restricted with the given qualifiers
qualifiedWith
(Annotation...
The qualifiers to further restrict this Topic to
qualifiers
)

A set of qualifiers to further restrict this Topic to.

Method Detail

getTopicQualifiersback to summary
public Set<Annotation> getTopicQualifiers()

The qualifiers associated with this Topic. Messages should only be distributed to subscribers that have matching qualifiers

Returns:Set<Annotation>

the non-null but possibly empty set of qualifiers associated with this Topic

getTopicTypeback to summary
public Type getTopicType()

Gets the type of the topic, in order to match the message to subscribers

Returns:Type

the Type of this topic. Will not return null

namedback to summary
public Topic<T> named(String name)

Returns an Topic that is further qualified with the given name

Parameters
name:String

The value field of the Named annotation parameter. Must not be null

Returns:Topic<T>

A topic further qualified with the given name

ofTypeback to summary
public <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:Type

The type to restrict the returned Topic to

Returns:Topic<U>

A Topic restricted to only producing messages of the given type

publishback to summary
public void publish(T message)

Publishes a message to all subscribers

Parameters
message:T

The non-null message to send to all current subscribers

Exceptions
IllegalStateException:
If there is no implementation of TopicDistributionService to do the distribution of the message
qualifiedWithback to summary
public Topic<T> qualifiedWith(Annotation... qualifiers)

A set of qualifiers to further restrict this Topic to.

Parameters
qualifiers:Annotation[]

The qualifiers to further restrict this Topic to

Returns:Topic<T>

An Topic restricted with the given qualifiers