1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 package org.apache.hc.client5.http.impl.async;
29
30 import java.io.IOException;
31
32 import org.apache.hc.client5.http.async.AsyncExecCallback;
33 import org.apache.hc.client5.http.async.AsyncExecChain;
34 import org.apache.hc.client5.http.async.AsyncExecChainHandler;
35 import org.apache.hc.core5.http.HttpException;
36 import org.apache.hc.core5.http.HttpRequest;
37 import org.apache.hc.core5.http.nio.AsyncEntityProducer;
38
39 class AsyncExecChainElement {
40
41 private final AsyncExecChainHandler handler;
42 private final AsyncExecChainElement next;
43
44 AsyncExecChainElementnElement(final AsyncExecChainHandler handler, final AsyncExecChainElement next) {
45 this.handler = handler;
46 this.next = next;
47 }
48
49 public void execute(
50 final HttpRequest request,
51 final AsyncEntityProducer entityProducer,
52 final AsyncExecChain.Scope scope,
53 final AsyncExecCallback asyncExecCallback) throws HttpException, IOException {
54 handler.execute(request, entityProducer, scope, new AsyncExecChain() {
55
56 @Override
57 public void proceed(
58 final HttpRequest request,
59 final AsyncEntityProducer entityProducer,
60 final AsyncExecChain.Scope scope,
61 final AsyncExecCallback asyncExecCallback) throws HttpException, IOException {
62 next.execute(request, entityProducer, scope, asyncExecCallback);
63 }
64
65 }, asyncExecCallback);
66
67 }
68
69 @Override
70 public String toString() {
71 return "{" +
72 "handler=" + handler.getClass() +
73 ", next=" + (next != null ? next.handler.getClass() : "null") +
74 '}';
75 }
76
77 }