Commits

Stephen McKamey committed ce4d4d3

fixing conflict between ResponseBuilder and ActionTimer

Comments (0)

Files changed (4)

duel-mvcapp-archetype/src/main/resources/archetype-resources/src/main/java/aspects/ActionTimer.java

 		}
 
 		// emit a header with the timing
-		ResponseBuilder response = (result instanceof Response) ? Response.fromResponse((Response)result) : Response.ok(result);
+		ResponseBuilder response =
+			(result instanceof ResponseBuilder) ? (ResponseBuilder)result :
+			(result instanceof Response) ? Response.fromResponse((Response)result) :
+			Response.ok(result);
 		return response.header("X-Action-MS", elapsed).build();
 	}
 }

duel-mvcapp-archetype/src/main/resources/archetype-resources/src/main/java/controllers/PingController.java

 package ${package}.controllers;
 
 import javax.ws.rs.*;
+import javax.ws.rs.core.Response;
 import com.google.inject.*;
 
 /**
 	@Produces("text/plain")
 	public Object ping() {
 
-		// TODO: perform service health test
-		return "OK";
+		// TODO: perform service health tests
+
+		//return non-OK status to pull server from pool
+		return Response.ok("pong");
 	}
 }

mvcapp/src/main/java/com/example/mvcapp/aspects/ActionTimer.java

 		}
 
 		// emit a header with the timing
-		ResponseBuilder response = (result instanceof Response) ? Response.fromResponse((Response)result) : Response.ok(result);
+		ResponseBuilder response =
+			(result instanceof ResponseBuilder) ? (ResponseBuilder)result :
+			(result instanceof Response) ? Response.fromResponse((Response)result) :
+			Response.ok(result);
 		return response.header("X-Action-MS", elapsed).build();
 	}
 }

mvcapp/src/main/java/com/example/mvcapp/controllers/PingController.java

 package com.example.mvcapp.controllers;
 
 import javax.ws.rs.*;
+import javax.ws.rs.core.Response;
 import com.google.inject.*;
 
 /**
 	@Produces("text/plain")
 	public Object ping() {
 
-		// TODO: perform service health test
-		return "OK";
+		// TODO: perform service health tests
+
+		//return non-OK status to pull server from pool
+		return Response.ok("pong");
 	}
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.