private Builder _protocol(Protocol protocol, int port) { Map<Protocol, Integer> newPorts = new EnumMap<>(Protocol.class); newPorts.putAll(_config.ports()); newPorts.put(protocol, port); _config = new Server.Config(newPorts, _config.mode()); return this; } }
/** * Build the server and begin serving the provided routes as configured. * * @param block the router to use. * @return the actively running server. */ public Server build(Function<BuiltInComponents, Router> block) { Server.Config config = _buildConfig(); return new Server( JavaServerHelper.forRouter( JavaModeConverter.asScalaMode(config.mode()), OptionConverters.toScala(config.maybeHttpPort()), OptionConverters.toScala(config.maybeHttpsPort()), block ) ); }
/** * Build the server and begin serving the provided routes as configured. * * @param block the router to use. * @return the actively running server. */ public Server build(Function<BuiltInComponents, Router> block) { Server.Config config = _buildConfig(); return new Server( JavaServerHelper.forRouter( JavaModeConverter.asScalaMode(config.mode()), OptionConverters.toScala(config.maybeHttpPort()), OptionConverters.toScala(config.maybeHttpsPort()), block ) ); }
/** * Set the mode the server should be run on (defaults to TEST) * * @param mode the Play mode (dev, prod, test) * @return the builder with Server.Config set to mode. */ public Builder mode(Mode mode) { _config = new Server.Config(_config.ports(), mode); return this; }
private Server.Config _buildConfig() { Builder builder = this; if (_config.ports().isEmpty()) { builder = this._protocol(Protocol.HTTP, 0); } return builder._config; }
private Server.Config _buildConfig() { Builder builder = this; if (_config.ports().isEmpty()) { builder = this._protocol(Protocol.HTTP, 0); } return builder._config; }
/** * Set the mode the server should be run on (defaults to TEST) * * @param mode the Play mode (dev, prod, test) * @return the builder with Server.Config set to mode. */ public Builder mode(Mode mode) { _config = new Server.Config(_config.ports(), mode); return this; }
private Builder _protocol(Protocol protocol, int port) { Map<Protocol, Integer> newPorts = new EnumMap<>(Protocol.class); newPorts.putAll(_config.ports()); newPorts.put(protocol, port); _config = new Server.Config(newPorts, _config.mode()); return this; } }