Skip to content

Commit 2771f8f

Browse files
committed
format
1 parent 08c73ce commit 2771f8f

File tree

2 files changed

+25
-33
lines changed

2 files changed

+25
-33
lines changed
Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
package io.avaje.jex.http.sse;
22

3-
import java.io.Closeable;
4-
import java.util.function.Consumer;
5-
63
import io.avaje.jex.http.Context;
74
import io.avaje.jex.http.ExchangeHandler;
85
import io.avaje.jex.spi.JsonService;
6+
import java.io.Closeable;
7+
import java.util.function.Consumer;
98

109
/**
11-
* A client for Server-Sent Events (SSE). This class handles the setup of the SSE connection,
12-
* sending events and comments to the client, and managing the lifecycle of the connection. It
13-
* ensures proper headers are set and provides methods for sending various types of data.
10+
* A client for Server-Sent Events (SSE). This class handles the setup of the SSE connection, sending events and
11+
* comments to the client, and managing the lifecycle of the connection. It ensures proper headers are set and provides
12+
* methods for sending various types of data.
1413
*
15-
* <p>This class implements {@link Closeable} to allow for proper resource management. The
16-
* connection is automatically closed if the client disconnects or if an error occurs during event
17-
* emission.
14+
* <p>This class implements {@link Closeable} to allow for proper resource management. The connection is automatically
15+
* closed if the client disconnects or if an error occurs during event emission.
1816
*/
1917
public interface SseClient extends Closeable {
2018

@@ -35,23 +33,22 @@ static ExchangeHandler handler(Consumer<SseClient> consumer) {
3533
Context ctx();
3634

3735
/**
38-
* By blocking the SSE connection, you can share this client outside the handler to notify it from
39-
* other sources. Keep in mind that this function will block the handler until the SSE client is
40-
* released by another thread.
36+
* By blocking the SSE connection, you can share this client outside the handler to notify it from other sources.
37+
* Keep in mind that this function will block the handler until the SSE client is released by another thread.
4138
*/
4239
void keepAlive();
4340

4441
/**
45-
* Add a callback that will be called either when connection is closed through {@link #close()},
46-
* or when the {@link Emitter} is detected as closed.
42+
* Add a callback that will be called either when connection is closed through {@link #close()}, or when the
43+
* {@link Emitter} is detected as closed.
4744
*
4845
* @param task task to run
4946
*/
5047
void onClose(Runnable task);
5148

5249
/**
53-
* Attempt to send a comment. If the {@link Emitter} fails to emit (remote client has
54-
* disconnected), the {@link #close()} function will be called instead.
50+
* Attempt to send a comment. If the {@link Emitter} fails to emit (remote client has disconnected), the
51+
* {@link #close()} function will be called instead.
5552
*/
5653
void sendComment(String comment);
5754

@@ -62,19 +59,19 @@ static ExchangeHandler handler(Consumer<SseClient> consumer) {
6259
void sendEvent(String event, Object data);
6360

6461
/**
65-
* Attempt to send an event. If the {@link Emitter} fails to emit (remote client has
66-
* disconnected), the {@link #close()} function will be called instead.
62+
* Attempt to send an event. If the {@link Emitter} fails to emit (remote client has disconnected), the
63+
* {@link #close()} function will be called instead.
6764
*
6865
* @param event The name of the event.
69-
* @param data The data to send in the event. This can be a String, an InputStream, or any object
70-
* that can be serialized to JSON using the configured {@link JsonService}.
66+
* @param data The data to send in the event. This can be a String, an InputStream, or any object that can be
67+
* serialized to JSON using the configured {@link JsonService}.
7168
* @param id The ID of the event.
7269
*/
7370
void sendEvent(String event, Object data, String id);
7471

7572
/**
76-
* Returns true if {@link #close()} has been called. This can either be by the user, or by Jex
77-
* upon detecting that the {@link Emitter} is closed.
73+
* Returns true if {@link #close()} has been called. This can either be by the user, or by Jex upon detecting that
74+
* the {@link Emitter} is closed.
7875
*/
7976
boolean terminated();
8077
}

avaje-jex/src/main/java/io/avaje/jex/spi/JsonService.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ public non-sealed interface JsonService extends JexExtension {
1515
/**
1616
* **Writes a Java Object as JSON to an OutputStream**
1717
*
18-
* <p>Serializes a Java object into JSON format and writes the resulting JSON to the specified
19-
* output stream.
18+
* <p>Serializes a Java object into JSON format and writes the resulting JSON to the specified output stream.
2019
*
2120
* @param bean the Java object to be serialized
2221
* @param os the output stream to write the JSON data to
@@ -26,8 +25,7 @@ public non-sealed interface JsonService extends JexExtension {
2625
/**
2726
* **Writes a Java Object as a JSON string**
2827
*
29-
* <p>Serializes a Java object into JSON string format and writes the resulting JSON to the
30-
* specified output stream.
28+
* <p>Serializes a Java object into JSON string format and writes the resulting JSON to the specified output stream.
3129
*
3230
* @param bean the Java object to be serialized
3331
* @return the serialized JSON string
@@ -37,8 +35,7 @@ public non-sealed interface JsonService extends JexExtension {
3735
/**
3836
* **Reads JSON from an InputStream**
3937
*
40-
* <p>Reads a JSON-formatted input stream and deserializes it into a Java object of the specified
41-
* type.
38+
* <p>Reads a JSON-formatted input stream and deserializes it into a Java object of the specified type.
4239
*
4340
* @param type the Class object of the desired type
4441
* @param is the input stream containing the JSON data
@@ -49,8 +46,7 @@ public non-sealed interface JsonService extends JexExtension {
4946
/**
5047
* **Reads JSON from an InputStream**
5148
*
52-
* <p>Reads a JSON-formatted input stream and deserializes it into a Java object of the specified
53-
* type.
49+
* <p>Reads a JSON-formatted input stream and deserializes it into a Java object of the specified type.
5450
*
5551
* @param type the Type object of the desired type
5652
* @param is the input stream containing the JSON data
@@ -59,9 +55,8 @@ public non-sealed interface JsonService extends JexExtension {
5955
<T> T fromJson(Type type, InputStream is);
6056

6157
/**
62-
* Serializes a stream of Java objects into a JSON-Stream format, using the {@code x-json-stream}
63-
* media type. Each object in the stream is serialized as a separate JSON object, and the objects
64-
* are separated by newlines.
58+
* Serializes a stream of Java objects into a JSON-Stream format, using the {@code x-json-stream} media type. Each
59+
* object in the stream is serialized as a separate JSON object, and the objects are separated by newlines.
6560
*
6661
* @param iterator the stream of objects to be serialized
6762
* @param os the output stream to write the JSON-Stream data to

0 commit comments

Comments
 (0)