Top Description Methods
org.osgi.util.pushstream

public Interface SimplePushEventSource<T>

extends PushEventSource<T>, AutoCloseable
Known Direct Implementers
org.osgi.util.pushstream.SimplePushEventSourceImpl
Annotations
@ProviderType
Type Parameters
<T>
The type of the events produced by this source
Imports
org.osgi.annotation.versioning.ProviderType, org.osgi.util.promise.Promise

A SimplePushEventSource is a helper that makes it simpler to write a PushEventSource. Users do not need to manage multiple registrations to the stream, nor do they have to be concerned with back pressure.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Redeclares java.lang.AutoCloseable.close.

Close this source.

public Promise<Void>

Returns:

A promise representing the connection state of this EventSource
connectPromise
()

This method can be used to delay event generation until an event source has connected.

public void
endOfStream()

Close this source for now, but potentially reopen it later.

public void
error(Throwable
the error
t
)

Close this source for now, but potentially reopen it later.

public boolean

Returns:

true if any consumers are currently connected
isConnected
()

Determine whether there are any PushEventConsumers for this PushEventSource.

public void
publish(T t)

Asynchronously publish an event to this stream and all connected PushEventConsumer instances.

Inherited from org.osgi.util.pushstream.PushEventSource:
open

Method Detail

closeback to summary
public void close()

Redeclares java.lang.AutoCloseable.close.

Close this source. Calling this method indicates that there will never be any more events published by it. Calling this method sends a close event to all connected consumers. After calling this method any PushEventConsumer that tries to open(PushEventConsumer) this source will immediately receive a close event, and will not see any remaining buffered events.

Annotations
@Override
connectPromiseback to summary
public Promise<Void> connectPromise()

This method can be used to delay event generation until an event source has connected. The returned promise will resolve as soon as one or more PushEventConsumer instances have opened the SimplePushEventSource.

The returned promise may already be resolved if this SimplePushEventSource already has connected consumers. If the SimplePushEventSource is closed before the returned Promise resolves then it will be failed with an IllegalStateException.

Note that the connected consumers are able to asynchronously close their connections to this SimplePushEventSource, and therefore it is possible that once the promise resolves this SimplePushEventSource may no longer be connected to any consumers.

Returns:Promise<Void>

A promise representing the connection state of this EventSource

endOfStreamback to summary
public void endOfStream()

Close this source for now, but potentially reopen it later. Calling this method asynchronously sends a close event to all connected consumers and then disconnects them. Any events previously queued by the publish(Object) method will be delivered before this close event.

After calling this method any PushEventConsumer that wishes may open(PushEventConsumer) this source, and will receive subsequent events.

errorback to summary
public void error(Throwable t)

Close this source for now, but potentially reopen it later. Calling this method asynchronously sends an error event to all connected consumers and then disconnects them. Any events previously queued by the publish(Object) method will be delivered before this error event.

After calling this method any PushEventConsumer that wishes may open(PushEventConsumer) this source, and will receive subsequent events.

Parameters
t:Throwable

the error

isConnectedback to summary
public boolean isConnected()

Determine whether there are any PushEventConsumers for this PushEventSource. This can be used to skip expensive event creation logic when there are no listeners.

Returns:boolean

true if any consumers are currently connected

publishback to summary
public void publish(T t)

Asynchronously publish an event to this stream and all connected PushEventConsumer instances. When this method returns there is no guarantee that all consumers have been notified. Events published by a single thread will maintain their relative ordering, however they may be interleaved with events from other threads.

Exceptions
IllegalStateException:
if the source is closed