-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify JsonService interface (#79)
* simplify JsonService interface * Update JsonService.java
- Loading branch information
Showing
11 changed files
with
101 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ain/java/io/avaje/jex/spi/HeaderKeys.java → ...in/java/io/avaje/jex/core/HeaderKeys.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package io.avaje.jex.spi; | ||
package io.avaje.jex.core; | ||
|
||
public class HeaderKeys { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,48 @@ | ||
package io.avaje.jex.spi; | ||
|
||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
import java.util.Iterator; | ||
|
||
/** | ||
* HttpService used to convert request/response bodies to beans. | ||
* **JsonService** | ||
* | ||
* <p>A service responsible for handling JSON-based request and response bodies. | ||
* | ||
* @see {@link JexExtension} for SPI registration details. | ||
*/ | ||
public non-sealed interface JsonService extends JexExtension { | ||
|
||
/** | ||
* Read the request body as a bean and return the bean. | ||
* **Reads JSON from an InputStream** | ||
* | ||
* <p>Reads a JSON-formatted input stream and deserializes it into a Java object of the specified | ||
* type. | ||
* | ||
* @param type the Class object of the desired type | ||
* @param is the input stream containing the JSON data | ||
* @return the deserialized object | ||
*/ | ||
<T> T jsonRead(Class<T> type, SpiContext ctx); | ||
<T> T jsonRead(Class<T> type, InputStream is); | ||
|
||
/** | ||
* Write the bean as JSON response content. | ||
* **Writes a Java Object as JSON to an OutputStream** | ||
* | ||
* <p>Serializes a Java object into JSON format and writes the resulting JSON to the specified | ||
* output stream. | ||
* | ||
* @param bean the Java object to be serialized | ||
* @param os the output stream to write the JSON data to | ||
*/ | ||
void jsonWrite(Object bean, SpiContext ctx); | ||
void jsonWrite(Object bean, OutputStream os); | ||
|
||
/** | ||
* Write the beans as {@literal x-json-stream } JSON with new line delimiter. | ||
* Serializes a stream of Java objects into a JSON-Stream format, using the {@code x-json-stream} | ||
* media type. Each object in the stream is serialized as a separate JSON object, and the objects | ||
* are separated by newlines. | ||
* | ||
* @param iterator the stream of objects to be serialized | ||
* @param os the output stream to write the JSON-Stream data to | ||
*/ | ||
<E> void jsonWriteStream(Iterator<E> stream, SpiContext ctx); | ||
|
||
<E> void jsonWriteStream(Iterator<E> iterator, OutputStream os); | ||
} |