private HttpServer createHttpServer ( JolokiaServerConfig pConfig ) throws IOException { int port = pConfig . getPort ( ) ; InetAddress address = pConfig . getAddress ( ) ; InetSocketAddress socketAddress = new InetSocketAddress ( address , port ) ; HttpServer server = pConfig . useHttps ( ) ? createHttpsServer ( socketAddress , pConfig ) : HttpServer . create ( socketAddress , pConfig . getBacklog ( ) ) ; // Thread factory which creates only daemon threads ThreadFactory daemonThreadFactory = new DaemonThreadFactory ( pConfig . getThreadNamePrefix ( ) ) ; // Prepare executor pool Executor executor ; String mode = pConfig . getExecutor ( ) ; if ( "fixed" . equalsIgnoreCase ( mode ) ) { executor = Executors . newFixedThreadPool ( pConfig . getThreadNr ( ) , daemonThreadFactory ) ; } else if ( "cached" . equalsIgnoreCase ( mode ) ) { executor = Executors . newCachedThreadPool ( daemonThreadFactory ) ; } else { executor = Executors . newSingleThreadExecutor ( daemonThreadFactory ) ; } server . setExecutor ( executor ) ; return server ; }
Create the HttpServer to use . Can be overridden if a custom or already existing HttpServer should be used