Class TomcatMicroservice
Wraps the Microservice + TomcatConfiguration bootstrap in a single static call so
a consumer can stand up a Tomcat microservice with one Maven dependency and one line of code:
Bundled defaults (all overridable):
- Port
8000 (surfaced asTomcat/port in a consumer-suppliedjuneau.cfg ). - Interactive console enabled (use
run(String[], Servlet, boolean)withstartConsole=falseto suppress). - An auto-created, auto-deleted temp Catalina base directory — a consumer-supplied
@Bean TomcatSettingswithTomcatSettings.Builder.baseDir(String)wins via the existingTomcatServerComponentresolution chain.
The supplied root servlet is registered as a @Bean Servlet in an external bean store and
auto-mounted by TomcatServerComponent
at the path declared by its @Rest annotation. Consumers
who want full control over the bean store / configuration classes / listener wiring should call
Microservice.create() directly — this facade is a thin convenience over that builder.
- Since:
- 10.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic MicroserviceBoots a Tomcat microservice with the supplied root servlet and the bundled defaults, with the interactive console enabled.static MicroserviceBoots a Tomcat microservice with the supplied root servlet and the bundled defaults.static Microservicerun(String[] args, WritableBeanStore beanStore, boolean startConsole, Class<?>... configurations) Power-user form: boots a Tomcat microservice with a caller-supplied bean store and configuration class list.
-
Method Details
-
run
Boots a Tomcat microservice with the supplied root servlet and the bundled defaults, with the interactive console enabled.Equivalent to calling
run(args, rootServlet, true).- Parameters:
args- Themain(String[])arguments. Forwarded toMicroservice.Builder#args(String...).rootServlet- The root REST servlet (typically annotated with@Rest).- Returns:
- The started
Microserviceinstance. Callers typically chainMicroservice.join(). - Throws:
Exception- Error occurred during bootstrap.
-
run
public static Microservice run(String[] args, jakarta.servlet.Servlet rootServlet, boolean startConsole) throws Exception Boots a Tomcat microservice with the supplied root servlet and the bundled defaults.Constructs the
Microservice, registers the supplied servlet as a@Bean ServletsoTomcatServerComponentauto-mounts it, appliesTomcatConfigurationso embedded Tomcat itself is wired, and starts the lifecycle. The returned microservice has not yet beenjoined; callers wanting the standard "start and block forever" loop should chain.join().- Parameters:
args- Themain(String[])arguments. Forwarded toMicroservice.Builder#args(String...).rootServlet- The root REST servlet (typically annotated with@Rest).startConsole- Iftrue , also starts the interactive console thread viaMicroservice.startConsole().- Returns:
- The started
Microserviceinstance. - Throws:
Exception- Error occurred during bootstrap.
-
run
public static Microservice run(String[] args, WritableBeanStore beanStore, boolean startConsole, Class<?>... configurations) throws Exception Power-user form: boots a Tomcat microservice with a caller-supplied bean store and configuration class list.Equivalent to writing the
Microservicebuilder chain by hand, but with the boilerplate collapsed. Use this when the simplerrun(String[], Servlet)overloads are too restrictive — e.g. multiple@Bean Servletcontributions, customMicroserviceListeners, or a parent bean store.- Parameters:
args- Themain(String[])arguments. Forwarded toMicroservice.Builder#args(String...).beanStore- The bean store to use for dependency injection. Pre-populated bean entries (@Bean Servlet,MicroserviceListener, etc.) are picked up byTomcatConfigurationand the microservice runtime.startConsole- Iftrue , also starts the interactive console thread.configurations- The@Configuration-annotated classes to register. Always includesTomcatConfiguration; pass an empty list to use only that.- Returns:
- The started
Microserviceinstance. - Throws:
Exception- Error occurred during bootstrap.
-