public class AsyncMapper extends Object implements Route.Mapper
Map Callable
and CompletableFuture
results to Deferred API
.
{
map(new AsyncMapper());
get("/callable", () -> {
return new Callable<String> () {
public String call() {
return "OK";
}
};
});
get("/completable-future", () -> {
return CompletableFuture.supplyAsync(() -> "OK");
});
}
From Mvc route you can return a callable:
public class Controller {
@GET
@Path("/async")
public Callable<String> async() {
return "Success";
}
}
Constructor and Description |
---|
AsyncMapper() |
Modifier and Type | Method and Description |
---|---|
Object |
map(Object value)
Map the type to something else.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
chain, create, name
public Object map(Object value) throws Throwable
Route.Mapper
map
in interface Route.Mapper
value
- Value to map.
Throwable
- If mapping fails.
Copyright © 2019. All rights reserved.