/** * Returns a base URL consisting of the protocal, host, and port for a * Connector in use by the Jetty Server contained in this runner. */ public URL getBaseUrl() { String protocol = null; try { Connector[] conns = server.getConnectors(); if (0 == conns.length) { throw new IllegalStateException("Jetty Server has no Connectors"); } Connector c = conns[0]; if (c.getLocalPort() < 0) { throw new IllegalStateException("Jetty Connector is not open: " + c.getLocalPort()); } protocol = (c instanceof SslConnector) ? "https" : "http"; return new URL(protocol, c.getHost(), c.getLocalPort(), context); } catch (MalformedURLException e) { throw new IllegalStateException ("Java could not make sense of protocol: " + protocol, e); } }