Skip to content

Commit 18c8eb0

Browse files
committed
Updated JSON binding and async examples
1 parent 660f1e5 commit 18c8eb0

10 files changed

Lines changed: 73 additions & 1 deletion

File tree

httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonNodeResponseExample.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@
4444
import org.apache.hc.core5.reactor.IOReactorConfig;
4545
import org.apache.hc.core5.util.Timeout;
4646

47+
/**
48+
* This example demonstrates how an HTTP response JSON content can be consumed as
49+
* Jackson JsonNode object.
50+
* <p>
51+
* Please note content of incoming and outgoing HTTP messages gets streamed without making
52+
* a copy of the message body content in an intermediate buffer.
53+
* <p>
54+
* This example uses {@link AsyncJsonClientPipeline} to simplify HTTP message execution pipeline
55+
* assembly. One can also use JSON message request producers and response consumers directly.
56+
*/
4757
public class JsonNodeResponseExample {
4858

4959
public static void main(final String... args) throws Exception {

httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonObjectRequestExample.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@
4747
import org.apache.hc.core5.reactor.IOReactorConfig;
4848
import org.apache.hc.core5.util.Timeout;
4949

50+
/**
51+
* This example demonstrates how a plain Java Object can be serialized as a request
52+
* content body in JSON format and an HTTP response JSON content can be consumed as
53+
* a plain Java Object compatible with Jackson JSON bindings.
54+
*
55+
* <p>
56+
* Please note content of incoming and outgoing HTTP messages gets streamed without making
57+
* a copy of the message body content in an intermediate buffer.
58+
* <p>
59+
* This example uses {@link AsyncJsonClientPipeline} to simplify HTTP message execution pipeline
60+
* assembly. One can also use JSON message request producers and response consumers directly.
61+
*/
5062
public class JsonObjectRequestExample {
5163

5264
public static void main(final String... args) throws Exception {

httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonSequenceRequestExample.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@
5050
import org.apache.hc.core5.reactor.IOReactorConfig;
5151
import org.apache.hc.core5.util.Timeout;
5252

53+
/**
54+
* This example demonstrates how to stream out a sequence plain Java Objects compatible
55+
* with Jackson JSON bindings as a request content body in JSON format.
56+
*
57+
* <p>
58+
* Please note content of incoming and outgoing HTTP messages gets streamed without making
59+
* a copy of the message body content in an intermediate buffer.
60+
* <p>
61+
* This example uses {@link AsyncJsonClientPipeline} to simplify HTTP message execution pipeline
62+
* assembly. One can also use JSON message request producers and response consumers directly.
63+
*/
5364
public class JsonSequenceRequestExample {
5465

5566
public static void main(final String... args) throws Exception {

httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonSequenceResponseExample.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@
4343
import org.apache.hc.core5.reactor.IOReactorConfig;
4444
import org.apache.hc.core5.util.Timeout;
4545

46+
/**
47+
* This example demonstrates how an HTTP response content can be consumed as a sequence
48+
* of plain Java Objects compatible with Jackson JSON bindings.
49+
*
50+
* <p>
51+
* Please note content of incoming and outgoing HTTP messages gets streamed without making
52+
* a copy of the message body content in an intermediate buffer.
53+
* <p>
54+
* This example uses {@link AsyncJsonClientPipeline} to simplify HTTP message execution pipeline
55+
* assembly. One can also use JSON message request producers and response consumers directly.
56+
*/
4657
public class JsonSequenceResponseExample {
4758

4859
public static void main(final String... args) throws Exception {

httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonServerExample.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@
5757
import org.apache.hc.core5.util.TimeValue;
5858

5959
/**
60-
* Example of asynchronous embedded JSON server.
60+
* Example of asynchronous embedded HTTP server that exchanges messages in JSON format.
61+
* <p>
62+
* Please note content of incoming and outgoing HTTP messages gets streamed without making
63+
* a copy of the message body content in an intermediate buffer.
64+
* <p>
65+
* This example uses {@link AsyncJsonServerPipeline} to simplify HTTP message execution pipeline
66+
* assembly. One can also use JSON message consumers and response producers directly.
6167
*/
6268
public class JsonServerExample {
6369

httpcore5-jackson2/src/test/java/org/apache/hc/core5/jackson2/http/examples/JsonTokenEventResponseExample.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@
4343
import org.apache.hc.core5.reactor.IOReactorConfig;
4444
import org.apache.hc.core5.util.Timeout;
4545

46+
/**
47+
* This example demonstrates how an HTTP response JSON content can be consumed as
48+
* a stream of events.
49+
* <p>
50+
* Please note content of incoming and outgoing HTTP messages gets streamed without making
51+
* a copy of the message body content in an intermediate buffer.
52+
* <p>
53+
* This example uses {@link AsyncJsonClientPipeline} to simplify HTTP message execution pipeline
54+
* assembly. One can also use JSON message request and response consumers directly.
55+
*/
4656
public class JsonTokenEventResponseExample {
4757

4858
public static void main(final String... args) throws Exception {

httpcore5/src/test/java/org/apache/hc/core5/http/examples/AsyncClientSNIExample.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353

5454
/**
5555
* Example of SNI (Server Name Identification) usage with async I/O.
56+
* <p>
57+
* This example uses {@link AsyncClientPipeline} to simplify HTTP message execution pipeline
58+
* assembly. One can also use message request producers and response consumers directly.
5659
*/
5760
public class AsyncClientSNIExample {
5861

httpcore5/src/test/java/org/apache/hc/core5/http/examples/AsyncFileServerExample.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@
6363

6464
/**
6565
* Example of asynchronous embedded HTTP/1.1 file server.
66+
* <p>
67+
* This example uses {@link AsyncServerPipeline} to simplify HTTP message execution pipeline
68+
* assembly. One can also use message request consumers and response producers directly.
6669
*/
6770
public class AsyncFileServerExample {
6871

httpcore5/src/test/java/org/apache/hc/core5/http/examples/AsyncPipelinedRequestExecutionExample.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050

5151
/**
5252
* Example of asynchronous HTTP/1.1 request execution.
53+
* <p>
54+
* This example uses {@link AsyncClientPipeline} to simplify HTTP message execution pipeline
55+
* assembly. One can also use message request producers and response consumers directly.
5356
*/
5457
public class AsyncPipelinedRequestExecutionExample {
5558

httpcore5/src/test/java/org/apache/hc/core5/http/examples/AsyncRequestExecutionExample.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848

4949
/**
5050
* Example of asynchronous HTTP/1.1 request execution.
51+
* <p>
52+
* This example uses {@link AsyncClientPipeline} to simplify HTTP message execution pipeline
53+
* assembly. One can also use message request producers and response consumers directly.
5154
*/
5255
public class AsyncRequestExecutionExample {
5356

0 commit comments

Comments
 (0)