/** * Returns the Local Port of the first Connector found for the jetty Server. * @exception RuntimeException if there is no Connector */ public int getLocalPort() { Connector[] conns = server.getConnectors(); if (0 == conns.length) { throw new RuntimeException("Jetty Server has no Connectors"); } return conns[0].getLocalPort(); }
public void start() throws Exception { server.start(); port = server.getConnectors()[0].getLocalPort(); }
public void start() throws Exception { server = new Server(port); server.setHandler(new AppsResourceHandler()); server.start(); port = server.getConnectors()[0].getLocalPort(); }
@Before public void setupLocalServer() throws Exception { // Set up a local Jetty HTTP server Server server = new Server(); server.addConnector(new SocketConnector()); ResourceHandler resourceHandler = new ResourceHandler(); resourceHandler.setResourceBase("src/test/resources/server"); server.addHandler(resourceHandler); server.start(); // The server will have a random port assigned, so capture that localPort = server.getConnectors()[0].getLocalPort(); }
protected final int getPort() { return this.server.getConnectors()[0].getLocalPort(); } }
/** * Returns the Local Port of the first Connector found for the jetty Server. * @exception RuntimeException if there is no Connector */ public int getLocalPort() { Connector[] conns = server.getConnectors(); if (0 == conns.length) { throw new RuntimeException("Jetty Server has no Connectors"); } return conns[0].getLocalPort(); }
/** * Get the port that the server is on * @return the port */ @Deprecated public int getPort() { return webServer.getConnectors()[0].getLocalPort(); }
/** * Get the port that the server is on * @return the port */ @Deprecated public int getPort() { return webServer.getConnectors()[0].getLocalPort(); }
/** * Get the port that the server is on * @return the port */ public int getPort() { return webServer.getConnectors()[0].getLocalPort(); }
/** * Get the port that the server is on * @return the port */ public int getPort() { return webServer.getConnectors()[0].getLocalPort(); }
/** * Get the port that the server is on * @return the port */ @Deprecated public int getPort() { return webServer.getConnectors()[0].getLocalPort(); }
/** * Get the port that the server is on * * @return the port */ public int getPort() { return webServer.getConnectors()[0].getLocalPort(); }
/** * Get the port that the server is on * @return the port */ @Deprecated public int getPort() { return webServer.getConnectors()[0].getLocalPort(); }
/** * Get the port that corresponds to a particular connector. In the case of * HDFS, the second connector corresponds to the HTTPS connector. * * @return the corresponding port for the connector, or -1 if there's no such * connector. */ public int getConnectorPort(int index) { Preconditions.checkArgument(index >= 0); return index < webServer.getConnectors().length ? webServer.getConnectors()[index].getLocalPort() : -1; }
/** * Return the bind address of the listener. * @return InetSocketAddress of the listener */ public InetSocketAddress getListenerAddress() { int port = listener.getLocalPort(); if (port == -1) { // not bound, return requested port port = listener.getPort(); } return new InetSocketAddress(listener.getHost(), port); }
/** Returns the port assigned to the server. * * @return the port assigned to the server. */ public static int getPort() { if ( port == 0 ) { if ( ! SERVER.isStarted() ) throw new IllegalStateException( "The server is not started yet" ); port = SERVER.getConnectors()[ 0 ].getLocalPort(); } return port; }
/** Returns the port assigned to the server. * * @return the port assigned to the server. */ public static int getPort() { if ( port == 0 ) { if ( ! SERVER.isStarted() ) throw new IllegalStateException( "The server is not started yet" ); port = SERVER.getConnectors()[ 0 ].getLocalPort(); } return port; }
/** * Return the host and port of the HttpServer, if live * @return the classname and any HTTP URL */ @Override public String toString() { return listener != null ? ("HttpServer at http://" + listener.getHost() + ":" + listener.getLocalPort() + "/" + (isAlive() ? STATE_DESCRIPTION_ALIVE : STATE_DESCRIPTION_NOT_LIVE)) : "Inactive HttpServer"; }
/** * Return the host and port of the HttpServer, if live * @return the classname and any HTTP URL */ @Override public String toString() { return listener != null ? ("HttpServer at http://" + listener.getHost() + ":" + listener.getLocalPort() + "/" + (isAlive() ? STATE_DESCRIPTION_ALIVE : STATE_DESCRIPTION_NOT_LIVE)) : "Inactive HttpServer"; }
/** * @return the port the embedded HTTP server is listening to */ protected int getServerPort() { return server.getConnectors()[0].getLocalPort(); }