public JmxJettyServer(final Server server) { this.server = server; this.connector = server.getConnectors()[0]; }
/** * 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(); }
private void setStatsOnConnectors(final Server server) { final boolean isStatsOn = this.props.getBoolean("jetty.connector.stats", true); logger.info("Setting up connector with stats on: " + isStatsOn); for (final Connector connector : server.getConnectors()) { connector.setStatsOn(isStatsOn); } }
public void start() throws Exception { server.start(); port = server.getConnectors()[0].getLocalPort(); }
@Override public void stopInner() { try { if(httpServer != null) { httpServer.stop(); for(Connector c: httpServer.getConnectors()) { c.close(); } } if(context != null) context.destroy(); } catch(Exception e) { throw new VoldemortException(e); } this.httpServer = null; this.context = null; }
public String getRedirectUri() throws IOException { if ( this.port == -1 ) { this.port = getUnusedPort(); } this.server = new Server( this.port ); Connector[] arr$ = this.server.getConnectors(); int len$ = arr$.length; for ( int i$ = 0; i$ < len$; ++i$ ) { Connector c = arr$[i$]; c.setHost( this.host ); } this.server.addHandler( new CustomLocalServerReceiver.CallbackHandler() ); try { this.server.start(); } catch ( Exception var5 ) { Throwables.propagateIfPossible( var5 ); throw new IOException( var5 ); } return "http://" + this.host + ":" + this.port + "/Callback/success.html"; }
public JettySolandraRunner( String context, int port, String host) { this.context = context; server = new Server( port ); server.getConnectors()[0].setHost(host); server.setStopAtShutdown( true ); // Initialize the servlets Context root = new Context( server, context, Context.SESSIONS ); // for some reason, there must be a servlet for this to get applied root.addServlet( Servlet404.class, "/*" ); dispatchFilter = root.addFilter( SolandraDispatchFilter.class, "*", Handler.REQUEST ); }
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(); } }
/** * 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; }
/** * 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(); }
/** 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; }
private String baseFor(final Server jettyServer) { final Connector connector = jettyServer.getConnectors()[0]; final String scheme = "http"; final String host = StringUtils.coalesce(connector.getHost(), "localhost"); final int port = connector.getPort(); final WebAppContext handler = (WebAppContext) jettyServer.getHandler(); final String contextPath = handler.getContextPath(); final StringBuilder buf = new StringBuilder(); final Formatter formatter = new Formatter(buf); formatter.format("%s://%s:%d/%s", scheme, host, port, contextPath); return appendSlashIfRequired(buf).toString(); }
/** * @return the port the embedded HTTP server is listening to */ protected int getServerPort() { return server.getConnectors()[0].getLocalPort(); }