use of org.glassfish.grizzly.http.server.HttpServer in project jersey by jersey.
the class JerseyGrizzlyRunner method main.
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);
}
}
use of org.glassfish.grizzly.http.server.HttpServer in project jersey by jersey.
the class App method main.
public static void main(String[] args) {
try {
System.out.println("Feed Combiner Example App");
URI baseUri = UriBuilder.fromUri("http://localhost/").port(8080).path("combiner").build();
// Automatically set the SelectorRunner count value equal to Runtime.getRuntime().availableProcessors()
HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, new MyApplication(), false);
Runtime.getRuntime().addShutdownHook(new Thread(server::shutdownNow));
server.start();
System.out.println("Application started.\n" + "HTML manager: " + baseUri + "\n" + "REST API: " + baseUri + "/feeds\n" + "Stop the application using CTRL+C");
Thread.currentThread().join();
} catch (IOException | InterruptedException e) {
Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, e);
}
}
use of org.glassfish.grizzly.http.server.HttpServer in project jersey by jersey.
the class App method main.
public static void main(String[] args) {
try {
System.out.println("\"Exception Mapping\" Jersey Example App");
final ResourceConfig resourceConfig = new ResourceConfig(ExceptionResource.class, ExceptionResource.MyResponseFilter.class, ExceptionResource.WebApplicationExceptionFilter.class, Exceptions.MyExceptionMapper.class, Exceptions.MySubExceptionMapper.class, Exceptions.WebApplicationExceptionMapper.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.%n" + "Try out %s%s%n" + "Stop 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);
}
}
use of org.glassfish.grizzly.http.server.HttpServer in project jersey by jersey.
the class App method main.
public static void main(String[] args) {
try {
System.out.println("Extended WADL web application example");
Map<String, String> initParams = new HashMap<>();
initParams.put(ServletProperties.JAXRS_APPLICATION_CLASS, MyApplication.class.getName());
initParams.put(ServerProperties.WADL_GENERATOR_CONFIG, "org.glassfish.jersey.examples.extendedwadl" + ".SampleWadlGeneratorConfig");
final HttpServer server = GrizzlyWebContainerFactory.create(BASE_URI, ServletContainer.class, initParams);
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
server.shutdownNow();
}
}));
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);
}
}
use of org.glassfish.grizzly.http.server.HttpServer in project jersey by jersey.
the class App method main.
public static void main(String[] args) {
try {
System.out.println("\"Hello World\" Jersey-Spring Example App");
final JerseyConfig resourceConfig = new JerseyConfig();
resourceConfig.property("contextConfig", new AnnotationConfigApplicationContext(SpringAnnotationConfig.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);
}
}
Aggregations