APR为JBoss加速主要通过基于APR和JNI(Java Native Interface)的Connector实现。具体包括:Connector、JNI和集成。
Connector
1、 基于APR的HTTP11 Connector实现
org.apache.coyote.http11. Http11NioProcessor
org.apache.coyote.http11. Http11AprProtocol
2、 基于APR的AJP Connector实现
org.apache.coyote.ajp. AjpAprProcessor
org.apache.coyote.ajp. AjpAprProtocol
JNI实现
1、 Connector
Java接口:org.apache.tomcat.jni.Library
C实现:native connector的src目录
2、 SSL
Java接口:org.apache.tomcat.jni.SSL
C实现:native connector的src目录
APR集成
1、 JNI库的初始化和清除
APR的初始化通过Server的LifecycleListener接口实现,配置在server.xml中,xml片断如下:
<Server>
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="off" />
……
JNI库在Server的Lifecycle的INI_EVENT时进行初始化,在AFTER_STOP_EVENT时进行清除,具体代码如下:
/**
* Primary entry point for startup and shutdown events.
*
* @param event The event that has occurred
*/
public void lifecycleEvent(LifecycleEvent event) {
if (Lifecycle.INIT_EVENT.equals(event.getType())) {
aprInitialized = init();
if (aprInitialized) {
try {
initializeSSL();
} catch (Throwable t) {
if (!log.isDebugEnabled()) {
log.info(sm.getString("aprListener.sslInit"));
} else {
log.debug(sm.getString("aprListener.sslInit"));
}
}
}
} else if (Lifecycle.AFTER_STOP_EVENT.equals(event.getType())) {
if (!aprInitialized) {
return;
}
try {
terminateAPR();
} catch (Throwable t) {
if (!log.isDebugEnabled()) {
log.info(sm.getString("aprListener.aprDestroy"));
} else {
log.debug(sm.getString("aprListener.aprDestroy"), t);
}
}
}
}
2、 Connector选用
public Connector(String protocol)
throws Exception {
setProtocol(protocol);
// Instantiate protocol handler
try {
Class clazz = Class.forName(protocolHandlerClassName);
this.protocolHandler = (ProtocolHandler) clazz.newInstance();
} catch (Exception e) {
log.error
(sm.getString
("coyoteConnector.protocolHandlerInstantiationFailed", e));
}
}
/**
* Set the Coyote protocol which will be used by the connector.
*
* @param protocol The Coyote protocol name
*/
public void setProtocol(String protocol) {
// Test APR support
initializeAPR();
if (aprInitialized) {
if ("HTTP/1.1".equals(protocol)) {
setProtocolHandlerClassName
("org.apache.coyote.http11.Http11AprProtocol");
} else if ("AJP/1.3".equals(protocol)) {
setProtocolHandlerClassName
("org.apache.coyote.ajp.AjpAprProtocol");
} else if (protocol != null) {
setProtocolHandlerClassName(protocol);
} else {
setProtocolHandlerClassName
("org.apache.coyote.http11.Http11AprProtocol");
}
} else {
if ("HTTP/1.1".equals(protocol)) {
setProtocolHandlerClassName
("org.apache.coyote.http11.Http11Protocol");
} else if ("AJP/1.3".equals(protocol)) {
setProtocolHandlerClassName
("org.apache.jk.server.JkCoyoteHandler");
} else if (protocol != null) {
setProtocolHandlerClassName(protocol);
}
}
}
说明:Connector构造函数调用setProtocol函数设置Connector处理请求的Protocol Handler。在setProtocol函数中,只要能够成功地初始化APR,将使用基于APR的实现的org.apache.coyote.http11.Http11AprProtocol和org.apache.coyote.ajp.AjpAprProtocol作为请求处理的Protocol Handler。
分享到:
相关推荐
赠送jar包:jboss-logging-3.4.1.Final.jar; 赠送原API文档:jboss-logging-3.4.1.Final-javadoc.jar; 赠送源代码:jboss-logging-3.4.1.Final-sources.jar; 赠送Maven依赖信息文件:jboss-logging-3.4.1.Final....
赠送jar包:jboss-logging-3.4.3.Final.jar; 赠送原API文档:jboss-logging-3.4.3.Final-javadoc.jar; 赠送源代码:jboss-logging-3.4.3.Final-sources.jar; 赠送Maven依赖信息文件:jboss-logging-3.4.3.Final....
赠送jar包:jboss-logging-3.3.2.Final.jar; 赠送原API文档:jboss-logging-3.3.2.Final-javadoc.jar; 赠送源代码:jboss-logging-3.3.2.Final-sources.jar; 赠送Maven依赖信息文件:jboss-logging-3.3.2.Final....
赠送jar包:jboss-logging-3.4.2.Final.jar; 赠送原API文档:jboss-logging-3.4.2.Final-javadoc.jar; 赠送源代码:jboss-logging-3.4.2.Final-sources.jar; 赠送Maven依赖信息文件:jboss-logging-3.4.2.Final....
Beyond coverage of the core application server, the book also teaches how to use some of the "hot" technologies that run on top of the application server, such as Jboss Seam and JBoss Portal. ...
JBoss at Work: A Practical Guide
It shows how to configure the server's various component containers such as the JBoss Web Server, the EJB 3 server, and JBoss Messaging. It also provides detailed insight into configuring the various...
JBoss AS 5 Development
The latest JBoss AS 5 Development Guide book, very practical to any developer who is or is going to use JBoss AS
jboss as7 文档 内容非常全。 希望对大家有所帮助。
JBoss AS 7 Development
JBoss AS 7 简介 与之前版本的差异等
[Packt Publishing] JBoss AS 7 配置部署管理教程 (英文版) [Packt Publishing] JBoss AS 7 Configuration, Deployment and Administration (E-Book) ☆ 出版信息:☆ [作者信息] Francesco Marchioni [出版机构...
某大牛写的jboss-exp 1. 查看系统名称 java -jar jboss_exploit_fat.jar -i http://192.168.7.84:10081/invoker/JMXInvokerServlet get jboss.system:type=ServerInfo OSName 2. 查看系统版本 java -jar jboss_...
[Packt Publishing] JBoss AS 7 开发教程 (英文版) [Packt Publishing] JBoss AS 7 Development (E-Book) ☆ 出版信息:☆ [作者信息] Francesco Marchioni [出版机构] Packt Publishing [出版日期] 2013年06月...
我总结的JBoss AS7教程资料,几全面的,对目前公司的项目都很有帮助的,希望对j2ee的人员进行jboss升级的掌握有帮助。
jboss 5的详细说明。对在jboss5上进行开发来说是很好的参考资料。
jboss-logging-3.3 Final jar 架包!
5.远程删除文件D:\jboss\server\default\deploy\management\myname.war\index.jsp文件 java -jar jboss_exploit_fat.jar -i ...