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 package org.apache.hc.core5.http.impl.bootstrap;
28
29 import java.net.InetSocketAddress;
30 import java.net.SocketAddress;
31 import java.util.concurrent.Future;
32
33 import org.apache.hc.core5.annotation.Internal;
34 import org.apache.hc.core5.concurrent.FutureCallback;
35 import org.apache.hc.core5.function.Callback;
36 import org.apache.hc.core5.function.Decorator;
37 import org.apache.hc.core5.http.URIScheme;
38 import org.apache.hc.core5.reactor.EndpointParameters;
39 import org.apache.hc.core5.http.nio.command.ShutdownCommand;
40 import org.apache.hc.core5.reactor.IOEventHandlerFactory;
41 import org.apache.hc.core5.reactor.IOReactorConfig;
42 import org.apache.hc.core5.reactor.IOSession;
43 import org.apache.hc.core5.reactor.IOSessionListener;
44 import org.apache.hc.core5.reactor.ListenerEndpoint;
45
46
47
48
49
50
51 public class HttpAsyncServer extends AsyncServer {
52
53 private final String canonicalName;
54
55
56
57
58
59
60 @Internal
61 public HttpAsyncServer(
62 final IOEventHandlerFactory eventHandlerFactory,
63 final IOReactorConfig ioReactorConfig,
64 final Decorator<IOSession> ioSessionDecorator,
65 final Callback<Exception> exceptionCallback,
66 final IOSessionListener sessionListener,
67 final String canonicalName) {
68 super(eventHandlerFactory, ioReactorConfig, ioSessionDecorator, exceptionCallback, sessionListener,
69 ShutdownCommand.GRACEFUL_NORMAL_CALLBACK);
70 this.canonicalName = canonicalName;
71 }
72
73
74
75
76 @Internal
77 public HttpAsyncServer(
78 final IOEventHandlerFactory eventHandlerFactory,
79 final IOReactorConfig ioReactorConfig,
80 final Decorator<IOSession> ioSessionDecorator,
81 final Callback<Exception> exceptionCallback,
82 final IOSessionListener sessionListener) {
83 this(eventHandlerFactory, ioReactorConfig, ioSessionDecorator, exceptionCallback, sessionListener, null);
84 }
85
86
87
88
89 public Future<ListenerEndpoint> listen(
90 final SocketAddress address,
91 final URIScheme scheme,
92 final Object attachment,
93 final FutureCallback<ListenerEndpoint> callback) {
94 final InetSocketAddress inetSocketAddress = (InetSocketAddress) address;
95 final EndpointParameterstParameters.html#EndpointParameters">EndpointParameters parameters = new EndpointParameters(
96 scheme.id,
97 canonicalName != null ? canonicalName : "localhost",
98 inetSocketAddress.getPort(),
99 attachment);
100 return super.listen(address, parameters, callback);
101 }
102
103
104
105
106 public Future<ListenerEndpoint> listen(
107 final SocketAddress address,
108 final URIScheme scheme,
109 final FutureCallback<ListenerEndpoint> callback) {
110 return listen(address, scheme, null, callback);
111 }
112
113
114
115
116 public Future<ListenerEndpoint> listen(final SocketAddress address, final URIScheme scheme) {
117 return listen(address, scheme, null, null);
118 }
119
120
121
122
123 @Deprecated
124 @Override
125 public Future<ListenerEndpoint> listen(final SocketAddress address, final FutureCallback<ListenerEndpoint> callback) {
126 return super.listen(address, callback);
127 }
128
129
130
131
132 @Deprecated
133 @Override
134 public Future<ListenerEndpoint> listen(final SocketAddress address) {
135 return super.listen(address);
136 }
137
138 }