本文整理了Java中org.apache.catalina.connector.Connector
类的一些代码示例,展示了Connector
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Connector
类的具体详情如下:
包路径:org.apache.catalina.connector.Connector
类名称:Connector
[英]Implementation of a Coyote connector.
[中]郊狼连接器的实现。
代码示例来源:origin: OryxProject/oryx
private Connector makeConnector() {
Connector connector = new Connector(Http11Nio2Protocol.class.getName());
connector.setPort(port);
connector.setSecure(false);
connector.setScheme("http");
connector.setPort(securePort);
connector.setSecure(true);
connector.setScheme("https");
connector.setAttribute("SSLEnabled", "true");
SSLHostConfig sslHostConfig = new SSLHostConfig();
SSLHostConfigCertificate cert =
cert.setCertificateKeyAlias(keyAlias);
sslHostConfig.addCertificate(cert);
connector.addSslHostConfig(sslHostConfig);
connector.addUpgradeProtocol(new Http2Protocol());
connector.setXpoweredBy(false);
connector.setAttribute("maxThreads", 400);
connector.setAttribute("acceptCount", 50);
connector.setAttribute("maxKeepAliveRequests", 100);
connector.setAttribute("socket.soReuseAddress", true);
connector.setMaxPostSize(0);
代码示例来源: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: SonarSource/sonarqube
private void verifyHttpConnector(int expectedPort, Map<String, Object> expectedProps) {
verify(tomcat.getService()).addConnector(argThat(c -> {
if (!c.getScheme().equals("http")) {
return false;
}
if (!c.getProtocol().equals(TomcatConnectors.HTTP_PROTOCOL)) {
return false;
}
if (c.getPort() != expectedPort) {
return false;
}
for (Map.Entry<String, Object> expectedProp : expectedProps.entrySet()) {
if (!expectedProp.getValue().equals(c.getProperty(expectedProp.getKey()))) {
return false;
}
}
return true;
}));
}
}
代码示例来源:origin: macrozheng/mall
private Connector createStandardConnector() {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setPort(port);
return connector;
}
}
代码示例来源:origin: org.springframework.boot/spring-boot
@Override
public void customize(Connector connector) {
ProtocolHandler handler = connector.getProtocolHandler();
Assert.state(handler instanceof AbstractHttp11JsseProtocol,
"To use SSL, the connector's protocol handler must be an "
+ "AbstractHttp11JsseProtocol subclass");
configureSsl((AbstractHttp11JsseProtocol<?>) handler, this.ssl,
this.sslStoreProvider);
connector.setScheme("https");
connector.setSecure(true);
}
代码示例来源:origin: SonarSource/sonarqube
private Connector newConnector(String protocol, String schema) {
Connector httpConnector = new Connector(protocol);
httpConnector.setScheme(schema);
httpConnector.setPort(1234);
return httpConnector;
}
}
代码示例来源:origin: org.jboss.web/jbossweb
response.sendError(HttpServletResponse.SC_FORBIDDEN);
done = true;
break;
response.sendError(HttpServletResponse.SC_GONE);
done = true;
break;
urlString.insert(0, request.getContext().getEncodedPath());
response.sendRedirect(urlString.toString());
response.setStatus(rules[i].getRedirectCode());
done = true;
request.getCoyoteRequest().requestURI().setString(null);
CharChunk chunk = request.getCoyoteRequest().requestURI().getCharChunk();
chunk.recycle();
if (context) {
request.getCoyoteRequest().requestURI().toChars();
request.getConnector().getProtocolHandler().getAdapter().service
(request.getCoyoteRequest(), response.getCoyoteResponse());
} catch (Exception e) {
代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9
req.scheme().setString(connector.getScheme());
request.setSecure(connector.getSecure());
String proxyName = connector.getProxyName();
int proxyPort = connector.getProxyPort();
res.setStatus(400);
res.setMessage("Invalid URI: " + ioe.getMessage());
connector.getService().getContainer().logAccess(
request, response, 0, true);
return false;
res.setStatus(400);
res.setMessage("Invalid URI");
connector.getService().getContainer().logAccess(
request, response, 0, true);
return false;
res.setStatus(400);
res.setMessage("Invalid URI character encoding");
connector.getService().getContainer().logAccess(
request, response, 0, true);
return false;
if (connector.getUseIPVHosts()) {
connector.getMapper().map(serverName, decodedURI, version,
if (!connector.getAllowTrace()
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
Charset uriCharset = request.getConnector().getURICharset();
String originalQueryStringEncoded = request.getQueryString();
MessageBytes urlMB =
context ? request.getRequestPathMB() : request.getDecodedRequestURIMB();
urlMB.toChars();
CharSequence urlDecoded = urlMB.getCharChunk();
response.sendError(HttpServletResponse.SC_FORBIDDEN);
done = true;
break;
response.sendError(HttpServletResponse.SC_GONE);
done = true;
break;
urlStringEncoded.insert(0, request.getContext().getEncodedPath());
response.sendRedirect(
UDecoder.URLDecode(urlStringEncoded.toString(), uriCharset));
} else {
request.getCoyoteRequest().requestURI().toChars();
if (!connector.getProtocolHandler().getAdapter().prepare(
Pipeline pipeline = connector.getService().getContainer().getPipeline();
代码示例来源: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: org.apache.tomcat/tomcat-catalina
if (req.scheme().isNull()) {
req.scheme().setString(connector.getScheme());
request.setSecure(connector.getSecure());
} else {
request.setSecure(req.scheme().equals("https"));
String proxyName = connector.getProxyName();
int proxyPort = connector.getProxyPort();
allow.append("GET, HEAD, POST, PUT, DELETE, OPTIONS");
if (connector.getAllowTrace()) {
allow.append(", TRACE");
connector.getService().getContainer().logAccess(request, response, 0, true);
return false;
} else {
response.sendError(400, "Invalid URI");
if (connector.getUseIPVHosts()) {
connector.getService().getMapper().map(serverName, decodedURI,
version, request.getMappingData());
if (!connector.getAllowTrace()
代码示例来源:origin: org.jboss.web/jbossweb
if (! req.scheme().isNull()) {
req.scheme().setString(connector.getScheme());
request.setSecure(connector.getSecure());
String proxyName = connector.getProxyName();
int proxyPort = connector.getProxyPort();
request.setUserPrincipal(new CoyotePrincipal(principal));
if (connector.getUseIPVHosts()) {
if (connector.getAllowedHosts() != null && connector.getAllowedHosts().size() == 1) {
connector.getService().getMapper().map(serverName, decodedURI,
return false;
if (connector.getAllowedHosts() != null) {
Host host = (Host) request.getMappingData().host;
if (!connector.getAllowedHosts().contains(host.getName())) {
res.setStatus(403);
res.setMessage("Host access is forbidden through this connector");
if (!connector.getAllowTrace()
redirectPath = redirectPath + request.getContext().getSessionCookie().getPathParameterName()
代码示例来源:origin: org.osivia.portal.core/osivia-portal-jbossas-jbossweb-lib
/* */ protected boolean postParseRequest(org.apache.coyote.Request req, Request request, org.apache.coyote.Response res, Response response)
/* */ throws Exception
/* 328 */ if (!req.scheme().isNull())
/* 330 */ request.setSecure(req.scheme().equals("https"));
/* 334 */ req.scheme().setString(this.connector.getScheme());
/* 335 */ request.setSecure(this.connector.getSecure());
/* 343 */ String proxyName = this.connector.getProxyName();
/* 344 */ int proxyPort = this.connector.getProxyPort();
/* 345 */ if (proxyPort != 0) {
/* 346 */ req.setServerPort(proxyPort);
/* 406 */ request.setAuthType(authtype);
/* 411 */ if (this.connector.getUseIPVHosts()) {
/* 412 */ serverName = req.localName();
/* 413 */ if (serverName.isNull())
/* 418 */ serverName = req.serverName();
/* 420 */ this.connector.getMapper().map(serverName, decodedURI, request.getMappingData());
/* 426 */ if ((!this.connector.getAllowTrace()) && (req.method().equalsIgnoreCase("TRACE")))
/* 428 */ Wrapper wrapper = request.getWrapper();
代码示例来源:origin: apache/incubator-dubbo
tomcat.setBaseDir(baseDir);
tomcat.setPort(url.getPort());
tomcat.getConnector().setProperty(
"maxThreads", String.valueOf(url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS)));
tomcat.getConnector().setProperty(
"maxConnections", String.valueOf(url.getParameter(Constants.ACCEPTS_KEY, -1)));
tomcat.getConnector().setProperty("URIEncoding", "UTF-8");
tomcat.getConnector().setProperty("connectionTimeout", "60000");
tomcat.getConnector().setProperty("maxKeepAliveRequests", "-1");
tomcat.getConnector().setProtocol("org.apache.coyote.http11.Http11NioProtocol");
context.addServletMapping("/*", "dispatcher");
ServletManager.getInstance().addServletContext(url.getPort(), context.getServletContext());
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
connector.pause();
connector.getProtocolHandler().closeServerSocketGraceful();
if(log.isInfoEnabled())
log.info(sm.getString("standardService.stop.name", this.name));
setState(LifecycleState.STOPPING);
engine.stop();
for (Connector connector: connectors) {
if (!LifecycleState.STARTED.equals(
connector.getState())) {
connector.stop();
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
log.debug("Not renewing threads when the context is stopping. "
+ "It is not configured to do it.");
return;
Engine engine = (Engine) context.getParent().getParent();
Service service = engine.getService();
Connector[] connectors = service.findConnectors();
if (connectors != null) {
for (Connector connector : connectors) {
ProtocolHandler handler = connector.getProtocolHandler();
Executor executor = null;
if (handler != null) {
代码示例来源: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: org.apache.tomcat/tomcat-catalina
private static void setSSLImplementationName(Connector con, String sslImplementationName) throws Exception {
Method m = IntrospectionUtils.findMethod(con.getProtocolHandler().getClass(),"setSslImplementationName",new Class[] {String.class});
if (m != null) {
m.invoke(con.getProtocolHandler(), new Object[] {sslImplementationName});
} else {
log.warn(sm.getString("connector.noSetSSLImplementationName", con));
}
}
代码示例来源:origin: micromata/projectforge
private Connector createAJPConnector()
{
final Connector ajpConnector = new Connector("AJP/1.3");
ajpConnector.setPort(ajpPort);
ajpConnector.setAttribute("address", "127.0.0.1");
ajpConnector.setSecure(false);
ajpConnector.setAllowTrace(false);
ajpConnector.setScheme("http");
return ajpConnector;
}
}
代码示例来源:origin: nutzam/nutzboot
@Override
public void init() throws LifecycleException {
this.tomcat = new Tomcat();
File baseDir = createTempDir("tomcat");
this.tomcat.setBaseDir(baseDir.getAbsolutePath());
Connector connector = new Connector(PROP_PROTOCOL);
connector.setPort(getPort());
connector.setURIEncoding(DEFAULT_CHARSET.name());
connector.setMaxPostSize(conf.getInt(PROP_MAX_POST_SIZE, 64 * 1024 * 1024));
String connectorKey = PRE + "connector.";
for (String key : conf.keys()) {
if (key.startsWith(connectorKey)) {
String k = key.substring(connectorKey.length());
String v = conf.get(key);
connector.setProperty(k, v);
}
}
// 设置一下最大线程数
this.tomcat.getService().addConnector(connector);
StandardThreadExecutor executor = new StandardThreadExecutor();
executor.setMaxThreads(getMaxThread());
connector.getService().addExecutor(executor);
this.tomcat.setConnector(connector);
this.tomcat.setHostname(getHost());
this.tomcat.getHost().setAutoDeploy(false);
this.tomcat.getEngine().setBackgroundProcessorDelay(30);
this.prepareContext();
}
内容来源于网络,如有侵权,请联系作者删除!