3030
3131import org .lattejava .http .log .Logger ;
3232import org .lattejava .http .security .SecurityTools ;
33+ import org .lattejava .http .server .HTTPContext ;
3334import org .lattejava .http .server .HTTPListenerConfiguration ;
3435import org .lattejava .http .server .HTTPServerConfiguration ;
3536import org .lattejava .http .server .Instrumenter ;
@@ -48,6 +49,8 @@ public class HTTPServerThread extends Thread {
4849
4950 private final HTTPServerConfiguration configuration ;
5051
52+ private final HTTPContext context ;
53+
5154 private final Instrumenter instrumenter ;
5255
5356 private final HTTPListenerConfiguration listener ;
@@ -62,11 +65,12 @@ public class HTTPServerThread extends Thread {
6265
6366 private volatile boolean running ;
6467
65- public HTTPServerThread (HTTPServerConfiguration configuration , HTTPListenerConfiguration listener )
68+ public HTTPServerThread (HTTPServerConfiguration configuration , HTTPContext context , HTTPListenerConfiguration listener )
6669 throws IOException , GeneralSecurityException {
6770 super ("HTTP server [" + listener .getBindAddress ().toString () + ":" + listener .getPort () + "]" );
6871
6972 this .configuration = configuration ;
73+ this .context = context ;
7074 this .listener = listener ;
7175 this .instrumenter = configuration .getInstrumenter ();
7276 this .logger = configuration .getLoggerFactory ().getLogger (HTTPServerThread .class );
@@ -75,8 +79,8 @@ public HTTPServerThread(HTTPServerConfiguration configuration, HTTPListenerConfi
7579 this .cleaner = new HTTPServerCleanerThread ();
7680
7781 if (listener .isTLS ()) {
78- SSLContext context = SecurityTools .serverContext (listener .getCertificateChain (), listener .getPrivateKey ());
79- this .socket = context .getServerSocketFactory ().createServerSocket ();
82+ SSLContext sslContext = SecurityTools .serverContext (listener .getCertificateChain (), listener .getPrivateKey ());
83+ this .socket = sslContext .getServerSocketFactory ().createServerSocket ();
8084 } else {
8185 this .socket = new ServerSocket ();
8286 }
@@ -112,7 +116,7 @@ public void run() {
112116 }
113117
114118 Throughput throughput = new Throughput (configuration .getReadThroughputCalculationDelay ().toMillis (), configuration .getWriteThroughputCalculationDelay ().toMillis ());
115- HTTPWorker runnable = new HTTPWorker (clientSocket , configuration , instrumenter , listener , throughput );
119+ HTTPWorker runnable = new HTTPWorker (clientSocket , configuration , context , instrumenter , listener , throughput );
116120 Thread client = Thread .ofVirtual ()
117121 .name ("HTTP client [" + clientSocket .getRemoteSocketAddress () + "]" )
118122 .start (runnable );
0 commit comments