Reputation: 4555
I am writing a Java command-line application intended to read and write from a database and just finish executing, once it is done with its work.
It will never expose a REST interface to anyone nor will it need to start a server and listen on any ports.
So the app is something like this:
public class Main {
public static void main(final String[] args) {
// Start Helidon CDI, JTA, etc. - but not JAX-RS
// No: Server.create().start();
// No: io.helidon.microprofile.cdi.Main.main(args);
// Do work
MyApp myApp = CDI.current().select(MyApp.class).get();
app.run();
// Shutdown
io.helidon.microprofile.cdi.Main.shutdown();
}
}
But however I initialize the Helidon framework a web server is launched and starts to listen on port 8080 (or whatever). Even when using Helidon's Main.main(...) method a web server is launched.
So how do I startup/initialize Helidon for use with a command-line app with CDI, JTA, JPA but no web server?
In terms of Spring Boot I think I am requesting the Helidon equivalent of a CommandLineRunner
.
Upvotes: 0
Views: 520
Reputation: 16238
If all you want to do is start a CDI container so that your application can be managed by CDI, then you could probably just use SeContainerInitializer
, which is just ordinary CDI. You can do this with or without Helidon.
If you want to use the Helidon JPA/JTA features, they are exposed via ordinary CDI portable extension machinery, so just put them on your classpath.
Upvotes: 0