Refine search
public static void main(String[] args) { try { System.out.println("\"JAX-RS 2.1 Server-Sent Events\" Jersey Example App"); final ResourceConfig resourceConfig = new ResourceConfig(JaxRsServerSentEventsResource.class); final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, resourceConfig, false); Runtime.getRuntime().addShutdownHook(new Thread(server::shutdownNow)); server.start(); System.out.println(String.format("Application started.\nTry out %s%s\nStop the application using CTRL+C", BASE_URI, ROOT_PATH)); Thread.currentThread().join(); } catch (IOException | InterruptedException ex) { Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); } } }
/** * Create new {@link HttpServer} instance. * * @param uri uri on which the {@link ApplicationHandler} will be deployed. Only first path segment will be used as * context path, the rest will be ignored. * @return newly created {@code HttpServer}. * @throws ProcessingException in case of any failure when creating a new {@code HttpServer} instance. */ public static HttpServer createHttpServer(final URI uri) { return createHttpServer(uri, (GrizzlyHttpContainer) null, false, null, true); }
public static void main(String[] args) throws Exception { System.out.println("Jersey performance test web service application"); final String jaxRsApp = args.length > 0 ? args[0] : null; //noinspection unchecked final ResourceConfig resourceConfig = ResourceConfig .forApplicationClass((Class<? extends Application>) Class.forName(jaxRsApp)); URI baseUri = args.length > 1 ? URI.create(args[1]) : BASE_URI; int selectors = args.length > 2 ? Integer.parseInt(args[2]) : DEFAULT_SELECTORS; int workers = args.length > 3 ? Integer.parseInt(args[3]) : DEFAULT_WORKERS; final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig, false); final TCPNIOTransport transport = server.getListener("grizzly").getTransport(); transport.setSelectorRunnersCount(selectors); transport.setWorkerThreadPoolConfig(ThreadPoolConfig.defaultConfig().setCorePoolSize(workers).setMaxPoolSize(workers)); server.start(); System.out.println(String.format("Application started.\nTry out %s\nHit Ctrl-C to stop it...", baseUri)); while (server.isStarted()) { Thread.sleep(600000); } } }
@Override protected void startUp() throws Exception { httpServer = GrizzlyHttpServerFactory.createHttpServer( uri, createResourceConfig(), false); httpServer.getServerConfiguration().setDefaultErrorPageGenerator(ERROR_PAGE_GENERATOR); httpServer.start(); }
public boolean start(int httpPort) { // ideally greater than reserved port but then port 80 is also valid Preconditions.checkArgument(httpPort > 0); baseUri = URI.create("http://0.0.0.0:" + Integer.toString(httpPort) + "/"); httpServer = GrizzlyHttpServerFactory.createHttpServer(baseUri, this); setupSwagger(httpServer); ClassLoader classLoader = ControllerAdminApiApplication.class.getClassLoader(); // This is ugly from typical patterns to setup static resources but all our APIs are // at path "/". So, configuring static handler for path "/" does not work well. // Configuring this as a default servlet is an option but that is still ugly if we evolve // So, we setup specific handlers for static resource directory. index.html is served directly // by a jersey handler httpServer.getServerConfiguration() .addHttpHandler(new CLStaticHttpHandler(classLoader, "/static/query/"), "/query/"); httpServer.getServerConfiguration().addHttpHandler(new CLStaticHttpHandler(classLoader, "/static/css/"), "/css/"); httpServer.getServerConfiguration().addHttpHandler(new CLStaticHttpHandler(classLoader, "/static/js/"), "/js/"); // without this explicit request to /index.html will not work httpServer.getServerConfiguration().addHttpHandler(new CLStaticHttpHandler(classLoader, "/static/"), "/index.html"); started = true; LOGGER.info("Start jersey admin API on port: {}", httpPort); return true; }
public static void main(String[] args) throws IOException { final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, new JerseyApplication()); System.out.println("Press any key to close"); System.in.read(); server.shutdownNow(); } }
public SwiftProxy(Properties properties, BlobStoreLocator locator, URI endpoint) { this.endpoint = requireNonNull(endpoint); rc = new BounceResourceConfig(properties, locator); if (logger.isDebugEnabled()) { rc.register(new LoggingFilter(java.util.logging.Logger.getGlobal(), false)); } server = GrizzlyHttpServerFactory.createHttpServer(endpoint, rc, false); server.getListeners().forEach(listener -> { listener.registerAddOn(new ContentLengthAddOn()); }); // allow HTTP DELETE to have payload for multi-object delete server.getServerConfiguration().setAllowPayloadForUndefinedHttpMethods(true); RuntimeDelegate.setInstance(new RuntimeDelegateImpl(RuntimeDelegate.getInstance())); }
public static void main(final String[] args) throws Exception { baseUri = args.length > 0 ? URI.create(args[0]) : BASE_URI; final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, createApp()); LOG.log(Level.SEVERE, "An error occurred during test data generation. ", e); server.shutdown();
); final HttpServer httpServer = GrizzlyHttpServerFactory.createHttpServer( listenUri, resourceConfig, false); final NetworkListener listener = httpServer.getListener("grizzly"); listener.setMaxHttpHeaderSize(maxHeaderSize);
/** * Create new {@link HttpServer} instance. * * @param uri uri on which the {@link ApplicationHandler} will be deployed. Only first path segment will be used * as context path, the rest will be ignored. * @param start if set to false, server will not get started, which allows to configure the underlying transport * layer, see above for details. * @return newly created {@code HttpServer}. * @throws ProcessingException in case of any failure when creating a new {@code HttpServer} instance. */ public static HttpServer createHttpServer(final URI uri, final boolean start) { return createHttpServer(uri, (GrizzlyHttpContainer) null, false, null, start); }
public void start() throws IOException { URI baseUri = UriBuilder.fromUri("http://0.0.0.0/").port(restPort).build(); ResourceConfig config = new ResourceConfig(); config.register(new AssociatedResource(indexManager)); config.register(new QueryResource(indexManager)); config.register(new FetchResource(indexManager)); config.register(new FieldsResource(indexManager)); config.register(new IndexResource(indexManager)); config.register(new IndexesResource(indexManager)); config.register(new TermsResource(indexManager)); config.register(new MembersResource(indexManager)); config.register(new StatsResource(indexManager)); server = GrizzlyHttpServerFactory.createHttpServer(baseUri, config); server.getListener("grizzly").setMaxHttpHeaderSize(128 * 1024); }
public static void main(String[] args) { try { System.out.println("JSON with JAXB Jersey Example App"); final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, createApp(), false); Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { server.shutdownNow(); } })); server.start(); System.out.println(String.format("Application started.%nStop the application using CTRL+C")); Thread.currentThread().join(); } catch (IOException | InterruptedException ex) { Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); } }
public boolean start(int httpPort) { if (httpPort <= 0) { LOGGER.warn("Invalid admin API port: {}. Not starting admin service", httpPort); return false; } baseUri = URI.create("http://0.0.0.0:" + Integer.toString(httpPort) + "/"); httpServer = GrizzlyHttpServerFactory.createHttpServer(baseUri, this); setupSwagger(httpServer); started = true; return true; }
public static void main(String[] args) { try { System.out.println("JSON with MOXy Jersey Example App"); final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, createApp(), false); Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { server.shutdownNow(); } })); server.start(); System.out.println(String.format("Application started.%nStop the application using CTRL+C")); Thread.currentThread().join(); } catch (IOException | InterruptedException ex) { Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); } }
public void start(int httpPort) { Preconditions.checkArgument(httpPort > 0); _baseUri = URI.create("http://0.0.0.0:" + httpPort + "/"); _httpServer = GrizzlyHttpServerFactory.createHttpServer(_baseUri, this); setupSwagger(); }
public static void main(String[] args) { try { System.out.println("JSON with Jackson Jersey Example App"); final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, createApp(), false); Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { server.shutdownNow(); } })); server.start(); System.out.println(String.format("Application started.%nStop the application using CTRL+C")); Thread.currentThread().join(); } catch (IOException | InterruptedException ex) { Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); } }
private void startServer(final File segmentDirectory, final String json) throws Exception { int httpPort = 8090; URI baseUri = URI.create("http://0.0.0.0:" + Integer.toString(httpPort) + "/"); HttpServer httpServer = GrizzlyHttpServerFactory.createHttpServer(baseUri, new StarTreeResource(json)); LOGGER.info("Go to http://{}:{}/ to view the star tree", "localhost", httpPort); }
public static void main(String[] args) { try { System.out.println("JAXB Jersey Example App"); final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, createApp(), false); Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { server.shutdownNow(); } })); server.start(); System.out.println( String.format("Application started.%nTry out %s%nStop the application using CTRL+C", BASE_URI)); Thread.currentThread().join(); } catch (IOException | InterruptedException ex) { Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); } }
/** * Create new {@link HttpServer} instance. * * @param uri URI on which the Jersey web application will be deployed. Only first path segment will be * used as context path, the rest will be ignored. * @param configuration web application configuration. * @param start if set to false, server will not get started, which allows to configure the underlying * transport layer, see above for details. * @return newly created {@code HttpServer}. * @throws ProcessingException in case of any failure when creating a new {@code HttpServer} instance. */ public static HttpServer createHttpServer(final URI uri, final ResourceConfig configuration, final boolean start) { return createHttpServer( uri, new GrizzlyHttpContainer(configuration), false, null, start); }
public static void main(final String[] args) { try { System.out.println("JSON with Jackson Jersey Example App"); final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, createApp(), false); Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { server.shutdownNow(); } })); server.start(); System.out.println(String.format("Application started.%nStop the application using CTRL+C")); Thread.currentThread().join(); } catch (IOException | InterruptedException ex) { Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); } }