diff --git a/VerteilteSysteme-Examples/build/TCPTimeCounterRESTServer.jar b/VerteilteSysteme-Examples/build/TCPTimeCounterRESTServer.jar index cac647e..e383e28 100644 Binary files a/VerteilteSysteme-Examples/build/TCPTimeCounterRESTServer.jar and b/VerteilteSysteme-Examples/build/TCPTimeCounterRESTServer.jar differ diff --git a/VerteilteSysteme-Examples/src/verteiltesysteme/aws/TCPTimeCounterRESTService.java b/VerteilteSysteme-Examples/src/verteiltesysteme/aws/TCPTimeCounterRESTService.java index 08bd24b..be853b6 100644 --- a/VerteilteSysteme-Examples/src/verteiltesysteme/aws/TCPTimeCounterRESTService.java +++ b/VerteilteSysteme-Examples/src/verteiltesysteme/aws/TCPTimeCounterRESTService.java @@ -11,14 +11,15 @@ import com.amazonaws.services.s3.AmazonS3ClientBuilder; public class TCPTimeCounterRESTService { static final String webContextPath = "/counter"; static final String bucketName = "vertsys-counter"; - + static final String dnsNameELB = "VertSys-ELB1-b88aad9416b2929b.elb.eu-central-1.amazonaws.com"; + private Long getCounter() { // Verbindung zu S3 AmazonS3 s3Client = AmazonS3ClientBuilder.defaultClient(); String region = s3Client.getRegionName(); return new Long(s3Client.getObjectAsString(bucketName, region)); } - + private boolean setCounter(Long counter) { // Verbindung zu S3 AmazonS3 s3Client = AmazonS3ClientBuilder.defaultClient(); @@ -36,7 +37,10 @@ public class TCPTimeCounterRESTService { @GET @Produces(MediaType.TEXT_HTML) public String getCounterHtml() { - return "TCPTimeCounter REST Service

HTML: " + getCounter() + "

"; + return "TCPTimeCounter REST Service" + + "" + + "

Verteilte Systeme HS Fulda - TCPTimeCounter REST Service

"+ + "

HTML-Output: " + getCounter() + "

"; } @GET @@ -50,7 +54,7 @@ public class TCPTimeCounterRESTService { @Produces(MediaType.TEXT_PLAIN) public String incrCounterPlain(@FormParam("input") String input) { Long currentCounterValue = getCounter(); - currentCounterValue = currentCounterValue + (new Long(input)).longValue(); + currentCounterValue = currentCounterValue + (new Long(input)).longValue(); setCounter(currentCounterValue); return "Plain-Text: TCPTimeCounter counter increased by " + input + " to " + currentCounterValue; } @@ -60,9 +64,14 @@ public class TCPTimeCounterRESTService { @Produces(MediaType.TEXT_HTML) public String incrCounterHtml(@FormParam("input") String input) { Long currentCounterValue = getCounter(); - currentCounterValue = currentCounterValue + (new Long(input)).longValue(); + currentCounterValue = currentCounterValue + (new Long(input)).longValue(); setCounter(currentCounterValue); - return "TCPTimeCounter counter increased by " + input + " to " + currentCounterValue + "</h2></body></html>"; + return "<html><head><title>TCPTimeCounter REST Service" + + "

Verteilte Systeme HS Fulda - TCPTimeCounter REST Service

" + + "

HTML-Output: counter increased by " + + input + " to " + currentCounterValue + "

" + + "
" + + "
"; } @POST @@ -72,7 +81,8 @@ public class TCPTimeCounterRESTService { Long currentCounterValue = getCounter(); currentCounterValue = currentCounterValue + (new Long(input)).longValue(); setCounter(currentCounterValue); - return "{\n \"type\": \"JSON\",\n \"output\": \"Plain-Text: TCPTimeCounter counter increased by " + input + " to " + currentCounterValue + "\"\n}"; - } - + return "{\n \"type\": \"JSON\",\n \"output\": \"Plain-Text: TCPTimeCounter counter increased by " + input + + " to " + currentCounterValue + "\"\n}"; + } + } \ No newline at end of file