/** * 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); }
/** * 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 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 void start(int httpPort) { Preconditions.checkArgument(httpPort > 0); _baseUri = URI.create("http://0.0.0.0:" + httpPort + "/"); _httpServer = GrizzlyHttpServerFactory.createHttpServer(_baseUri, this); setupSwagger(); }
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("\"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 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); }
/** * 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 config web application configuration. * @param parentContext DI provider specific context with application's registered bindings. * @return newly created {@code HttpServer}. * @throws ProcessingException in case of any failure when creating a new {@code HttpServer} instance. * @see GrizzlyHttpContainer * @since 2.12 */ public static HttpServer createHttpServer(final URI uri, final ResourceConfig config, final Object parentContext) { return createHttpServer(uri, new GrizzlyHttpContainer(config, parentContext), false, null, true); }
/** * 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. * @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) { return createHttpServer( uri, new GrizzlyHttpContainer(configuration), false, null, true ); }
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); } }
private GrizzlyTestContainer(final URI baseUri, final DeploymentContext context) { this.baseUri = UriBuilder.fromUri(baseUri).path(context.getContextPath()).build(); if (LOGGER.isLoggable(Level.INFO)) { LOGGER.info("Creating GrizzlyTestContainer configured at the base URI " + TestHelper.zeroPortToAvailablePort(baseUri)); } this.server = GrizzlyHttpServerFactory.createHttpServer(this.baseUri, context.getResourceConfig(), false); }
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 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); } }
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); } }
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); } }
public static void main(String[] args) { try { System.out.println("XML with MOXy Jersey Example App"); final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, createApp()); 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 + "/customer")); Thread.currentThread().join(); } catch (IOException | InterruptedException ex) { Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); } }
public static void main(String[] args) { try { System.out.println("Jersey HTTP PATCH Support Example App"); final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, create(), 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/%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); } }
public static void main(String[] args) { try { System.out.println("JSONP 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%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); } }
protected static void start() { weld = new Weld(); weld.initialize(); server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, createJaxRsApp(), true); }
@BeforeClass public static void setup() throws IOException { httpServer = GrizzlyHttpServerFactory.createHttpServer( SERVER_URI, createResourceConfig(), false); httpServer.start(); client = ClientBuilder.newBuilder() .register(GsonMessageBodyProvider.class) .register(PURE_GSON_TEXT_PLAIN) .build(); }