当前位置: 首页>>代码示例>>Java>>正文


Java AbstractHttp11Protocol.setCompression方法代码示例

本文整理汇总了Java中org.apache.coyote.http11.AbstractHttp11Protocol.setCompression方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractHttp11Protocol.setCompression方法的具体用法?Java AbstractHttp11Protocol.setCompression怎么用?Java AbstractHttp11Protocol.setCompression使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.coyote.http11.AbstractHttp11Protocol的用法示例。


在下文中一共展示了AbstractHttp11Protocol.setCompression方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: customizeCompression

import org.apache.coyote.http11.AbstractHttp11Protocol; //导入方法依赖的package包/类
private void customizeCompression(Connector connector) {
	ProtocolHandler handler = connector.getProtocolHandler();
	if (handler instanceof AbstractHttp11Protocol) {
		AbstractHttp11Protocol<?> protocol = (AbstractHttp11Protocol<?>) handler;
		Compression compression = getCompression();
		protocol.setCompression("on");
		protocol.setCompressionMinSize(compression.getMinResponseSize());
		protocol.setCompressableMimeType(
				StringUtils.arrayToCommaDelimitedString(compression.getMimeTypes()));
		if (getCompression().getExcludedUserAgents() != null) {
			protocol.setNoCompressionUserAgents(
					StringUtils.arrayToCommaDelimitedString(
							getCompression().getExcludedUserAgents()));
		}
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:TomcatEmbeddedServletContainerFactory.java

示例2: customizeCompression

import org.apache.coyote.http11.AbstractHttp11Protocol; //导入方法依赖的package包/类
private void customizeCompression(Connector connector) {
	ProtocolHandler handler = connector.getProtocolHandler();
	if (handler instanceof AbstractHttp11Protocol) {
		AbstractHttp11Protocol<?> protocol = (AbstractHttp11Protocol<?>) handler;
		Compression compression = getCompression();
		protocol.setCompression("on");
		protocol.setCompressionMinSize(compression.getMinResponseSize());
		protocol.setCompressableMimeTypes(
				StringUtils.arrayToCommaDelimitedString(compression.getMimeTypes()));
		if (getCompression().getExcludedUserAgents() != null) {
			protocol.setNoCompressionUserAgents(
					StringUtils.arrayToCommaDelimitedString(
							getCompression().getExcludedUserAgents()));
		}
	}
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:17,代码来源:TomcatEmbeddedServletContainerFactory.java

示例3: initialize

import org.apache.coyote.http11.AbstractHttp11Protocol; //导入方法依赖的package包/类
public void initialize() {
		try {
			JFishTomcat tomcat = new JFishTomcat();
			if(serverConfig.getTomcatContextClassName()!=null){
				tomcat.setContextClass((Class<StandardContext>)ReflectUtils.loadClass(serverConfig.getTomcatContextClassName(), true));
			}
			int port = serverConfig.getPort();
			tomcat.setPort(port);
//			tomcat.setBaseDir(webConfig.getServerBaseDir());
			String baseDir = null;
			if(!Utils.isBlank(serverConfig.getServerBaseDir())){
				baseDir = serverConfig.getServerBaseDir();
			}else{
				baseDir = System.getProperty("java.io.tmpdir");
				logger.info("set serverBaseDir as java.io.tmpdir : {} ", baseDir);
			}
			tomcat.setBaseDir(baseDir);
			
			// This magic line makes Tomcat look for WAR files in catalinaHome/webapps
			// and automatically deploy them
//			tomcat.getHost().addLifecycleListener(new HostConfig());
			appBaseFile = new File(baseDir+"/tomcat.webapps."+this.serverConfig.getPort());
			if(!appBaseFile.exists()){
				appBaseFile.mkdirs();
			}
			appBaseFile.deleteOnExit();
			tomcat.getHost().setAppBase(appBaseFile.getAbsolutePath());
			Connector connector = tomcat.getConnector();
			connector.setURIEncoding("UTF-8");
			connector.setRedirectPort(serverConfig.getRedirectPort());
			connector.setMaxPostSize(serverConfig.getMaxPostSize());
			
			ProtocolHandler protocol = connector.getProtocolHandler();
			if(protocol instanceof AbstractHttp11Protocol){
				/*****
				 * <Connector port="8080" protocol="HTTP/1.1" 
					   connectionTimeout="20000" 
   						redirectPort="8181" compression="500" 
  						compressableMimeType="text/html,text/xml,text/plain,application/octet-stream" />
				 */
				AbstractHttp11Protocol<?> hp = (AbstractHttp11Protocol<?>) protocol;
				hp.setCompression("on");
				hp.setCompressableMimeTypes("text/html,text/xml,text/plain,application/octet-stream");
			}
			
			
			StandardServer server = (StandardServer) tomcat.getServer();
			AprLifecycleListener listener = new AprLifecycleListener();
			server.addLifecycleListener(listener);

			/*tomcat.addUser("adminuser", "adminuser");
			tomcat.addRole("adminuser", "admin");
			tomcat.addRole("adminuser", "admin");*/
			
			this.tomcat = tomcat;
		} catch (Exception e) {
			throw new RuntimeException("web server initialize error , check it. " + e.getMessage(), e);
		}
		
		/*Runtime.getRuntime().addShutdownHook(new Thread(){

			@Override
			public void run() {
				appBaseFile.delete();
			}
			
		});*/
	}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:69,代码来源:TomcatServer.java


注:本文中的org.apache.coyote.http11.AbstractHttp11Protocol.setCompression方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。