final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(NUM_THREADS);
final ExecutorService executor = Executors.newFixedThreadPool(NUM_THREADS);
EngineBuilder engineBuilder = new EngineBuilder().setTaskExecutor(scheduler).setTimerScheduler(scheduler);
AsyncCallableTask.register(engineBuilder, executor);
final Engine engine = engineBuilder.build();
ResourceFactory resourceFactory = createResourceFactory(beans);
TransportDispatcher dispatcher = new DelegatingTransportDispatcher(new RestLiServer(config,
resourceFactory,
engine));
final FilterChain fc = FilterChains.empty().addLast(new SimpleLoggingFilter());
final HttpServer server = new HttpServerFactory(fc).createServer(port,
HttpServerFactory.DEFAULT_CONTEXT_PATH,
NUM_THREADS,
dispatcher,
enableAsync,
enableAsync ? ASYNC_TIMEOUT : -1);
return new HttpServer()
{
@Override
public void start()
throws IOException
{
server.start();
}
@Override
public void stop()
throws IOException
{
server.stop();
engine.shutdown();
executor.shutdown();
scheduler.shutdown();
}
@Override