...36import org.openqa.selenium.grid.server.BaseServerFlags;37import org.openqa.selenium.grid.server.BaseServerOptions;38import org.openqa.selenium.grid.server.EventBusFlags;39import org.openqa.selenium.grid.server.EventBusOptions;40import org.openqa.selenium.grid.server.NetworkOptions;41import org.openqa.selenium.grid.server.Server;42import org.openqa.selenium.grid.sessionmap.SessionMap;43import org.openqa.selenium.grid.sessionmap.local.LocalSessionMap;44import org.openqa.selenium.grid.web.CombinedHandler;45import org.openqa.selenium.grid.web.RoutableHttpClientFactory;46import org.openqa.selenium.net.NetworkUtils;47import org.openqa.selenium.netty.server.NettyServer;48import org.openqa.selenium.remote.http.HttpClient;49import java.net.URI;50import java.net.URISyntaxException;51import java.util.Set;52import java.util.logging.Logger;53@AutoService(CliCommand.class)54public class Standalone extends TemplateGridCommand {55 private static final Logger LOG = Logger.getLogger("selenium");56 @Override57 public String getName() {58 return "standalone";59 }60 @Override61 public String getDescription() {62 return "The selenium server, running everything in-process.";63 }64 @Override65 protected Set<Object> getFlagObjects() {66 return ImmutableSet.of(67 new BaseServerFlags(),68 new DockerFlags(),69 new EventBusFlags(),70 new StandaloneFlags());71 }72 @Override73 protected String getSystemPropertiesConfigPrefix() {74 return "selenium";75 }76 @Override77 protected Config getDefaultConfig() {78 return new DefaultStandaloneConfig();79 }80 @Override81 protected void execute(Config config) throws Exception {82 LoggingOptions loggingOptions = new LoggingOptions(config);83 Tracer tracer = loggingOptions.getTracer();84 EventBusOptions events = new EventBusOptions(config);85 EventBus bus = events.getEventBus();86 String hostName;87 try {88 hostName = new NetworkUtils().getNonLoopbackAddressOfThisMachine();89 } catch (WebDriverException e) {90 hostName = "localhost";91 }92 int port = config.getInt("server", "port")93 .orElseThrow(() -> new IllegalArgumentException("No port to use configured"));94 URI localhost = null;95 try {96 localhost = new URI("http", null, hostName, port, null, null, null);97 } catch (URISyntaxException e) {98 throw new IllegalArgumentException(e);99 }100 NetworkOptions networkOptions = new NetworkOptions(config);101 CombinedHandler combinedHandler = new CombinedHandler();102 HttpClient.Factory clientFactory = new RoutableHttpClientFactory(103 localhost.toURL(),104 combinedHandler,105 networkOptions.getHttpClientFactory(tracer));106 SessionMap sessions = new LocalSessionMap(tracer, bus);107 combinedHandler.addHandler(sessions);108 Distributor distributor = new LocalDistributor(tracer, bus, clientFactory, sessions, null);109 combinedHandler.addHandler(distributor);110 Router router = new Router(tracer, clientFactory, sessions, distributor);111 LocalNode.Builder nodeBuilder = LocalNode.builder(112 tracer,113 bus,114 clientFactory,...