Thank you for your recommendation. I had gone through it.
I have a framework where I need to feed Dropwizzard HTTPServer, so that framework will start and stop the server.
SpringBoot, Oracle J4C/Helidon can be plugged to that. We need to support Dropwizzarad as well.
In case of Helidon we do as shown below;
public synchronized Startable<Void> getUserServer() {
if (userServer == null) {
final io.helidon.webserver.Routing.Builder routingBuilder = getRoutingBuilder();
final io.helidon.webserver.ServerConfiguration.Builder serverConfigBuilder = getServerConfigBuilder();
customizeServerConfig(serverConfigBuilder);
customizeRouting(routingBuilder);
final io.helidon.webserver.WebServer server = WebServer.create(serverConfigBuilder.build(), routingBuilder.build());
this.userServer = new J4CStartable(server);
}
return userServer;
}
private static class J4CStartable implements Startable<Void> {
private final WebServer webserver;
private J4CStartable(final WebServer webserver) {
this.webserver = webserver;
}
@Override
public CompletionStage<Void> start() {
return this.webserver.start().exceptionally(t -> {
if (t != null) {
final Throwable t2 = ExceptionUtils.getCause(t);
if (t2 instanceof SocketException && "Permission denied".equals(t2.getMessage()) && webserver.configuration().port() < 1024) {
throw new RuntimeException("Permission denied (Possibly trying to bind to port < 1024 as non-root user)", t);
} else {
throw new RuntimeException(t);
}
}
return null;
}).thenApply(s -> null);
}
@Override
public CompletionStage<Void> stop() {
return this.webserver.shutdown().thenApply(s -> null);
}
}
When we execute below in tutorial which code starts the HTTP server? I believe I would need the same stuff.
java -jar target/hello-world-0.0.1-SNAPSHOT.jar server hello-world.yml
Thank you once again.
regards,
Robin Kuttaiah