Skip to content

Instantly share code, notes, and snippets.

View eldermoraes's full-sized avatar
🤓
Coding

Elder Moraes eldermoraes

🤓
Coding
View GitHub Profile
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
}
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)));
}
@Timed(name = "getEvents_timed")
@GET
@Produces(MediaType.APPLICATION_JSON)
public JsonObject getEventList(){
String response = theDevConfAPI.getEventList();
return JSON.createObjectBuilder()
.add("message", response)
.build();
}
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);
}
private static FlowFuture<BookingRes> cancel(String cancelFn, Object input, Throwable e) {
Flows.currentFlow().invokeFunction(cancelFn, input, BookingRes.class);
return Flows.currentFlow().failedFuture(e);
}
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 =
@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()
public interface Auth {
public boolean isLogged(String token);
public String login(String login, String password);
String logout(String token);
}
@Path("app2")
public class App2 {
@Inject
private Auth auth;
@GET
public Response helloWorld(String token) {
if (!auth.isLogged(token)) {
@Path("app1")
public class App1 {
@Inject
private Auth auth;
@GET
public Response helloWorld(String token) {
if (!auth.isLogged(token)) {