@Override synchronized public void removeConnector(String host, int port) { Connector[] connectors = server.getConnectors(); for (Connector connector : connectors) { if (connector.getHost().equals(host) && connector.getLocalPort() == port) { if (connector.isStarted() || connector.isStarting()) { try { connector.stop(); } catch (Exception ex) { log.severe("Couldn't stop connector: " + connector + " " + ex); throw new RuntimeException(ex); } } server.removeConnector(connector); if (connectors.length == 1) { log.info("No more connectors, stopping Jetty server"); stopIfRunning(); } break; } } }
/** * Gets the actual bind hostname. * * @return the bind host */ public String getBindHost() { String bindHost = mServer.getServer().getConnectors()[0].getHost(); return bindHost == null ? "0.0.0.0" : bindHost; }
public String getHost() { return connector.getHost(); }
/** * Get the InetSocketAddress of the server. * * @return InetSocketAddress of server. */ public InetSocketAddress getSocketAddress() { if (!server.isRunning()) { throw new IllegalStateException("Server not started yet"); } // assumes we only have one connector Connector connector = server.getConnectors()[0]; return new InetSocketAddress(connector.getHost(), connector.getLocalPort()); }
/** * Get the URI to reference this server. * <p> * The returned URI includes the proper host name and port number, but does * not contain a path. * * @return URI to reference this server's root context. */ public URI getURI() { assertAlreadySetUp(); String host = connector.getHost(); if (host.contains(":") && !host.startsWith("[")) host = "[" + host + "]"; final String uri = "http://" + host + ":" + getPort(); try { return new URI(uri); } catch (URISyntaxException e) { throw new RuntimeException("Unexpected URI error on " + uri, e); } }
@Override synchronized public void removeConnector(String host, int port) { Connector[] connectors = server.getConnectors(); for (Connector connector : connectors) { if (connector.getHost().equals(host) && connector.getLocalPort() == port) { if (connector.isStarted() || connector.isStarting()) { try { connector.stop(); } catch (Exception ex) { log.severe("Couldn't stop connector: " + connector + " " + ex); throw new RuntimeException(ex); } } server.removeConnector(connector); if (connectors.length == 1) { log.info("No more connectors, stopping Jetty server"); stopIfRunning(); } break; } } }
public void start() throws Exception { Connector connector; if (enableSsl) { SslContextFactory sslContextFactory = new SslContextFactory(); if (sslContext == null) { } else { System.out.println("Using provided SSLContext"); System.out.println(sslContext); sslContextFactory.setSslContext(sslContext); } connector = new SslSelectChannelConnector(); ((SslSelectChannelConnector) connector).setSslContext(sslContext); } else { connector = new SelectChannelConnector(); } connector.setPort(port); server.addConnector(connector); connector.open(); server.setHandler(contexts); server.start(); if (enableSsl) { protocol = "https"; } else { protocol = "http"; } port = connector.getLocalPort(); host = connector.getHost(); }
String host = (connectors==null||connectors[0]==null?"":connectors[0].getHost()); if (host == null) host = "0.0.0.0";
String host = (connectors==null||connectors[0]==null?"":connectors[0].getHost()); if (host == null) host = "0.0.0.0";
String host = (connectors==null||connectors[0]==null?"":connectors[0].getHost()); if (host == null) host = "0.0.0.0";
InetSocketAddress inetSocketAddress = new InetSocketAddress(connector.getHost(), connector.getLocalPort()); serviceCancellable = discoveryService.register( ResolvingDiscoverable.of(new Discoverable(Constants.Service.EXTERNAL_AUTHENTICATION, inetSocketAddress)));