Browse Source

added grizzly debug error page

master
Sebastian Rieger 7 years ago
parent
commit
93aaab6933
  1. BIN
      VerteilteSysteme-Examples/build/RMIEchoServer.jar
  2. BIN
      VerteilteSysteme-Examples/build/RMIMandelbrotCalculationsServer.jar
  3. BIN
      VerteilteSysteme-Examples/build/TCPPerfServer.jar
  4. BIN
      VerteilteSysteme-Examples/build/TCPServer.jar
  5. BIN
      VerteilteSysteme-Examples/build/TCPServerMulti.jar
  6. BIN
      VerteilteSysteme-Examples/build/TCPTimeCounterRESTServer.jar
  7. BIN
      VerteilteSysteme-Examples/build/TCPTimeCounterServer.jar
  8. BIN
      VerteilteSysteme-Examples/build/UDPServer.jar
  9. BIN
      VerteilteSysteme-Examples/build/UDPServerMulti.jar
  10. BIN
      VerteilteSysteme-Examples/build/UDPTimeCounterServer.jar
  11. 64
      VerteilteSysteme-Examples/src/verteiltesysteme/aws/TCPTimeCounterRESTServer.java

BIN
VerteilteSysteme-Examples/build/RMIEchoServer.jar

BIN
VerteilteSysteme-Examples/build/RMIMandelbrotCalculationsServer.jar

BIN
VerteilteSysteme-Examples/build/TCPPerfServer.jar

BIN
VerteilteSysteme-Examples/build/TCPServer.jar

BIN
VerteilteSysteme-Examples/build/TCPServerMulti.jar

BIN
VerteilteSysteme-Examples/build/TCPTimeCounterRESTServer.jar

BIN
VerteilteSysteme-Examples/build/TCPTimeCounterServer.jar

BIN
VerteilteSysteme-Examples/build/UDPServer.jar

BIN
VerteilteSysteme-Examples/build/UDPServerMulti.jar

BIN
VerteilteSysteme-Examples/build/UDPTimeCounterServer.jar

64
VerteilteSysteme-Examples/src/verteiltesysteme/aws/TCPTimeCounterRESTServer.java

@ -1,32 +1,52 @@
/* Beispiel angelehnt an http://www.torsten-horn.de/techdocs/jee-rest.htm */ /* Beispiel angelehnt an http://www.torsten-horn.de/techdocs/jee-rest.htm */
package verteiltesysteme.aws; package verteiltesysteme.aws;
import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.PrintStream;
import java.net.URI; import java.net.URI;
import org.glassfish.grizzly.http.server.ErrorPageGenerator;
import org.glassfish.grizzly.http.server.HttpServer; import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.grizzly.http.server.Request;
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ResourceConfig;
public class TCPTimeCounterRESTServer
{
public static void main( String[] args ) throws IOException, InterruptedException
{
String baseUrl = ( args.length > 0 ) ? args[0] : "http://0.0.0.0:36042";
final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(
URI.create( baseUrl ), new ResourceConfig( TCPTimeCounterRESTService.class ), false );
Runtime.getRuntime().addShutdownHook( new Thread( new Runnable() {
@Override
public void run() {
server.shutdownNow();
}
} ) );
server.start();
System.out.println("Grizzly-HTTP-Server gestartet");
System.out.println("Stoppen des Grizzly-HTTP-Servers mit: Strg+C\n");
System.out.println("RESTful Web Service URL: " + baseUrl + TCPTimeCounterRESTService.webContextPath);
Thread.currentThread().join();
}
public class TCPTimeCounterRESTServer {
public static void main(String[] args) throws IOException, InterruptedException {
String baseUrl = (args.length > 0) ? args[0] : "http://0.0.0.0:36042";
final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(URI.create(baseUrl),
new ResourceConfig(TCPTimeCounterRESTService.class), false);
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
server.shutdownNow();
}
}));
ErrorPageGenerator epg = new ErrorPageGenerator() {
@Override
public String generate(Request request, int status, String reasonPhrase, String description,
Throwable exception) {
StringBuilder sb = new StringBuilder();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
exception.printStackTrace(ps);
ps.close();
sb.append(new String(baos.toByteArray()));
System.out.println(sb.toString());
return sb.toString();
}
};
server.getServerConfiguration().setDefaultErrorPageGenerator(epg);
server.start();
System.out.println("Grizzly-HTTP-Server gestartet");
System.out.println("Stoppen des Grizzly-HTTP-Servers mit: Strg+C\n");
System.out.println("RESTful Web Service URL: " + baseUrl + TCPTimeCounterRESTService.webContextPath);
Thread.currentThread().join();
}
} }
Loading…
Cancel
Save