Class SseEventSource.Builder
- java.lang.Object
-
- javax.ws.rs.sse.SseEventSource.Builder
-
- Enclosing interface:
- SseEventSource
public abstract static class SseEventSource.Builder extends java.lang.ObjectSseEventSourcebuilder class.Event source builder provides methods that let you conveniently configure and subsequently build a new
SseEventSourceinstance. You can obtain a new event source builder instance using a staticSseEventSource.target(endpoint)factory method.For example:
SseEventSource es = SseEventSource.target(endpoint) .reconnectingEvery(5, SECONDS) .build(); es.register(System.out::println); es.open();
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringJAXRS_DEFAULT_SSE_BUILDERDefault SSE event source builder implementation class name.static java.lang.StringJAXRS_DEFAULT_SSE_BUILDER_PROPERTYName of the property identifying theSseEventSource.Builderimplementation to be returned fromnewBuilder().
-
Constructor Summary
Constructors Modifier Constructor Description protectedBuilder()Allows custom implementations to extend the SSE event source builder class.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract SseEventSourcebuild()Build new SSE event source pointing at a SSE streamingweb target.(package private) static SseEventSource.BuildernewBuilder()Create a new SSE event source instance using the default implementation class provided by the implementation provider.abstract SseEventSource.BuilderreconnectingEvery(long delay, java.util.concurrent.TimeUnit unit)Set the initial reconnect delay to be used by the event source.protected abstract SseEventSource.Buildertarget(WebTarget endpoint)
-
-
-
Field Detail
-
JAXRS_DEFAULT_SSE_BUILDER_PROPERTY
public static final java.lang.String JAXRS_DEFAULT_SSE_BUILDER_PROPERTY
Name of the property identifying theSseEventSource.Builderimplementation to be returned fromnewBuilder().- See Also:
- Constant Field Values
-
JAXRS_DEFAULT_SSE_BUILDER
private static final java.lang.String JAXRS_DEFAULT_SSE_BUILDER
Default SSE event source builder implementation class name.- See Also:
- Constant Field Values
-
-
Method Detail
-
newBuilder
static SseEventSource.Builder newBuilder()
Create a new SSE event source instance using the default implementation class provided by the implementation provider.- Returns:
- new SSE event source builder instance.
-
target
protected abstract SseEventSource.Builder target(WebTarget endpoint)
-
reconnectingEvery
public abstract SseEventSource.Builder reconnectingEvery(long delay, java.util.concurrent.TimeUnit unit)
Set the initial reconnect delay to be used by the event source.Note that this value may be later overridden by the SSE endpoint using either a
retrySSE event field orHTTP 503 + "Retry-After"mechanism as described in theSseEventSourcejavadoc.- Parameters:
delay- the default time to wait before attempting to recover from a connection loss.unit- time unit of the reconnect delay parameter.- Returns:
- updated event source builder instance.
-
build
public abstract SseEventSource build()
Build new SSE event source pointing at a SSE streamingweb target.The returned event source is ready, but not
connectedto the SSE endpoint. It is expected that you will manually invoke itsSseEventSource.open()method once you are ready to start receiving SSE events. In case you want to build an event source instance that is already connected to the SSE endpoint, use the event source builderSseEventSource.open()method instead.Once the event source is open, the incoming events are processed by the event source in an asynchronous task that runs in an internal single-threaded
scheduled executor service.- Returns:
- new event source instance, ready to be connected to the SSE endpoint.
- See Also:
SseEventSource.open()
-
-