类名 |
org.apache.catalina.core.AprLifecycleListener |
继承关系 |
LifecycleListener
|
关联类 |
org.apache.tomcat.jni.Library
org.apache.tomcat.jni.SSL
|
实现功能 |
检查是否具有 APR/native 库,如果有则将其加载 |
分析
在StandardServer一节的学习中,我们遗漏了一个很重要的部分没有提及。那就是加载LifecycleListener。我们已经知道,继承LifecycleListener接口的类可以用来监听component的状态变化。 当StandardServer被初始化时,有一系列的标准LifecycleListener被加载并监听StandardServer的变化(这些Listener被定义在server.xml文件的Server标签下)。接下来的一系列博文中,我们会逐一介绍这些Listener。
APR/native
除了提供正常的web server服务(HTTP,File I/O, etc.), Tomcat还提供了一种称之为 Apache Portable Runtime的组件为web应用提供高可扩展性,高性能以及更好的与本地服务技术整合的功能。Tomcat的文档中提到了几种典型的功能,比如sendfile,epoll和OpenSSL等高级IO功能。OS级别的功能如随机数的产生,系统状态等等。
想要使用APR/native支持,以下组件需要被安装:
1. APR library
2. Tomcat 使用APR所需的JNI wapper类
3. OpenSSL libraries
一旦这些组件被安装并可用,Tomcat的Connector就会自动的使用APR,这里最值得关注的就是SSL的配置,我们接下来会大概的提到。详细的内容会在Connector中具体描述。
APR Lifecycle Listener配置
APRLifecycleListener的配置项很简单,className属性配置其full name。 SSLEngine属性配置是否使用SSL,默认选项是on:
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
在Connector中,只要配置SSLEnabled为true即可,当然还有其它配置项需要关心,在这里我们不过度深入。
<Connector port="443" maxHttpHeaderSize="8192"
maxThreads="150"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
SSLEnabled="true"
SSLCertificateFile="${catalina.base}/conf/localhost.crt"
SSLCertificateKeyFile="${catalina.base}/conf/localhost.key" />
lifecycleEvent方法
AprLifecycleListener类的核心方法是lifecycleEvent,当StandardServer的状态发生改变时,该方法被触发:
1. eventType == BEFORE_INIT
a. 初始化并加载org.apache.tomcat.jni.Library, 即APR native Library的jni wrapper。
b. 初始化并加载org.apache.tomcat.jni.SSL, 即SSL的jni wrapper。
2. eventType == AFTER_DESTROY
a. 终止org.apache.tomcat.jni.Library
b. 终止org.apache.tomcat.jni.SSL
org.apache.tomcat.jni.Library 和 SSL 属于jni的部分了,不在本文讨论之列。
分享到:
相关推荐
org.apache.catalina.core.AprLifecycleListener myeclipse tomcat 無法啟動 用這個文件
2010-8-11 18:24:13 org.apache.catalina.core.AprLifecycleListener lifecycleEvent 信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the ...
2008-10-11 21:33:55 org.apache.catalina.core.AprLifecycleListener init 信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the...
针对一个tomcat中有的项目需要使用ssl加密有些可以直接访问的情况,可通过修改tomcat/conf下的server.xml来实现。具体配置可参考下面这段代码,注意”Catalina1″>这个标签中的配置。 <?xml version='1.0' ...
一月 10, 2018 4:52:07 下午 org.apache.catalina.core.AprLifecycleListener init 严重: An incompatible version 1.1.31 of the APR based Apache Tomcat Native library is installed, ...
最近在做实训项目的时候使用到了 ssm框架...信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\java\jdk\b
2008-3-15 14:24:12 org.apache.catalina.core.AprLifecycleListener init 信息: The APR based Apache Tomcat Native library which allows optimal performanc e in production environments was not found on the...
九月 18, 2013 11:39:01 上午 org.apache.catalina.core.AprLifecycleListener init INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not ...
2009-8-29 14:02:04 org.apache.catalina.core.AprLifecycleListener init 信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the ...