@Override public void execute(RatpackServerSpec server) throws Exception { RatpackDslClosures closures = new RatpackDslClosures(null); RatpackDslBacking backing = new RatpackDslBacking(closures); ClosureUtil.configureDelegateFirst(backing, closure); server.registry(Guice.registry(ClosureUtil.delegatingAction(closures.getBindings()))); server.handlers(Groovy.chainAction(closures.getHandlers())); ServerConfigBuilder builder = ServerConfig.builder().development(true); if (ephemeralPort) { builder.port(0); } ClosureUtil.configureDelegateFirst(builder, closures.getServerConfig()); server.serverConfig(builder); }
/** * Creates a module to injector transformer based on the given launch config. * * <p>Delegates to {@link Guice#newInjectorFactory(ratpack.launch.LaunchConfig)}. * * @param launchConfig The launch config * @return the result of {@link Guice#newInjectorFactory(ratpack.launch.LaunchConfig)} with the * given launch config */ protected Function<? super Module, ? extends Injector> createInjectorFactory( LaunchConfig launchConfig) { return Guice.newInjectorFactory(launchConfig); }