/** * Convenience method to {@link #of(Action) define} and {@link #start()} the server in one go. * * @param definition the server definition * @return the newly created and started server * @throws Exception any thrown by {@link #of(Action)} or {@link #start()} */ static RatpackServer start(Action<? super RatpackServerSpec> definition) throws Exception { RatpackServer server = of(definition); server.start(); return server; }
/** * Creates an embedded application from the given function. * * @param definition a function that defines the server * @return a newly created embedded application * @throws java.lang.Exception if an error is encountered creating the application * @see ratpack.server.RatpackServer#of(Action) */ static EmbeddedApp of(Action<? super RatpackServerSpec> definition) throws Exception { return fromServer(RatpackServer.of(d -> definition.execute(new EmbeddedRatpackServerSpec(d)))); }
@Bean public RatpackServer ratpackServer(ApplicationContext context) throws Exception { return RatpackServer.of(ratpackServerSpec -> ratpackServerSpec.serverConfig(serverConfig) .registry(joinedRegistry(context)).handlers(chainConfigurers)); }
/** * Creates an embedded application using the given server config, and server creating function. * * @param serverConfig the server configuration * @param definition a function to create the server to embed * @return a newly created embedded application */ static EmbeddedApp fromServer(ServerConfig serverConfig, Action<? super RatpackServerSpec> definition) { return fromServer(uncheck(() -> RatpackServer.of(b -> definition.execute(b.serverConfig(serverConfig))))); }