org.apache.catalina.connector.Connector.getLocalPort()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(176)

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

Connector.getLocalPort介绍

暂无

代码示例

代码示例来源:origin: org.springframework.boot/spring-boot

@Override
public int getPort() {
  Connector connector = this.tomcat.getConnector();
  if (connector != null) {
    return connector.getLocalPort();
  }
  return 0;
}

代码示例来源:origin: org.springframework.boot/spring-boot

private String getPortsDescription(boolean localPort) {
  StringBuilder ports = new StringBuilder();
  for (Connector connector : this.tomcat.getService().findConnectors()) {
    if (ports.length() != 0) {
      ports.append(' ');
    }
    int port = localPort ? connector.getLocalPort() : connector.getPort();
    ports.append(port).append(" (").append(connector.getScheme()).append(')');
  }
  return ports.toString();
}

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

@Override
public void start() throws Exception {
  this.tomcatServer.start();
  this.port = this.tomcatServer.getConnector().getLocalPort();
  this.context.addLifecycleListener(event -> {
    if (logger.isDebugEnabled()) {
      logger.debug("Event: " + event.getType());
    }
  });
}

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

@Override
protected void startInternal() throws LifecycleException {
  this.tomcatServer.start();
  setPort(this.tomcatServer.getConnector().getLocalPort());
}

代码示例来源:origin: AsyncHttpClient/async-http-client

ctx.addServletMappingDecoded("/*", "webdav");
tomcat.start();
port1 = tomcat.getConnector().getLocalPort();

代码示例来源:origin: AsyncHttpClient/async-http-client

ctx.addServletMappingDecoded("/*", "webdav");
tomcat.start();
port1 = tomcat.getConnector().getLocalPort();

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

public String getWsBaseUrl() {
  return "ws://localhost:" + this.tomcatServer.getConnector().getLocalPort();
}

代码示例来源:origin: com.github.mjeanroy/junit-servers-tomcat

@Override
protected int doGetPort() {
  return getConnector().getLocalPort();
}

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

@Override
protected void before() throws LifecycleException {
  this.tomcat = new Tomcat();
  this.tomcat.getConnector().setPort(0);
  Context context = this.tomcat.addContext("/", null);
  this.tomcat.addServlet("/", "test", new TestServlet());
  context.addServletMappingDecoded("/", "test");
  this.tomcat.addServlet("/", "set-cookie", new CookiesServlet());
  context.addServletMappingDecoded("/set-cookie", "set-cookie");
  this.tomcat.start();
  this.port = this.tomcat.getConnector().getLocalPort();
}

代码示例来源:origin: apache/tomcat-maven-plugin

portProperties.put( "tomcat.maven.http.port", Integer.toString( connector.getLocalPort() ) );
                   Integer.toString( connector.getLocalPort() ) );
System.setProperty( "tomcat.maven.http.port", Integer.toString( connector.getLocalPort() ) );
                     Integer.toString( httpsConnector.getLocalPort() ) );
  portProperties.put( "tomcat.maven.https.port", Integer.toString( httpsConnector.getLocalPort() ) );
  System.setProperty( "tomcat.maven.https.port", Integer.toString( httpsConnector.getLocalPort() ) );
                     Integer.toString( ajpConnector.getLocalPort() ) );
  portProperties.put( "tomcat.maven.ajp.port", Integer.toString( ajpConnector.getLocalPort() ) );
  System.setProperty( "tomcat.maven.ajp.port", Integer.toString( ajpConnector.getLocalPort() ) );

代码示例来源:origin: apache/tomcat-maven-plugin

portProperties.put( "tomcat.maven.http.port", Integer.toString( connector.getLocalPort() ) );
                   Integer.toString( connector.getLocalPort() ) );
System.setProperty( "tomcat.maven.http.port", Integer.toString( connector.getLocalPort() ) );
                     Integer.toString( httpsConnector.getLocalPort() ) );
  portProperties.put( "tomcat.maven.https.port", Integer.toString( httpsConnector.getLocalPort() ) );
  System.setProperty( "tomcat.maven.https.port", Integer.toString( httpsConnector.getLocalPort() ) );
                     Integer.toString( ajpConnector.getLocalPort() ) );
  portProperties.put( "tomcat.maven.ajp.port", Integer.toString( ajpConnector.getLocalPort() ) );
  System.setProperty( "tomcat.maven.ajp.port", Integer.toString( ajpConnector.getLocalPort() ) );

代码示例来源:origin: org.apache.tomee.patch/commons-jcs-jcache-extras

@Test
public void testFilter() throws Exception
{
  Hello.COUNTER.set(0);
  final Tomcat tomcat = new Tomcat();
  tomcat.setPort(0);
  try {
    tomcat.getEngine();
    tomcat.start();
    final Context ctx = tomcat.addContext("/sample", docBase.getAbsolutePath());
    Tomcat.addServlet(ctx, "hello", Hello.class.getName());
    ctx.addServletMapping("/", "hello");
    addJcsFilter(ctx);
    StandardContext.class.cast(ctx).filterStart();
    final URL url = new URL("http://localhost:" + tomcat.getConnector().getLocalPort() + "/sample/");
    assertEquals("hello", IOUtils.toString(url.openStream()));
    assertEquals(1, Hello.COUNTER.get());
    assertEquals("hello", IOUtils.toString(url.openStream()));
    assertEquals(1, Hello.COUNTER.get());
  } finally {
    stop(tomcat);
  }
}

代码示例来源:origin: org.apache.tomee.patch/commons-jcs-jcache-extras

@Test
public void testFilterNoOutput() throws Exception
{
  Empty.COUNTER.set(0);
  final Tomcat tomcat = new Tomcat();
  tomcat.setHostname("localhost");
  tomcat.setPort(0);
  try {
    tomcat.getEngine();
    tomcat.start();
    final Context ctx = tomcat.addWebapp("/sample", docBase.getAbsolutePath());
    Tomcat.addServlet(ctx, "empty", Empty.class.getName());
    ctx.addServletMapping("/", "empty");
    addJcsFilter(ctx);
    StandardContext.class.cast(ctx).filterStart();
    final URL url = new URL("http://localhost:" + tomcat.getConnector().getLocalPort() + "/sample/");
    assertEquals("", IOUtils.toString(url.openStream()));
    assertEquals(1, Empty.COUNTER.get());
    assertEquals("", IOUtils.toString(url.openStream()));
    assertEquals(1, Empty.COUNTER.get());
  } finally {
    stop(tomcat);
  }
}

代码示例来源:origin: com.bsb.common.vaadin/com.bsb.common.vaadin7.embed

/**
 * Fires the embedded tomcat that is assumed to be fully configured.
 *
 * @throws LifecycleException if tomcat failed to start
 */
private void doStart() throws LifecycleException {
  tomcat.getServer().addLifecycleListener(new TomcatLifecycleListener());
  logger.info("Deploying application to [" + getConfig().getDeployUrl() + "]");
  tomcat.start();
  // Let's set the port that was used to actually start the application if necessary
  if (getConfig().getPort() == EmbedVaadinConfig.DEFAULT_PORT) {
    getConfig().setPort(getTomcat().getConnector().getLocalPort());
  }
  logger.info("Application has been deployed to [" + getConfig().getDeployUrl() + "]");
  if (config.shouldOpenBrowser()) {
    BrowserUtils.openBrowser(getConfig().getOpenBrowserUrl());
  }
  if (isWaiting()) {
    tomcat.getServer().await();
  }
}

代码示例来源:origin: salyh/elasticsearch-security-plugin

networkService
      .resolveBindHostAddress(bindHost),
      tomcat.getConnector().getLocalPort());
} catch (final Exception e) {
  throw new BindTransportException(

相关文章

Connector类方法