org.eclipse.jetty.server.Server.getConnectors()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(186)

本文整理了Java中org.eclipse.jetty.server.Server.getConnectors()方法的一些代码示例,展示了Server.getConnectors()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Server.getConnectors()方法的具体详情如下:
包路径:org.eclipse.jetty.server.Server
类名称:Server
方法名:getConnectors

Server.getConnectors介绍

暂无

代码示例

代码示例来源:origin: apache/storm

/**
 * The port the HTTP server is listening on. Not available until {@link #start() } has run.
 * @return The port the HTTP server is listening on. Not available until {@link #start() } has run.
 */
public int getHttpServerPort() {
  assert httpServer.getConnectors().length == 1;
  
  return ((ServerConnector) (httpServer.getConnectors()[0])).getLocalPort();
}

代码示例来源:origin: dropwizard/dropwizard

/**
 * Return the local port of the first {@link ServerConnector} in the
 * provided {@link Server} instance.
 *
 * @param server Server instance to use
 * @return First local port of the server instance
 */
default int getLocalPort(Server server) {
  return ((ServerConnector) server.getConnectors()[0]).getLocalPort();
}

代码示例来源:origin: dropwizard/dropwizard

/**
   * Return the local port of the last {@link ServerConnector} in the
   * provided {@link Server} instance. This may be the same value as returned
   * by {@link #getLocalPort(Server)} if using the "simple" server configuration.
   *
   * @param server Server instance to use
   * @return Last local port or the server instance
   */
  default int getAdminPort(Server server) {
    final Connector[] connectors = server.getConnectors();
    return ((ServerConnector) connectors[connectors.length - 1]).getLocalPort();
  }
}

代码示例来源:origin: dropwizard/dropwizard

public int getAdminPort() {
  final Connector[] connectors = requireNonNull(jettyServer).getConnectors();
  return ((ServerConnector) connectors[connectors.length - 1]).getLocalPort();
}

代码示例来源:origin: dropwizard/dropwizard

public int getLocalPort() {
  return ((ServerConnector) requireNonNull(jettyServer).getConnectors()[0]).getLocalPort();
}

代码示例来源:origin: dropwizard/dropwizard

public int getPort(int connectorIndex) {
  return ((ServerConnector) requireNonNull(jettyServer).getConnectors()[connectorIndex]).getLocalPort();
}

代码示例来源:origin: Alluxio/alluxio

/**
 * Shuts down the web server.
 */
public void stop() throws Exception {
 // close all connectors and release all binding ports
 for (Connector connector : mServer.getConnectors()) {
  connector.stop();
 }
 mServer.stop();
}

代码示例来源:origin: apache/hbase

/**
 * Get the port that the server is on
 * @return the port
 */
@Deprecated
public int getPort() {
 return ((ServerConnector)webServer.getConnectors()[0]).getLocalPort();
}

代码示例来源:origin: apache/hive

public int getPort() {
 return ((ServerConnector)(webServer.getConnectors()[0])).getLocalPort();
}

代码示例来源:origin: spring-projects/spring-framework

public int getPort() {
    return ((ServerConnector) this.server.getConnectors()[0]).getLocalPort();
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Override
protected void startInternal() throws Exception {
  this.jettyServer.start();
  setPort(((ServerConnector) this.jettyServer.getConnectors()[0]).getLocalPort());
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public void start() throws Exception {
  this.jettyServer.start();
  this.contextHandler.start();
  Connector[] connectors = jettyServer.getConnectors();
  NetworkConnector connector = (NetworkConnector) connectors[0];
  this.port = connector.getLocalPort();
}

代码示例来源:origin: neo4j/neo4j

private int getLocalPort( Server server )
{
  return ((ServerConnector) (server.getConnectors()[0])).getLocalPort();
}

代码示例来源:origin: pentaho/pentaho-kettle

private List<SocketConnector> getSocketConnectors( WebServer wServer ) {
 List<SocketConnector> sConnectors = new ArrayList<SocketConnector>();
 Connector[] connectors = wServer.getServer().getConnectors();
 for ( Connector cn : connectors ) {
  if ( cn instanceof SocketConnector ) {
   sConnectors.add( (SocketConnector) cn );
  }
 }
 return sConnectors;
}

代码示例来源:origin: confluentinc/ksql

public String getServerAddress() {
 if (server == null) {
  throw new IllegalStateException("Not started");
 }
 final int localPort = ((NetworkTrafficServerConnector) server.getConnectors()[0])
   .getLocalPort();
 
 return "http://localhost:"+ localPort;
}

代码示例来源:origin: spring-projects/spring-framework

@BeforeClass
public static void startJettyServer() throws Exception {
  // Let server pick its own random, available port.
  jettyServer = new Server(0);
  ServletContextHandler handler = new ServletContextHandler();
  MultipartConfigElement multipartConfig = new MultipartConfigElement("");
  ServletHolder holder = new ServletHolder(partsServlet);
  holder.getRegistration().setMultipartConfig(multipartConfig);
  handler.addServlet(holder, "/parts");
  holder = new ServletHolder(partListServlet);
  holder.getRegistration().setMultipartConfig(multipartConfig);
  handler.addServlet(holder, "/partlist");
  jettyServer.setHandler(handler);
  jettyServer.start();
  Connector[] connectors = jettyServer.getConnectors();
  NetworkConnector connector = (NetworkConnector) connectors[0];
  baseUrl = "http://localhost:" + connector.getLocalPort();
}

代码示例来源:origin: spring-projects/spring-framework

@BeforeClass
public static void startServer() throws Exception {
  // Let server pick its own random, available port.
  server = new Server(0);
  ServletContextHandler handler = new ServletContextHandler();
  handler.setContextPath("/");
  Class<?> config = CommonsMultipartResolverTestConfig.class;
  ServletHolder commonsResolverServlet = new ServletHolder(DispatcherServlet.class);
  commonsResolverServlet.setInitParameter("contextConfigLocation", config.getName());
  commonsResolverServlet.setInitParameter("contextClass", AnnotationConfigWebApplicationContext.class.getName());
  handler.addServlet(commonsResolverServlet, "/commons-resolver/*");
  config = StandardMultipartResolverTestConfig.class;
  ServletHolder standardResolverServlet = new ServletHolder(DispatcherServlet.class);
  standardResolverServlet.setInitParameter("contextConfigLocation", config.getName());
  standardResolverServlet.setInitParameter("contextClass", AnnotationConfigWebApplicationContext.class.getName());
  standardResolverServlet.getRegistration().setMultipartConfig(new MultipartConfigElement(""));
  handler.addServlet(standardResolverServlet, "/standard-resolver/*");
  server.setHandler(handler);
  server.start();
  Connector[] connectors = server.getConnectors();
  NetworkConnector connector = (NetworkConnector) connectors[0];
  baseUrl = "http://localhost:" + connector.getLocalPort();
}

代码示例来源:origin: ninjaframework/ninja

private void tryToSetHostAndPortFromJetty() {
  // do best attempt at fetching port jetty will start with
  Connector[] connectors = jetty.getConnectors();
  if (connectors != null && connectors.length > 0 && connectors[0] instanceof ServerConnector) {
    ServerConnector connector = (ServerConnector)connectors[0];
    host(connector.getHost());
    port(connector.getPort());
  }
}

代码示例来源:origin: apache/geode

@Test
public void testSetPortNoBindAddress() {
 final HttpService jetty = new HttpService(null, 8090, SSLConfigurationFactory
   .getSSLConfigForComponent(distributionConfig, SecurableCommunicationChannel.WEB));
 assertThat(jetty).isNotNull();
 assertThat(jetty.getHttpServer().getConnectors()[0]).isNotNull();
 assertThat(((ServerConnector) jetty.getHttpServer().getConnectors()[0]).getPort())
   .isEqualTo(8090);
}

代码示例来源:origin: jphp-group/jphp

@Signature
public Memory connectors() {
  Connector[] connectors = server.getConnectors();
  ArrayMemory arrayMemory = ArrayMemory.createListed(connectors.length);
  for (Connector connector : connectors) {
    arrayMemory.add(connector.getName());
  }
  return arrayMemory.toImmutable();
}

相关文章