Skip to content

Commit

Permalink
Clarifies deprecation in SinkProvider and SseSinkProvider.
Browse files Browse the repository at this point in the history
Signed-off-by: Santiago Pericas-Geertsen <[email protected]>
  • Loading branch information
spericas committed Aug 30, 2024
1 parent 3a48788 commit 9e3cd89
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

/**
* Sink provider for SSE type.
*
* @see io.helidon.webserver.http.spi.SinkProvider
*/
public class SseSinkProvider implements SinkProvider<SseEvent> {

Expand All @@ -38,13 +40,29 @@ public boolean supports(GenericType<? extends Sink<?>> type, ServerRequest reque
return SseSink.TYPE.equals(type) && request.headers().isAccepted(MediaTypes.TEXT_EVENT_STREAM);
}


/**
* Creates a Sink for SSE events.
*
* @param context the context
* @return newly created sink
* @param <X> type of sink
*/
@Override
@SuppressWarnings("unchecked")
public <X extends Sink<SseEvent>> X create(SinkProviderContext context) {
return (X) new SseSink(context);
}

/**
* Creates a Sink for SSE events.
*
* @param response the HTTP response
* @param eventConsumer an event consumer
* @param closeRunnable a runnable to call on close
* @param <X> type of sink
* @return newly created sink
* @deprecated replaced by {@link #create(SinkProviderContext)}
*/
@Override
public <X extends Sink<SseEvent>> X create(ServerResponse response,
BiConsumer<Object, MediaType> eventConsumer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,26 @@ public interface SinkProvider<T> {
/**
* Creates a sink using this provider.
*
* @param response the HTTP response
* @param eventConsumer an event consumer
* @param closeRunnable a runnable to call on close
* @param context a context for a sync provider
* @param <X> type of sink
* @return newly created sink
* @deprecated Replaced by {@link #create(SinkProviderContext)}
*/
@Deprecated(forRemoval = true, since = "4.1.2")
<X extends Sink<T>> X create(ServerResponse response,
BiConsumer<Object, MediaType> eventConsumer,
Runnable closeRunnable);
default <X extends Sink<T>> X create(SinkProviderContext context) {
throw new UnsupportedOperationException("Not implemented");
}

/**
* Creates a sink using this provider.
*
* @param context a context for a sync provider
* @param response the HTTP response
* @param eventConsumer an event consumer
* @param closeRunnable a runnable to call on close
* @param <X> type of sink
* @return newly created sink
* @deprecated replaced by {@link #create(SinkProviderContext)}
*/
default <X extends Sink<T>> X create(SinkProviderContext context) {
throw new UnsupportedOperationException("Not implemented");
}
@Deprecated(forRemoval = true, since = "4.1.2")
<X extends Sink<T>> X create(ServerResponse response,
BiConsumer<Object, MediaType> eventConsumer,
Runnable closeRunnable);
}

0 comments on commit 9e3cd89

Please sign in to comment.