use of com.linkedin.r2.transport.http.server.HttpServer in project rest.li by linkedin.
the class HttpServerFactory method createServer.
public HttpServer createServer(int port, String contextPath, int threadPoolSize, TransportDispatcher transportDispatcher, HttpJettyServer.ServletType servletType, int asyncTimeOut, boolean restOverStream) {
final TransportDispatcher filterDispatcher = new FilterChainDispatcher(transportDispatcher, _filters);
final HttpDispatcher dispatcher = HttpDispatcherFactory.create((filterDispatcher));
return new HttpJettyServer(port, contextPath, threadPoolSize, dispatcher, servletType, asyncTimeOut, restOverStream);
}
use of com.linkedin.r2.transport.http.server.HttpServer in project rest.li by linkedin.
the class TestMockHttpServerFactory method testCreateUsingPackageNames.
@Test
public void testCreateUsingPackageNames() throws IOException, RemoteInvocationException {
Map<String, Object> beans = getBeans();
boolean[] enableAsyncOptions = { true, false };
for (boolean enableAsync : enableAsyncOptions) {
HttpServer server = MockHttpServerFactory.create(PORT, new String[] { "com.linkedin.restli.example.impl" }, beans, enableAsync);
runTest(server);
}
}
use of com.linkedin.r2.transport.http.server.HttpServer in project rest.li by linkedin.
the class HttpNettyServerFactory method createServer.
public HttpServer createServer(int port, int threadPoolSize, TransportDispatcher transportDispatcher) {
final TransportDispatcher filterDispatcher = new FilterChainDispatcher(transportDispatcher, _filters);
final HttpDispatcher dispatcher = HttpDispatcherFactory.create((filterDispatcher));
return new HttpNettyServer(port, threadPoolSize, dispatcher);
}
use of com.linkedin.r2.transport.http.server.HttpServer in project rest.li by linkedin.
the class RestLiIntTestServer method main.
public static void main(String[] args) throws IOException {
final int numCores = Runtime.getRuntime().availableProcessors();
final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(numCores + 1);
final Engine engine = new EngineBuilder().setTaskExecutor(scheduler).setTimerScheduler(scheduler).build();
HttpServer server = createServer(engine, DEFAULT_PORT, supportedCompression);
server.start();
System.out.println("HttpServer running on port " + DEFAULT_PORT + ". Press any key to stop server");
System.in.read();
server.stop();
engine.shutdown();
}
use of com.linkedin.r2.transport.http.server.HttpServer in project rest.li by linkedin.
the class RestLiIntTestServer method createServer.
public static HttpServer createServer(Engine engine, int port, boolean useAsyncServletApi, int asyncTimeOut, List<? extends Filter> filters, FilterChain filterChain, boolean restOverStream, boolean useDocumentHandler, boolean useDebugHandler, RestLiConfig config) {
config.addResourcePackageNames(RESOURCE_PACKAGE_NAMES);
config.setServerNodeUri(URI.create("http://localhost:" + port));
if (useDocumentHandler && config.getDocumentationRequestHandler() == null) {
config.setDocumentationRequestHandler(new DefaultDocumentationRequestHandler());
}
if (useDebugHandler) {
config.addDebugRequestHandlers(new ParseqTraceDebugRequestHandler());
}
config.setFilters(filters);
config.setUseStreamCodec(Boolean.parseBoolean(System.getProperty("test.useStreamCodecServer", "false")));
GroupMembershipMgr membershipMgr = new HashGroupMembershipMgr();
GroupMgr groupMgr = new HashMapGroupMgr(membershipMgr);
GroupsRestApplication app = new GroupsRestApplication(groupMgr, membershipMgr);
SimpleBeanProvider beanProvider = new SimpleBeanProvider();
beanProvider.add("GroupsRestApplication", app);
// using InjectMockResourceFactory to keep examples spring-free
ResourceFactory factory = new InjectMockResourceFactory(beanProvider);
RestLiServer restLiServer = new RestLiServer(config, factory, engine);
TransportDispatcher dispatcher = new DelegatingTransportDispatcher(restLiServer, restLiServer);
return new HttpServerFactory(filterChain).createServer(port, HttpServerFactory.DEFAULT_CONTEXT_PATH, HttpServerFactory.DEFAULT_THREAD_POOL_SIZE, dispatcher, useAsyncServletApi ? HttpJettyServer.ServletType.ASYNC_EVENT : HttpJettyServer.ServletType.RAP, asyncTimeOut, restOverStream);
}
Aggregations