use of com.linkedin.r2.transport.http.server.RAPServlet in project rest.li by linkedin.
the class RestliServlet method buildR2ServletFromServletParams.
private AbstractR2Servlet buildR2ServletFromServletParams(ServletConfig servletConfig) {
ResourceFactory resourceFactory = new PrototypeResourceFactory();
RestLiConfig config = new RestLiConfig();
config.setResourcePackageNamesSet(getResourcePackageSet(servletConfig));
final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(getParseqThreadPoolSize(servletConfig));
Engine engine = new EngineBuilder().setTaskExecutor(scheduler).setTimerScheduler(scheduler).build();
final RestLiServer restLiServer = new RestLiServer(config, resourceFactory, engine);
DelegatingTransportDispatcher dispatcher = new DelegatingTransportDispatcher(restLiServer, restLiServer);
boolean useAsync = getUseAsync(servletConfig);
long asyncTimeOut = getAsyncTimeout(servletConfig);
if (useAsync && servletConfig.getServletContext().getMajorVersion() < 3) {
throw new IllegalArgumentException("This servlet is configured with useAsync=true, but the current servlet " + "context does not support the required Servlet API 3.0.");
}
if (!useAsync) {
log.info("Initializing Rest.li with a thread based request handling. Set useAsync=true on a Servlet API 3.0 container to enable Rest.li's async servlet.");
return new RAPServlet(dispatcher);
} else {
log.info("Initializing Rest.li with an async request handling enabled.");
return new AsyncR2Servlet(dispatcher, asyncTimeOut);
}
}
use of com.linkedin.r2.transport.http.server.RAPServlet in project rest.li by linkedin.
the class HttpServerFactory method createRAPServer.
public HttpServer createRAPServer(int port, TransportDispatcher transportDispatcher, int timeout, boolean restOverStream) {
final TransportDispatcher filterDispatcher = new FilterChainDispatcher(transportDispatcher, _filters);
HttpServlet httpServlet = restOverStream ? new RAPStreamServlet(filterDispatcher, timeout, DEFAULT_LOG_SERVLET_EXCEPTIONS) : new RAPServlet(filterDispatcher);
return new HttpJettyServer(port, httpServlet);
}
Aggregations