本文整理了Java中org.apache.catalina.connector.Connector.setPort()
方法的一些代码示例,展示了Connector.setPort()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Connector.setPort()
方法的具体详情如下:
包路径:org.apache.catalina.connector.Connector
类名称:Connector
方法名:setPort
[英]Set the port number on which we listen for requests.
[中]设置侦听请求的端口号。
代码示例来源:origin: macrozheng/mall
private Connector createStandardConnector() {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setPort(port);
return connector;
}
}
代码示例来源:origin: SonarSource/sonarqube
private Connector newConnector(String protocol, String schema) {
Connector httpConnector = new Connector(protocol);
httpConnector.setScheme(schema);
httpConnector.setPort(1234);
return httpConnector;
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public void setup() {
Connector connector = new Connector(Http11NioProtocol.class.getName());
connector.setPort(0);
File baseDir = createTempDir("tomcat");
String baseDirPath = baseDir.getAbsolutePath();
this.tomcatServer = new Tomcat();
this.tomcatServer.setBaseDir(baseDirPath);
this.tomcatServer.setPort(0);
this.tomcatServer.getService().addConnector(connector);
this.tomcatServer.setConnector(connector);
}
代码示例来源:origin: SonarSource/sonarqube
private static Connector newHttpConnector(Props props) {
// Not named "sonar.web.http.port" to keep backward-compatibility
int port = props.valueAsInt("sonar.web.port", 9000);
if (port < 0) {
throw new IllegalStateException(format("HTTP port '%s' is invalid", port));
}
Connector connector = new Connector(HTTP_PROTOCOL);
connector.setURIEncoding("UTF-8");
connector.setProperty("address", props.value("sonar.web.host", "0.0.0.0"));
connector.setProperty("socket.soReuseAddress", "true");
configurePool(props, connector);
configureCompression(connector);
configureMaxHttpHeaderSize(connector);
connector.setPort(port);
connector.setMaxPostSize(MAX_POST_SIZE);
return connector;
}
代码示例来源:origin: line/armeria
@Override
public Connector apply(String hostname) {
// Create the connector with our protocol handler. Tomcat will call ProtocolHandler.setAdapter()
// on its startup with the Coyote Adapter which gives an access to Tomcat's HTTP service pipeline.
final Class<?> protocolType = TomcatService.PROTOCOL_HANDLER_CLASS;
final Connector connector = new Connector(protocolType.getName());
// We do not really open a port - just trying to stop the Connector from complaining.
connector.setPort(0);
final StandardServer server = newServer(hostname, connector, config);
// Retrieve the components configured by newServer(), so we can use it in checkConfiguration().
final Service service = server.findServices()[0];
final Engine engine = TomcatUtil.engine(service, hostname);
final StandardHost host = (StandardHost) engine.findChildren()[0];
final Context context = (Context) host.findChildren()[0];
// Apply custom configurators set via TomcatServiceBuilder.configurator()
try {
config.configurators().forEach(c -> c.accept(server));
} catch (Throwable t) {
throw new TomcatServiceException("failed to configure an embedded Tomcat", t);
}
// Make sure the configurators did not ruin what we have configured in this method.
checkConfiguration(server, service, connector, engine, host, context);
assert connector.getService().getServer() != null;
return connector;
}
代码示例来源:origin: OryxProject/oryx
connector.setPort(port);
connector.setSecure(false);
connector.setScheme("http");
connector.setPort(securePort);
connector.setSecure(true);
connector.setScheme("https");
代码示例来源:origin: org.springframework.boot/spring-boot
protected void customizeConnector(Connector connector) {
int port = (getPort() >= 0) ? getPort() : 0;
connector.setPort(port);
if (StringUtils.hasText(this.getServerHeader())) {
connector.setAttribute("server", this.getServerHeader());
}
if (connector.getProtocolHandler() instanceof AbstractProtocol) {
customizeProtocol((AbstractProtocol<?>) connector.getProtocolHandler());
}
if (getUriEncoding() != null) {
connector.setURIEncoding(getUriEncoding().name());
}
// Don't bind to the socket prematurely if ApplicationContext is slow to start
connector.setProperty("bindOnInit", "false");
if (getSsl() != null && getSsl().isEnabled()) {
customizeSsl(connector);
}
TomcatConnectorCustomizer compression = new CompressionConnectorCustomizer(
getCompression());
compression.customize(connector);
for (TomcatConnectorCustomizer customizer : this.tomcatConnectorCustomizers) {
customizer.customize(connector);
}
}
代码示例来源:origin: org.springframework.boot/spring-boot
protected void customizeConnector(Connector connector) {
int port = (getPort() >= 0) ? getPort() : 0;
connector.setPort(port);
if (StringUtils.hasText(this.getServerHeader())) {
connector.setAttribute("server", this.getServerHeader());
}
if (connector.getProtocolHandler() instanceof AbstractProtocol) {
customizeProtocol((AbstractProtocol<?>) connector.getProtocolHandler());
}
if (getUriEncoding() != null) {
connector.setURIEncoding(getUriEncoding().name());
}
// Don't bind to the socket prematurely if ApplicationContext is slow to start
connector.setProperty("bindOnInit", "false");
if (getSsl() != null && getSsl().isEnabled()) {
customizeSsl(connector);
}
TomcatConnectorCustomizer compression = new CompressionConnectorCustomizer(
getCompression());
compression.customize(connector);
for (TomcatConnectorCustomizer customizer : this.tomcatConnectorCustomizers) {
customizer.customize(connector);
}
}
代码示例来源:origin: armzilla/amazon-echo-ha-bridge
private Connector createConnector(int portNumber) {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
connector.setScheme("http");
connector.setPort(portNumber);
return connector;
}
}
代码示例来源:origin: org.apache.geronimo.modules/geronimo-tomcat
/**
* Sets the network port that this connector listens on.
*/
public void setPort(int port) {
connector.setPort(port);
}
代码示例来源:origin: org.apache.geronimo.modules/geronimo-tomcat6
@Persistent(manageable=false)
public void setPort(int port) {
connector.setPort(port);
}
@Persistent(manageable=false)
代码示例来源: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: pippo-java/pippo
private void enableSSLConnector(Tomcat tomcat) {
log.info("Using https protocol");
Connector connector = tomcat.getConnector();
connector.setPort(getSettings().getPort());
connector.setSecure(true);
connector.setScheme("https");
connector.setAttribute("keyAlias", getSettings().getKeyAlias());
connector.setAttribute("keystorePass", getSettings().getKeystorePassword());
connector.setAttribute("keystoreType", getSettings().getKeyType());
connector.setAttribute("keystoreFile", getSettings().getKeystoreFile());
connector.setAttribute("clientAuth", getSettings().getClientAuth());
if (getSettings().getClientAuth()) {
connector.setAttribute("truststoreFile", getSettings().getTruststoreFile());
connector.setAttribute("truststorePass", getSettings().getTruststorePassword());
}
connector.setAttribute("protocol", "HTTP/1.1");
connector.setAttribute("sslProtocol", "TLS");
connector.setAttribute("maxThreads", getSettings().getMaxConnections());
connector.setAttribute("protocol", "org.apache.coyote.http11.Http11AprProtocol");
connector.setAttribute("SSLEnabled", true);
}
代码示例来源:origin: org.crazyyak.dev/yak-dev-embedded-tomcat
private Connector createAjpConnector(int port, int securePort){
System.out.println("Creating standard AJP connector on port " + port);
Connector connector = new Connector(org.apache.coyote.ajp.AjpNioProtocol.class.getName());
connector.setPort(port);
connector.setScheme("http");
connector.setSecure(false);
if (securePort > 0) {
connector.setRedirectPort(securePort);
}
return connector;
}
代码示例来源:origin: org.crazyyak.embedded/yak-embedded-tomcat
private Connector createAjpConnector(int port, int securePort){
System.out.println("Creating standard AJP connector on port " + port);
Connector connector = new Connector(org.apache.coyote.ajp.AjpNioProtocol.class.getName());
connector.setPort(port);
connector.setScheme("http");
connector.setSecure(false);
if (securePort > 0) {
connector.setRedirectPort(securePort);
}
return connector;
}
代码示例来源:origin: org.kurento/kurento-test
@Bean
@ConditionalOnMissingBean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setScheme("http");
connector.setPort(getAppHttpPort());
tomcat.addAdditionalTomcatConnectors(connector);
return tomcat;
}
}
代码示例来源:origin: nosqlcoco/springboot-weapp-demo
private Connector createStandardConnector() {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setScheme("http");
connector.setPort(port());
return connector;
}
}
代码示例来源:origin: je-ge/spring-boot
@Bean
public Connector httpConnector() {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setScheme("http");
// 表示用8080端口来供http访问
connector.setPort(8080);
connector.setSecure(false);
// 自动重定向到8443端口
connector.setRedirectPort(8443);
return connector;
}
}
代码示例来源:origin: Kurento/kurento-java
@Bean
@ConditionalOnMissingBean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setScheme("http");
connector.setPort(getAppHttpPort());
tomcat.addAdditionalTomcatConnectors(connector);
return tomcat;
}
}
代码示例来源:origin: sivaprasadreddy/jcart
private Connector initiateHttpConnector() {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setScheme("http");
connector.setPort(9090);
connector.setSecure(false);
connector.setRedirectPort(serverPort);
return connector;
}
}
内容来源于网络,如有侵权,请联系作者删除!