@Override protected void startUp() throws Exception { // Server configuration RestLiConfig config = new RestLiConfig(); config.addResourcePackageNames(JobExecutionInfoResource.class.getPackage().getName()); config.setServerNodeUri(serverUri); config.setDocumentationRequestHandler(new DefaultDocumentationRequestHandler()); // Handle dependency injection Injector injector = Guice.createInjector(new MetaStoreModule(properties)); JobHistoryStore jobHistoryStore = injector.getInstance(JobHistoryStore.class); SimpleBeanProvider beanProvider = new SimpleBeanProvider(); beanProvider.add("jobHistoryStore", jobHistoryStore); // Use InjectMockResourceFactory to keep this Spring free ResourceFactory factory = new InjectMockResourceFactory(beanProvider); // Create and start the HTTP server TransportDispatcher dispatcher = new DelegatingTransportDispatcher(new RestLiServer(config, factory)); String acceptedFilters = EncodingType.SNAPPY.getHttpName() + "," + EncodingType.GZIP.getHttpName(); FilterChain filterChain = FilterChains.createRestChain(new ServerCompressionFilter(acceptedFilters)); this.httpServer = Optional.of(new HttpNettyServerFactory(filterChain).createServer(port, dispatcher)); LOGGER.info("Starting the job execution information server"); this.httpServer.get().start(); }
/** * @param commaDelimitedResourcePackageNames comma-delimited package names list */ public void setResourcePackageNames(final String commaDelimitedResourcePackageNames) { if (commaDelimitedResourcePackageNames != null && ! "".equals(commaDelimitedResourcePackageNames.trim())) { _resourcePackageNames.clear(); addResourcePackageNames(commaDelimitedResourcePackageNames.split(",")); } }
/** * Creates a {@link HttpServer} that contains a {@link RestLiServer} to be used for testing a set of Rest.li * resources. * * The {@link HttpServer} uses an empty {@link FilterChain} and uses "/" as the context path. * * If the server is run in async mode (by calling this function with the last parameter {@code true}), the * timeout used is {@link #ASYNC_TIMEOUT}. * * Both the async and sync servers will use {@link #NUM_THREADS} threads. * * The server is started by calling {@link com.linkedin.r2.transport.http.server.HttpServer#start()} * The server is stopped by calling {@link com.linkedin.r2.transport.http.server.HttpServer#stop()} * * @param port the port the server will run on on localhost * @param resourcePackageNames the names of the packages that contain the Rest.li resources that you wish to serve * @param beans beans you want to inject into your Rest.li resource. * @param enableAsync true if the server should be async, false otherwise * @return a {@link HttpServer} created with the above parameters */ public static HttpServer create(int port, String[] resourcePackageNames, Map<String, Object> beans, boolean enableAsync) { RestLiConfig config = createConfig(port); config.addResourcePackageNames(resourcePackageNames); return create(port, config, beans, enableAsync); }
if (resourcePackages != null) config.addResourcePackageNames(resourcePackages);
@Override protected void startUp() throws Exception { // Server configuration RestLiConfig config = new RestLiConfig(); config.addResourcePackageNames(JobExecutionInfoResource.class.getPackage().getName()); config.setServerNodeUri(serverUri); config.setDocumentationRequestHandler(new DefaultDocumentationRequestHandler()); // Handle dependency injection Injector injector = Guice.createInjector(new MetaStoreModule(properties)); JobHistoryStore jobHistoryStore = injector.getInstance(JobHistoryStore.class); SimpleBeanProvider beanProvider = new SimpleBeanProvider(); beanProvider.add("jobHistoryStore", jobHistoryStore); // Use InjectMockResourceFactory to keep this Spring free ResourceFactory factory = new InjectMockResourceFactory(beanProvider); // Create and start the HTTP server TransportDispatcher dispatcher = new DelegatingTransportDispatcher(new RestLiServer(config, factory)); String acceptedFilters = EncodingType.SNAPPY.getHttpName() + "," + EncodingType.GZIP.getHttpName(); FilterChain filterChain = FilterChains.createRestChain(new ServerCompressionFilter(acceptedFilters)); this.httpServer = Optional.of(new HttpNettyServerFactory(filterChain).createServer(port, dispatcher)); LOGGER.info("Starting the job execution information server"); this.httpServer.get().start(); }
if (resourcePackages != null) config.addResourcePackageNames(resourcePackages);
@Override protected void startUp() throws Exception { // Server configuration RestLiConfig config = new RestLiConfig(); config.addResourcePackageNames(JobExecutionInfoResource.class.getPackage().getName()); config.setServerNodeUri(serverUri); config.setDocumentationRequestHandler(new DefaultDocumentationRequestHandler()); // Handle dependency injection Injector injector = Guice.createInjector(new MetaStoreModule(properties)); JobHistoryStore jobHistoryStore = injector.getInstance(JobHistoryStore.class); SimpleBeanProvider beanProvider = new SimpleBeanProvider(); beanProvider.add("jobHistoryStore", jobHistoryStore); // Use InjectMockResourceFactory to keep this Spring free ResourceFactory factory = new InjectMockResourceFactory(beanProvider); // Create and start the HTTP server TransportDispatcher dispatcher = new DelegatingTransportDispatcher(new RestLiServer(config, factory)); String acceptedFilters = EncodingType.SNAPPY.getHttpName() + "," + EncodingType.GZIP.getHttpName(); FilterChain filterChain = FilterChains.createRestChain(new ServerCompressionFilter(acceptedFilters)); this.httpServer = Optional.of(new HttpNettyServerFactory(filterChain).createServer(port, dispatcher)); LOGGER.info("Starting the job execution information server"); this.httpServer.get().start(); }
config.setDocumentationRequestHandler(new DefaultDocumentationRequestHandler()); config.setServerNodeUri(URI.create("/")); config.addResourcePackageNames(_packages);
config.addResourcePackageNames(RESOURCE_PACKAGE_NAMES); config.setServerNodeUri(URI.create("http://localhost:" + port)); if (useDocumentHandler)