You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.3 KiB

  1. /* Beispiel angelehnt an http://www.torsten-horn.de/techdocs/jee-rest.htm */
  2. package verteiltesysteme.rest;
  3. import java.io.IOException;
  4. import java.net.URI;
  5. import org.glassfish.grizzly.http.server.HttpServer;
  6. import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
  7. import org.glassfish.jersey.server.ResourceConfig;
  8. public class RESTServer
  9. {
  10. public static void main( String[] args ) throws IOException, InterruptedException
  11. {
  12. String baseUrl = ( args.length > 0 ) ? args[0] : "http://localhost:4434";
  13. final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(
  14. URI.create( baseUrl ), new ResourceConfig( RESTToUpperCaseService.class, RESTToLowerCaseService.class ), false );
  15. Runtime.getRuntime().addShutdownHook( new Thread( new Runnable() {
  16. @Override
  17. public void run() {
  18. server.shutdownNow();
  19. }
  20. } ) );
  21. server.start();
  22. System.out.println("Grizzly-HTTP-Server gestartet");
  23. System.out.println("Stoppen des Grizzly-HTTP-Servers mit: Strg+C\n");
  24. System.out.println("RESTful Web Service URL: " + baseUrl + RESTToUpperCaseService.webContextPath);
  25. System.out.println("RESTful Web Service URL: " + baseUrl + RESTToLowerCaseService.webContextPath);
  26. Thread.currentThread().join();
  27. }
  28. }