in java/showcase/src/main/java/org/apache/flink/statefun/playground/java/showcase/part6/serving/GreeterAppServer.java [72:92]
public static void main(String[] args) {
// Register the functions that you want to serve ...
final StatefulFunctions functions = new StatefulFunctions();
functions.withStatefulFunction(UserFn.SPEC);
functions.withStatefulFunction(GreetingsFn.SPEC);
// ... and build a request-reply handler for the registered functions, which understands how to
// decode invocation requests dispatched from StateFun / encode side-effects (e.g. state storage
// updates, or invoking other functions) as responses to be handled by StateFun.
final RequestReplyHandler requestReplyHandler = functions.requestReplyHandler();
// Use the request-reply handler along with your favorite HTTP web server framework
// to serve the functions!
final Undertow httpServer =
Undertow.builder()
.addHttpListener(PORT, "localhost")
.setHandler(new UndertowHttpHandler(requestReplyHandler))
.build();
httpServer.start();
}