red5内嵌tomcat启用apr和gzip

最近看到tomcat 的优化,发现使用如果使用apr可以提供tomcat的静态资源访问能力,于是就试了试。tomcat很好实现,网上很多资料。但是red5由于是嵌入的tomcat,没有server.xml, 所有一时没有找到如何解决。查看tomcat源码,发现tomcat检测apr是否可用使用在server.xml的

 

<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />

 

 再看看red5里面的tomcat配置文件jee-container.xml,没有发现可以配置的地方。于是作出如下修改。

 

	<bean id="AprLifecycleListener" class="org.apache.catalina.core.AprLifecycleListener" init-method="init" lazy-init="false"></bean>
        <!--spring容器启动,检测apr环境,类似上面的listener-->
	
	<bean id="tomcat.server" class="org.red5.server.tomcat.TomcatLoader" init-method="init" destroy-method="shutdown" depends-on="context.loader">

		<property name="webappFolder" value="${red5.root}/webapps" />
			      
	    <property name="connector">
			<bean class="org.apache.catalina.connector.Connector">
				<!-- Blocking I/O 
				<constructor-arg type="java.lang.String" value="org.apache.coyote.http11.Http11Protocol" />-->
				<!-- Non-blocking I/O -->
				<!--
				<constructor-arg type="java.lang.String" value="org.apache.coyote.http11.Http11NioProtocol" />	
				-->
				<!-- apr I/O -->
				
				<constructor-arg type="java.lang.String" value="org.apache.coyote.http11.Http11AprProtocol" />	
				
                <property name="port"><value>${http.port}</value></property>
		        <property name="redirectPort"><value>${https.port}</value></property>
                <property name="enableLookups"><value>false</value></property>
                <property name="useIPVHosts"><value>true</value></property>
                <property name="URIEncoding"><value>${http.URIEncoding}</value></property>
			</bean>
	    </property>
			    	
        <property name="address">
            <bean class="java.net.InetSocketAddress">
                <constructor-arg index="0" type="java.lang.String" value="${http.host}" />  
                <constructor-arg index="1" type="int" value="${http.port}" />  
            </bean>	
        </property>
	    	
        <property name="baseHost">
	       <bean class="org.apache.catalina.core.StandardHost">
	           <property name="name" value="${http.host}" />
	           <property name="unpackWARs" value="true" />
	           <property name="autoDeploy" value="true" />
	           <property name="xmlValidation" value="false" />
	           <property name="xmlNamespaceAware" value="false" />
	       </bean>	   
	    </property>		

		<property name="valves">
      		<list>
	    		<bean id="valve.access" class="org.apache.catalina.valves.AccessLogValve">
	                <property name="directory" value="log" />
	                <property name="prefix" value="${http.host}_access." />
	                <property name="suffix" value=".log" />
	                <property name="pattern" value="common" />
	                <property name="resolveHosts" value="false" />
	                <property name="rotatable" value="true" />
	        	</bean>
        	</list>
        </property>
	    
	</bean>

 启动信息

   red5内嵌tomcat启用apr和gzip_第1张图片

 

另外我想再启用gzip,但是没有找到配置的地方,哪位高人能指点下

2012年7月19日补充 开启gzip已经实现

直接上配置文件,浅红色为配置信息

<bean id="AprLifecycleListener" class="org.apache.catalina.core.AprLifecycleListener" init-method="init" lazy-init="false"></bean>

	
	<bean id="tomcat.server" class="org.red5.server.tomcat.TomcatLoader" init-method="init" destroy-method="shutdown" depends-on="context.loader">

		<property name="webappFolder" value="${red5.root}/webapps" />
			      
	    <property name="connector">
			<bean class="org.apache.catalina.connector.Connector">
				<!-- Blocking I/O 
				<constructor-arg type="java.lang.String" value="org.apache.coyote.http11.Http11Protocol" />-->
				<!-- Non-blocking I/O -->
				<!--
				<constructor-arg type="java.lang.String" value="org.apache.coyote.http11.Http11NioProtocol" />	
				-->
				<!-- apr I/O -->
				
				<constructor-arg type="java.lang.String" value="org.apache.coyote.http11.Http11AprProtocol" />	
				
                <property name="port"><value>${http.port}</value></property>
		        <property name="redirectPort"><value>${https.port}</value></property>
                <property name="enableLookups"><value>false</value></property>
                <property name="useIPVHosts"><value>true</value></property>
                <property name="URIEncoding"><value>${http.URIEncoding}</value></property>
				
			</bean>
	    </property>
		
		<property name="connectionProperties">
			<map>
				<entry><key><value>maxThreads</value></key><value>150</value></entry>
				<entry><key><value>minSpareThreads</value></key><value>25</value></entry>
				<entry><key><value>maxSpareThreads</value></key><value>75</value></entry>
				<entry><key><value>acceptCount</value></key><value>100</value></entry>
				<entry><key><value>disableUploadTimeout</value></key><value>true</value></entry>
				<entry><key><value>compression</value></key><value>on</value></entry>
				<entry><key><value>compressionMinSize</value></key><value>2048</value></entry>
				<entry><key><value>noCompressionUserAgents</value></key><value>gozilla, traviata</value></entry>
				<entry><key><value>compressableMimeType</value></key><value>text/html,text/xml,text/javascript,text/css,text/plain</value></entry>
			</map>
			
		</property>	
		
        <property name="address">
            <bean class="java.net.InetSocketAddress">
                <constructor-arg index="0" type="java.lang.String" value="${http.host}" />  
                <constructor-arg index="1" type="int" value="${http.port}" />  
            </bean>	
        </property>
	    	
        <property name="baseHost">
	       <bean class="org.apache.catalina.core.StandardHost">
	           <property name="name" value="${http.host}" />
	           <property name="unpackWARs" value="true" />
	           <property name="autoDeploy" value="true" />
	           <property name="xmlValidation" value="false" />
	           <property name="xmlNamespaceAware" value="false" />
	       </bean>	   
	    </property>		

		<property name="valves">
      		<list>
	    		<bean id="valve.access" class="org.apache.catalina.valves.AccessLogValve">
	                <property name="directory" value="log" />
	                <property name="prefix" value="${http.host}_access." />
	                <property name="suffix" value=".log" />
	                <property name="pattern" value="common" />
	                <property name="resolveHosts" value="false" />
	                <property name="rotatable" value="true" />
	        	</bean>
        	</list>
        </property>
	    
</bean>
 

 

你可能感兴趣的:(tomcat)