在JAVA WEB容器大家族中,Resin可以算的上最輕巧最快速的服務(wù)器了。我個人非常喜歡在產(chǎn)品開發(fā)階段使用Resin來測試和調(diào)試,因為開發(fā)階段需要頻繁地重啟服務(wù)器。在給客戶進行產(chǎn)品部署的時候我還是趨向于使用Tomcat,因為tomcat是全部免費的,而且使用者很多,再加上NIO和GZip模式可以優(yōu)化服務(wù)器性能以及tomcat出色的穩(wěn)定性。
Resin4可以給不同的Web app分配不同的端口,也就是說Resin4可以同時開啟多個端口的服務(wù),這一點是非常贊的,在tomcat中想要實現(xiàn)這個就必須另外再來一份tomcat,配置不同的端口。而Resin4就不需要了,給不同的應(yīng)用設(shè)置好相應(yīng)的端口就OK了。
Resin4有一個全局端口,也就是默認(rèn)端口,可以在conf/resin.properties文件中,對HTTP元素進行簡單的修改,如下:
# Set HTTP and HTTPS ports
http : 8080
#https : 8443
在Resin中創(chuàng)建虛擬目錄的方式是修改conf/resin.xml文件,正如我剛剛說的,每一個虛擬目錄都是一個Web app,都可以配置獨立的端口號。在resin.xml中一個cluster就代表一個端口應(yīng)用,代碼如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
< cluster id = "app" > <!-- define the servers in the cluster --> < server-multi id-prefix = "app-" address-list = "${app_servers}" port = "6800" /> < host-default > <!-- creates the webapps directory for .war expansion --> < web-app-deploy path = "webapps" expand-preserve-fileset = "WEB-INF/work/**" multiversion-routing = "${webapp_multiversion_routing}" /> </ host-default > <!-- auto virtual host deployment in hosts/foo.example.com/webapps --> < host-deploy path = "hosts" /> <!-- the default host, matching any host name --> < host id = "" root-directory = "." > <!-- - webapps can be overridden/extended in the resin.xml --> < web-app id = "/" root-directory = "webapps/ROOT" /> < web-app id = "/jPress" root-directory = "D:\workspace\java\myeclipse10\jPress\WebRoot" /> < resin:if test = "${resin_doc}" > < web-app id = "/resin-doc" root-directory = "${resin.root}/doc/resin-doc" /> </ resin:if > </ host > </ cluster > |
這個cluster是web-app的主簇,在其中添加<web-app>標(biāo)簽就可以配置虛擬目錄了,這時候這個應(yīng)用是使用默認(rèn)端口進行部署的。如果要給這個簇配置特定的端口號,可以在cluster標(biāo)簽第一個元素前面加上<server-default>標(biāo)簽,如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
< resin xmlns = "http://caucho.com/ns/resin" xmlns:resin = "urn:java:com.caucho.resin" > < cluster-default > <!-- shared configuration across all clusters --> < resin:import path = "classpath:META-INF/caucho/app-default.xml" /> < resin:import path = "${__DIR__}/health.xml" optional = "true" /> </ cluster-default > < cluster id = "my-cluster" > < server-default > <!-- thread limits, JVM config, keepalives, ports, HTTP --> < http port = "8083" /> </ server-default > < host id = "www.myhost.com" root-directory = "hosts/myhost.com" > < resin:MovedPermanently regexp = "/old-file" target = "/new-path" /> < web-app-deploy path = "webapps" expand-preserve-fileset = "WEB-INF/work/**" /> < web-app id = "/custom" > </ web-app > </ host > </ cluster > </ resin > |
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。
原文鏈接:https://blog.csdn.net/howareyouo/article/details/7776875