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); } } }
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 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(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("\"Hello World\" Jersey Example App"); ResourceConfig resourceConfig = new ResourceConfig(HelloWorldResource.class, CounterResource.class); HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, resourceConfig, false); Runtime.getRuntime().addShutdownHook(new Thread(server::shutdownNow)); server.start(); System.out.println("Application started.\nTry out"); System.out.println(String.format("%s%s", BASE_URI, ROOT_HELLO_PATH)); System.out.println(String.format("%s%s%s", BASE_URI, ROOT_COUNTER_PATH, "/request")); System.out.println(String.format("%s%s%s", BASE_URI, ROOT_COUNTER_PATH, "/application")); System.out.println("Stop 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(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); } }
public static void main(String[] args) { try { System.out.println("\"Server-Sent Events\" Jersey Example App"); final ResourceConfig resourceConfig = new ResourceConfig(ServerSentEventsResource.class, SseFeature.class); final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, resourceConfig, 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("System Properties 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.%n" + "Try out %s%n" + "Stop the application using CTRL+C", BASE_URI + "/properties")); 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("\"Custom Executor Managed Async Resources\" Jersey 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.\n" + "To test long-running asynchronous operation resource, try %s%s\n" + "To test async chat resource, try %s%s\n" + "Stop the application using CTRL+C", BASE_URI, ASYNC_LONG_RUNNING_MANAGED_OP_PATH, BASE_URI, "chat")); 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("\"Hello World\" Jersey Example App"); final ResourceConfig resourceConfig = new ResourceConfig(HelloWorldResource.class); final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, resourceConfig, 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("Simple Console Jersey Example App"); final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), 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 + "/form")); Thread.currentThread().join(); } catch (IOException | InterruptedException ex) { Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); } } }
@Override public void start() { if (server.isStarted()) { LOGGER.log(Level.WARNING, "Ignoring start request - GrizzlyTestContainer is already started."); } else { LOGGER.log(Level.FINE, "Starting GrizzlyTestContainer..."); try { server.start(); if (baseUri.getPort() == 0) { baseUri = UriBuilder.fromUri(baseUri) .port(server.getListener("grizzly").getPort()) .build(); LOGGER.log(Level.INFO, "Started GrizzlyTestContainer at the base URI " + baseUri); } } catch (final IOException ioe) { throw new TestContainerException(ioe); } } }
@Override public void start() { if (server.isStarted()) { LOGGER.log(Level.WARNING, "Ignoring start request - GrizzlyWebTestContainer is already started."); } else { LOGGER.log(Level.FINE, "Starting GrizzlyWebTestContainer..."); try { server.start(); if (baseUri.getPort() == 0) { baseUri = UriBuilder.fromUri(baseUri) .port(server.getListener("grizzly").getPort()) .build(); LOGGER.log(Level.INFO, "Started GrizzlyWebTestContainer at the base URI " + baseUri); } } catch (final IOException ioe) { throw new TestContainerException(ioe); } } }
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 before() throws Throwable { docRoot.create(); httpServer = org.glassfish.grizzly.http.server.HttpServer.createSimpleServer(docRoot.getRoot().getAbsolutePath()); httpServer.start(); }
@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(); }