- 浏览: 235319 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
潇洒小鸟2013:
确实有这个问题
c3p0存在严重bug -
jun1022509040:
http://download.csdn.net/detail ...
c3p0存在严重bug -
liang5233145:
1.7版本,有个close()方法,但是1.7之前没有关闭方法 ...
关闭URLClassLoader打开的jar包 -
ilomkdyhrnvbd:
性能测试之Apache性能调优观看地址:http://www. ...
apache性能调优 -
zxjlwt:
学习了。http://surenpi.com
jetty和tomcat中,war包解压缩的差别
jetty中文文档:www.jettycn.com
一个应用一个端口
A应用只能从A端口访问,B应用只能从B端口访问
要做到这一点的最有效的方法是创建两个org.eclipse.jetty.server.Server实例。还有另外一种效率较低的替代方案 。
服务器实例A有一个监听A端口的connector并部署A应用,服务器实例B有一个监听B端口的connector并部署B应用。例如:
我们希望A应用从8080端口访问,B应用通过SSL协议从8443端口访问。我们建立了2个服务器实例,每个实例的jetty.xml文件如下所示:
jettyA.xml
<Configure id="ServerA" class="org.eclipse.jetty.server.Server"> <!-- set up the port for ServerA --> <Set name="connectors"> <Array type="org.eclipse.jetty.server.Connector"> <Item> <New class="org.eclipse.jetty.server.nio.SelectChannelConnector"> <Set name="port">8080</Set> <Set name="maxIdleTime">30000</Set> <Set name="Acceptors">10</Set> </New> </Item> </Array> </Set> <!-- set up a context provider for Server A --> <Call name="addLifeCycle"> <Arg> <New class="org.eclipse.jetty.deploy.providers.ContextProvider"> <Set name="contexts"><Ref id="Contexts"/></Set> <Set name="configurationDir"><SystemProperty name="jetty.home" default="."/>/contextsA</Set> <Set name="scanInterval">5</Set> </New> </Arg> </Call> </Configure>
jettyB.xml:
<Configure id="ServerB" class="org.eclipse.jetty.server.Server"> <!-- set up the port for ServerB --> <Set name="connectors"> <Array type="org.eclipse.jetty.server.Connector"> <Item> <New class="org.eclipse.jetty.server.ssl.SslSocketConnector"> <Set name="Port">8443</Set> <Set name="maxIdleTime">30000</Set> <Set name="Keystore"><SystemProperty name="jetty.home" default="." />/etc/keystore</Set> <Set name="Password">OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4</Set> <Set name="KeyPassword">OBF:1u2u1wml1z7s1z7a1wnl1u2g</Set> </New> </Item> </Array> </Set> <!-- set up a context provider for ServerB --> <Call name="addLifeCycle"> <Arg> <New class="org.eclipse.jetty.deploy.providers.ContextProvider"> <Set name="contexts"><Ref id="Contexts"/></Set> <Set name="configurationDir"><SystemProperty name="jetty.home" default="."/>/contextsB</Set> <Set name="scanInterval">5</Set> </New> </Arg> </Call> </Configure>
现在我们需要配置两个context文件,一个描述需要部署到ServerA上的A应用,另一个描述需要部署到ServerB上的B应用。然后,我们把这些文件分别放到$JETTY_HOME/contextsA或$JETTY_HOME/contextsB中。
contextA.xml
<Configure class="org.eclipse.jetty.webapp.WebAppContext"> <Set name="war"><SystemProperty name="jetty.home"/>/webapps/A</Set> <Set name="contextPath">/webappA</Set> ... </Configure>
contextB.xml:
<Configure class="org.eclipse.jetty.webapp.WebAppContext"> <Set name="war"><SystemProperty name="jetty.home"/>/webapps/B</Set> <Set name="contextPath">/webappB</Set> ... </Configure>
你将在同一个JVM中运行2个服务器实例,只需提供2个xml配置文件:
java -jar start.jar jettyA.xml jettyB.xml
当然,你也可以启动2个独立Jetty实例,一个实例使用jettyA.xml,另一个实例使用jettyB.xml。但是,在同一JVM中运行2个服务器通常是更有效的。
替代方案
还有另一种方法,也可以实现上述相同的结果,但它的效率稍微差一些。这需要设置web应用的connector列表,只有列表中的connector发送过来的请求才会被处理。相对于上面描述的方法,这是一个效率较低的解决方案,因为该请求提交给每一个web应用,web应用必须决定是否接收并处理这个请求。在第一个解决方案,请求只会传给唯一的一个web应用。在此配置中,你只需要一个服务器实例。你需要为每个connector定义唯一的名称,然后给每个web应用指派connector名称列表,这样web应用就可以响应指定connector发来的请求了。
以下代码展示了如何配置connector列表:
jetty.xml:
<Configure class="org.eclipse.jetty.server.Server"> <!-- set up both connectors --> <Set name="connectors"> <Array type="org.eclipse.jetty.server.Connector"> <Item> <New id="connA" class="org.eclipse.jetty.server.nio.SelectChannelConnector"> <Set name="port">8080</Set> <Set name="maxIdleTime">30000</Set> <Set name="Acceptors">1</Set> <Set name="name">connA</Set> </New> </Item> <Item> <New id="connB" class="org.eclipse.jetty.server.nio.SelectChannelConnector"> <Set name="port">9090</Set> <Set name="maxIdleTime">30000</Set> <Set name="Acceptors">1</Set> <Set name="name">connB</Set> </New> </Item> </Array> </Set> <!-- set up a context provider --> <Call name="addLifeCycle"> <Arg> <New class="org.eclipse.jetty.deploy.providers.ContextProvider"> <Set name="contexts"><Ref id="Contexts"/></Set> <Set name="configurationDir"><SystemProperty name="jetty.home" default="."/>/contexts</Set> <Set name="scanInterval">5</Set> </New> </Arg> </Call> </Configure>
contextA.xml:
<Configure class="org.eclipse.jetty.webapp.WebAppContext"> <Set name="war"><SystemProperty name="jetty.home"/>/webapps/A</Set> <Set name="contextPath">/webappA</Set> <Set name="connectorNames"> <Array type="String"> <Item>connA</Item> </Array> </Set> ... </Configure>
contextB.xml:
<Configure class="org.eclipse.jetty.webapp.WebAppContext"> <Set name="war"><SystemProperty name="jetty.home"/>/webapps/B</Set> <Set name="contextPath"/webappB</Set> <Set name="connectorNames"> <Array type="String"> <Item>connB</Item> </Array> </Set> </Configure>
现在像往常一样启动jetty(如果你的服务器配置文件叫jetty.xml,可以从命令行省略它):
java -jar start.jar
评论
jetty目录中的start.ini中默认引入了很多配置文件:etc/jetty.xml, etc/jetty-deploy.xml 等等
发表评论
-
jetty ajp实现分析
2014-10-12 21:09 890Ajp13Parser用于解析web服务器传过来的输入流, ... -
访问JSP页面时报java.err.nojdk错误
2012-08-21 10:08 7324案件JDK6及以上版本时,则在Jetty中访问JSP页面的时候 ... -
jetty和ajaxanywhere有冲突
2012-01-12 16:38 1658有同事反映jetty下部署的应用程序有问题,而这个应用部署在t ... -
jetty处理get请求支持中文url
2011-12-27 15:52 3529URL实例是: http://localhost:8080/ ... -
jetty wiki未翻译的文章列表
2011-09-04 20:06 1390文章地址 翻译者 http://wiki.ec ... -
jetty-配置JMX
2011-09-02 14:26 11321jetty中文文档:www.jettycn. ... -
jetty-如何重定向或移动context
2011-08-26 11:09 4047jetty中文文档:www.jettycn.com ... -
jetty-如何序列化会话
2011-08-25 13:35 1969jetty中文文档:www.jettycn.com ... -
jetty-如何配置会话ID
2011-08-24 13:17 8072jetty中文文档:www.jettycn.com ... -
jetty-如何配置虚拟主机
2011-08-18 18:27 15312jetty中文文档:www.jettycn.com ... -
jetty-如何配置连接器
2011-08-02 14:36 1500jetty中文文档:www.jettycn.com ... -
jetty7中文文档
2011-06-22 23:06 9265jetty是一个开源的java servlet容器,功能类似于 ... -
jetty中的JNDI实现分析
2011-05-03 19:11 2279本文主要探讨jetty中的JN ... -
jetty存在session不一致问题
2011-04-19 13:09 4256jetty在集群环境中使用时,浏览器中的sessionId和后 ... -
jetty-plus.xml功能分析
2011-03-10 10:26 3369版本:jetty 7.3.0 一:org.eclips ... -
学习jetty-WebAppContext
2011-02-25 15:21 4779一个WebAppContext对象代表一个web应用程序,可以 ... -
学习jetty
2011-01-24 18:16 13961 jetty-web.xml 是和指定web应 ...
相关推荐
eclipse jetty插件,从...下载run-jetty-run.zip文件,解压后再编写个links文件丢到eclipse的dropins目录下即可,省去了使用eclipse update方式安装的麻烦。 link文件样例如: path=d:\\eclipse_plugins\\run-jetty-run
赠送jar包:jetty-util-6.1.26.jar; 赠送原API文档:jetty-util-6.1.26-javadoc.jar; 赠送源代码:jetty-util-6.1.26-sources.jar; 赠送Maven依赖信息文件:jetty-util-6.1.26.pom; 包含翻译后的API文档:jetty-...
安装方法为新加一个run-jetty-run.link文件,文件内容为 path=G:\\eclipse_plugins\\run-jetty-run 执行解压后的路径文件夹即可。 在线安装地址为: http://xzer.github.io/run-jetty-run-updatesite/nightly/ 支持...
赠送jar包:jetty-http-9.4.11.v20180605.jar; 赠送原API文档:jetty-http-9.4.11.v20180605-javadoc.jar; 赠送源代码:jetty-http-9.4.11.v20180605-sources.jar; 赠送Maven依赖信息文件:jetty-...
赠送jar包:jetty-server-8.1.8.jar; 赠送原API文档:jetty-server-8.1.8-javadoc.jar; 赠送源代码:jetty-server-8.1.8-sources.jar; 赠送Maven依赖信息文件:jetty-server-8.1.8.pom; 包含翻译后的API文档:...
jetty-all-9.4.47.v20220610-uber.jar
jetty-security-9.4.8.v20171121.jar,jetty-io-9.4.8.v20171121.jar,jetty-continuation-9.4.8.v20171121.jar,jetty-client-9.4.8.v20171121.jar,jetty-jmx-9.4.8.v20171121.jar,jetty-plus-9.4.8.v20171121....
赠送jar包:jetty-server-8.1.8.v20121106.jar; 赠送原API文档:jetty-server-8.1.8.v20121106-javadoc.jar; 赠送源代码:jetty-server-8.1.8.v20121106-sources.jar; 赠送Maven依赖信息文件:jetty-server-8.1.8...
赠送jar包:jetty-security-9.3.19.v20170502.jar; 赠送原API文档:jetty-security-9.3.19.v20170502-javadoc.jar; 赠送源代码:jetty-security-9.3.19.v20170502-sources.jar; 赠送Maven依赖信息文件:jetty-...
赠送jar包:jetty-util-6.1.26.jar; 赠送原API文档:jetty-util-6.1.26-javadoc.jar; 赠送源代码:jetty-util-6.1.26-sources.jar; 赠送Maven依赖信息文件:jetty-util-6.1.26.pom; 包含翻译后的API文档:jetty-...
赠送jar包:jetty-io-9.4.8.v20171121.jar; 赠送原API文档:jetty-io-9.4.8.v20171121-javadoc.jar; 赠送源代码:jetty-io-9.4.8.v20171121-sources.jar; 赠送Maven依赖信息文件:jetty-io-9.4.8.v20171121.pom;...
赠送jar包:jetty-webapp-9.3.19.v20170502.jar; 赠送原API文档:jetty-webapp-9.3.19.v20170502-javadoc.jar; 赠送源代码:jetty-webapp-9.3.19.v20170502-sources.jar; 赠送Maven依赖信息文件:jetty-webapp-...
赠送jar包:jetty-io-9.4.43.v20210629.jar; 赠送原API文档:jetty-io-9.4.43.v20210629-javadoc.jar; 赠送源代码:jetty-io-9.4.43.v20210629-sources.jar; 赠送Maven依赖信息文件:jetty-io-9.4.43.v20210629....
赠送jar包:jetty-sslengine-6.1.26.jar; 赠送原API文档:jetty-sslengine-6.1.26-javadoc.jar; 赠送源代码:jetty-sslengine-6.1.26-sources.jar; 赠送Maven依赖信息文件:jetty-sslengine-6.1.26.pom; 包含...
赠送jar包:jetty-server-8.1.8.jar; 赠送原API文档:jetty-server-8.1.8-javadoc.jar; 赠送源代码:jetty-server-8.1.8-sources.jar; 赠送Maven依赖信息文件:jetty-server-8.1.8.pom; 包含翻译后的API文档:...
赠送jar包:jetty-util-9.4.43.v20210629.jar; 赠送原API文档:jetty-util-9.4.43.v20210629-javadoc.jar; 赠送源代码:jetty-util-9.4.43.v20210629-sources.jar; 赠送Maven依赖信息文件:jetty-util-9.4.43.v...
赠送jar包:jetty-sslengine-6.1.26.jar; 赠送原API文档:jetty-sslengine-6.1.26-javadoc.jar; 赠送源代码:jetty-sslengine-6.1.26-sources.jar; 赠送Maven依赖信息文件:jetty-sslengine-6.1.26.pom; 包含...
赠送jar包:jetty-6.1.26.jar; 赠送原API文档:jetty-6.1.26-javadoc.jar; 赠送源代码:jetty-6.1.26-sources.jar; 赠送Maven依赖信息文件:jetty-6.1.26.pom; 包含翻译后的API文档:jetty-6.1.26-javadoc-API...
jetty-http-7.4.2.v20110526.jar jetty-http 服务jar包
赠送jar包:jetty-continuation-8.1.8.v20121106.jar; 赠送原API文档:jetty-continuation-8.1.8.v20121106-javadoc.jar; 赠送源代码:jetty-continuation-8.1.8.v20121106-sources.jar; 赠送Maven依赖信息文件:...