use of org.glassfish.grizzly.http.server.HttpServer in project jersey by jersey.
the class App method main.
/**
* Main application entry point.
*
* @param args application arguments.
*/
public static void main(String[] args) {
try {
System.out.println("JAX-RS Type Injection 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 injection into a programmatic resource, try out:%n %s%s%s%n" + "To test instance injection into an annotated resource, try out:%n %s%s%s%n" + "To test method injection into an annotated resource, try out:%n %s%s%s%n" + "Stop the application using CTRL+C", BASE_URI, ROOT_PATH_PROGRAMMATIC, "?q1=<value_1>&q2=<value_2>&q2=<value_3>", BASE_URI, ROOT_PATH_ANNOTATED_INSTANCE, "?q1=<value_1>&q2=<value_2>&q2=<value_3>", BASE_URI, ROOT_PATH_ANNOTATED_METHOD, "?q1=<value_1>&q2=<value_2>&q2=<value_3>"));
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("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);
}
}
use of org.glassfish.grizzly.http.server.HttpServer in project jersey by jersey.
the class App method main.
/**
* Main application entry point.
*
* @param args application arguments.
*/
public static void main(String[] args) {
try {
System.out.println("HTTP TRACE Support 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 TRACE with a programmatic resource, send HTTP TRACE request to:%n %s%s%n" + "To test TRACE with an annotated resource, send HTTP TRACE request to:%n %s%s%n" + "Stop the application using CTRL+C", BASE_URI, ROOT_PATH_PROGRAMMATIC, BASE_URI, ROOT_PATH_ANNOTATED));
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 Server method start.
/**
* Start SSL-secured HTTP test server.
*
* @throws IOException in case there is an error while reading server key store or trust store.
* @return an instance of the started SSL-secured HTTP test server.
*/
public static Server start() throws IOException {
// Grizzly ssl configuration
SSLContextConfigurator sslContext = new SSLContextConfigurator();
// set up security context
// contains server keypair
sslContext.setKeyStoreFile(KEYSTORE_SERVER_FILE);
sslContext.setKeyStorePass(KEYSTORE_SERVER_PWD);
// contains client certificate
sslContext.setTrustStoreFile(TRUSTORE_SERVER_FILE);
sslContext.setTrustStorePass(TRUSTORE_SERVER_PWD);
ResourceConfig rc = new ResourceConfig();
rc.registerClasses(RootResource.class, SecurityFilter.class, AuthenticationExceptionMapper.class);
final HttpServer grizzlyServer = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc, true, new SSLEngineConfigurator(sslContext).setClientMode(false).setNeedClientAuth(true));
// start Grizzly embedded server //
LOGGER.info("Jersey app started. Try out " + BASE_URI + "\nHit CTRL + C to stop it...");
grizzlyServer.start();
return new Server(grizzlyServer);
}
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("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);
}
}
Aggregations