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

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

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

Connector.getProtocolHandler介绍

[英]Return the protocol handler associated with the connector.
[中]返回与连接器关联的协议处理程序。

代码示例

代码示例来源:origin: ityouknow/spring-boot-examples

@Bean
public TomcatEmbeddedServletContainerFactory tomcatEmbedded() {
  TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
  tomcat.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> {
    if ((connector.getProtocolHandler() instanceof AbstractHttp11Protocol<?>)) {
      //-1 means unlimited
      ((AbstractHttp11Protocol<?>) connector.getProtocolHandler()).setMaxSwallowSize(-1);
    }
  });
  return tomcat;
}

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

private void stopProtocolHandler(Connector connector) {
  try {
    connector.getProtocolHandler().stop();
  }
  catch (Exception ex) {
    logger.error("Cannot pause connector: ", ex);
  }
}

代码示例来源: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: org.springframework.boot/spring-boot

@Override
public void customize(Connector connector) {
  if (this.compression != null && this.compression.getEnabled()) {
    ProtocolHandler handler = connector.getProtocolHandler();
    if (handler instanceof AbstractHttp11Protocol) {
      customize((AbstractHttp11Protocol<?>) handler);
    }
    for (UpgradeProtocol upgradeProtocol : connector.findUpgradeProtocols()) {
      if (upgradeProtocol instanceof Http2Protocol) {
        customize((Http2Protocol) upgradeProtocol);
      }
    }
  }
}

代码示例来源:origin: line/armeria

@Override
public HttpResponse serve(ServiceRequestContext ctx, HttpRequest req) throws Exception {
  final Optional<Adapter> coyoteAdapter = connector().map(c -> c.getProtocolHandler().getAdapter());

代码示例来源: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: psi-probe/psi-probe

/**
 * Gets the connector infos.
 *
 * @param connectors the connectors
 * @return the connector infos
 * @throws IllegalAccessException the illegal access exception
 * @throws InvocationTargetException the invocation target exception
 */
private List<ConnectorInfo> getConnectorInfos(List<Connector> connectors)
  throws IllegalAccessException, InvocationTargetException {
 List<ConnectorInfo> infos = new ArrayList<>();
 for (Connector connector : connectors) {
  if (!connector.getSecure()) {
   continue;
  }
  ProtocolHandler protocolHandler = connector.getProtocolHandler();
  if (protocolHandler instanceof AbstractHttp11JsseProtocol) {
   AbstractHttp11JsseProtocol<?> protocol = (AbstractHttp11JsseProtocol<?>) protocolHandler;
   if (!protocol.getSecure()) {
    continue;
   }
   infos.add(toConnectorInfo(protocol));
  }
 }
 return infos;
}

代码示例来源:origin: stackoverflow.com

@Bean
public EmbeddedServletContainerCustomizer servletContainerCustomizer() {
  return new EmbeddedServletContainerCustomizer() {
    @Override
    public void customize(ConfigurableEmbeddedServletContainer servletContainer) {
      ((TomcatEmbeddedServletContainerFactory) servletContainer).addConnectorCustomizers(
          new TomcatConnectorCustomizer() {
            @Override
            public void customize(Connector connector) {
              AbstractHttp11Protocol httpProtocol = (AbstractHttp11Protocol) connector.getProtocolHandler();
              httpProtocol.setCompression("on");
              httpProtocol.setCompressionMinSize(256);
              String mimeTypes = httpProtocol.getCompressableMimeTypes();
              String mimeTypesWithJson = mimeTypes + "," + MediaType.APPLICATION_JSON_VALUE;
              httpProtocol.setCompressableMimeTypes(mimeTypesWithJson);
            }
          }
      );
    }
  };
}

代码示例来源:origin: stackoverflow.com

factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
   @Override
   public void customize(Connector connector) {
     ((AbstractProtocol) connector.getProtocolHandler()).setConnectionTimeout(10000);
   }
 });

代码示例来源:origin: codefollower/Tomcat-Research

public void _setExecutor(Connector con, Executor ex) throws Exception {
  Method m = IntrospectionUtils.findMethod(con.getProtocolHandler().getClass(),"setExecutor",new Class[] {java.util.concurrent.Executor.class});
  if (m!=null) {
    m.invoke(con.getProtocolHandler(), new Object[] {ex});
  }else {
    log.warn("Connector ["+con+"] does not support external executors. Method setExecutor(java.util.concurrent.Executor) not found.");
  }
}

代码示例来源:origin: org.apache.catalina/com.springsource.org.apache.catalina

public void _setExecutor(Connector con, Executor ex) throws Exception {
  Method m = IntrospectionUtils.findMethod(con.getProtocolHandler().getClass(),"setExecutor",new Class[] {java.util.concurrent.Executor.class});
  if (m!=null) {
    m.invoke(con.getProtocolHandler(), new Object[] {ex});
  }else {
    log.warn("Connector ["+con+"] does not support external executors. Method setExecutor(java.util.concurrent.Executor) not found.");
  }
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

public void _setExecutor(Connector con, Executor ex) throws Exception {
  Method m = IntrospectionUtils.findMethod(con.getProtocolHandler().getClass(),"setExecutor",new Class[] {java.util.concurrent.Executor.class});
  if (m!=null) {
    m.invoke(con.getProtocolHandler(), new Object[] {ex});
  }else {
    log.warn("Connector ["+con+"] does not support external executors. Method setExecutor(java.util.concurrent.Executor) not found.");
  }
}

代码示例来源:origin: org.jboss.mod_cluster/mod_cluster

/**
* {@inhericDoc}
* @see org.jboss.modcluster.Connector#setAddress(java.net.InetAddress)
*/
public void setAddress(InetAddress address)
{
 IntrospectionUtils.setProperty(this.connector.getProtocolHandler(), "address", address.getHostAddress());
}

代码示例来源: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: org.apache.tomcat/tomcat-catalina

private static void setExecutor(Connector con, Executor ex) throws Exception {
  Method m = IntrospectionUtils.findMethod(con.getProtocolHandler().getClass(),"setExecutor",new Class[] {java.util.concurrent.Executor.class});
  if (m!=null) {
    m.invoke(con.getProtocolHandler(), new Object[] {ex});
  }else {
    log.warn(sm.getString("connector.noSetExecutor", con));
  }
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

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: codefollower/Tomcat-Research

@Override
public Object get(Request request, String name) {
  return Boolean.valueOf(
      request.getConnector().getProtocolHandler(
          ).isCometSupported());
}
@Override

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

@Override
public Object get(Request request, String name) {
  return Boolean.valueOf(
      request.getConnector().getProtocolHandler(
          ).isSendfileSupported() && request.getCoyoteRequest().getSendfile());
}
@Override

相关文章

Connector类方法