use of com.linkedin.r2.transport.common.bridge.server.TransportDispatcher 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.common.bridge.server.TransportDispatcher in project rest.li by linkedin.
the class TestJetty404 method setup.
@BeforeClass
public void setup() throws IOException {
_clientFactory = new HttpClientFactory.Builder().build();
_client = new TransportClientAdapter(_clientFactory.getClient(Collections.<String, String>emptyMap()), true);
_server = new HttpServerFactory().createH2cServer(PORT, "/correct-path", 50, new TransportDispatcher() {
@Override
public void handleRestRequest(RestRequest req, Map<String, String> wireAttrs, RequestContext requestContext, TransportCallback<RestResponse> callback) {
callback.onResponse(TransportResponseImpl.success(new RestResponseBuilder().build()));
}
@Override
public void handleStreamRequest(StreamRequest req, Map<String, String> wireAttrs, RequestContext requestContext, TransportCallback<StreamResponse> callback) {
req.getEntityStream().setReader(new DrainReader());
callback.onResponse(TransportResponseImpl.success(new StreamResponseBuilder().build(EntityStreams.emptyStream())));
}
}, true);
_server.start();
}
use of com.linkedin.r2.transport.common.bridge.server.TransportDispatcher 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.common.bridge.server.TransportDispatcher 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);
}
use of com.linkedin.r2.transport.common.bridge.server.TransportDispatcher in project rest.li by linkedin.
the class TestMIMEChainingMultipleSources method setup.
@BeforeClass
public void setup() throws IOException {
_scheduledExecutorService = Executors.newScheduledThreadPool(30);
_clientFactory = new HttpClientFactory.Builder().build();
_client = new TransportClientAdapter(_clientFactory.getClient(Collections.<String, String>emptyMap()));
_server_A_client = new TransportClientAdapter(_clientFactory.getClient(Collections.<String, String>emptyMap()));
final HttpServerFactory httpServerFactory = new HttpServerFactory();
final ServerARequestHandler serverARequestHandler = new ServerARequestHandler();
final TransportDispatcher serverATransportDispatcher = new TransportDispatcherBuilder().addStreamHandler(SERVER_A_URI, serverARequestHandler).build();
final ServerBRequestHandler serverBRequestHandler = new ServerBRequestHandler();
final TransportDispatcher serverBTransportDispatcher = new TransportDispatcherBuilder().addStreamHandler(SERVER_B_URI, serverBRequestHandler).build();
_serverA = httpServerFactory.createServer(PORT_SERVER_A, serverATransportDispatcher, true);
_serverB = httpServerFactory.createServer(PORT_SERVER_B, serverBTransportDispatcher, true);
_serverA.start();
_serverB.start();
}
Aggregations