This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package coffee.module; | |
import java.util.Random; | |
public class Coffee { | |
public enum CoffeeType { | |
AMERICANO, LATTE, CAPUCCINO, ESPRESSO, FLAT_WHITE, LONG_BLACK, MACHIATO, MOCHACCINO, IRISH, VIENNA, AFFOGATO | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void getEvent(ServerRequest serverRequest, ServerResponse serverResponse) { | |
serverRequest.context().get(MetricRegistry.class).ifPresent(reg -> reg.counter("eventCounter").inc()); | |
String eventId = serverRequest.path().param("eventId"); | |
sendResponse(serverResponse, THEDEVCONFAPI.getEvent(Integer.parseInt(eventId))); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Timed(name = "getEvents_timed") | |
@GET | |
@Produces(MediaType.APPLICATION_JSON) | |
public JsonObject getEventList(){ | |
String response = theDevConfAPI.getEventList(); | |
return JSON.createObjectBuilder() | |
.add("message", response) | |
.build(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static FlowFuture<BookingRes> retryCancel(String cancelFn, Object input, Throwable e) { | |
Retry.exponentialWithJitter( | |
() -> Flows.currentFlow().invokeFunction(cancelFn, input, BookingRes.class)); | |
return Flows.currentFlow().failedFuture(e); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static FlowFuture<BookingRes> cancel(String cancelFn, Object input, Throwable e) { | |
Flows.currentFlow().invokeFunction(cancelFn, input, BookingRes.class); | |
return Flows.currentFlow().failedFuture(e); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void book(TripReq input) { | |
Flow f = Flows.currentFlow(); | |
FlowFuture<BookingRes> flightFuture = | |
f.invokeFunction("./flight/book", input.flight, BookingRes.class); | |
FlowFuture<BookingRes> hotelFuture = | |
f.invokeFunction("./hotel/book", input.hotel, BookingRes.class); | |
FlowFuture<BookingRes> carFuture = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Stateless | |
public class AuthImpl implements Auth { | |
private String URL = "http://localhost:8080/javaEE8ExampleSSOAppService/resources/auth"; | |
@Override | |
public boolean isLogged(String token) { | |
return prepareWebTarget().path("/" + token) | |
.request() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Auth { | |
public boolean isLogged(String token); | |
public String login(String login, String password); | |
String logout(String token); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Path("app2") | |
public class App2 { | |
@Inject | |
private Auth auth; | |
@GET | |
public Response helloWorld(String token) { | |
if (!auth.isLogged(token)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Path("app1") | |
public class App1 { | |
@Inject | |
private Auth auth; | |
@GET | |
public Response helloWorld(String token) { | |
if (!auth.isLogged(token)) { |