📄 config-overview.xtp
字号:
<host id="www.foo.com"> <host-alias>foo.com</host-alias> <root-directory>foo.com</root-directory> </host> <host id=""> <root-directory>default-host</root-directory> </host> <host-deploy path="hosts"/> </cluster></resin></example><p>The above example also introduces the <host-default> tag. The<host-default> defines configuration common to all hosts following the<host-default>. In this case, we define an optional hostconfiguration file <var>host.xml</var> and a standard <var>webapps</var>deployment directory. The <host-default> are processed as macrosin configuration-file order. So a configuration tag later in the filecan override the defaults.</p></s1><s1 title="Clustering"><p>In Resin, adding servers to a cluster is just addinga <a href="server-tags.xtp#server"><server></a> tag toa <a href="cluster-tags.xtp#cluster"><cluster></a> block.Each <server> has an <var>id</var> which is unique in theresin.xml file. The server will also have aunique <var>address</var> and <var>port</var> which allowsthe servers in the cluster to communicate with each other.</p><p>Clustering is used for <a href="resin-clustering.xtp">load-balancing</a>,<a href="sessions.xtp">distributed sessions</a> and remoteadministration. Adding servers to a cluster lets sites handle more trafficand improves reliability by providing redundant servers.</p><example title="resin.xml for hardware load balancing"><resin xmlns="http://caucho.com/ns/resin"> <cluster id="app-tier"> <server-default> <http port="80"/> <user-name>resin</user-name> </server-default> <server id="app-a" address="192.168.2.10" port="6800"/> <server id="app-b" address="192.168.2.11" port="6800"/> <server id="app-c" address="192.168.2.12" port="6800"/> <host id=""> ... </host> </cluster></resin></example><p>In the previous example, each server listens to port 80 as definedin the <server-default>. The unique <var>id</var> and <var>address</var>are internal IP addresses. (The server <var>address</var> should never beexternal.) Because the example is listening to port 80, the<a href="server-tags.xtp#user-name"><user-name></a> switches from root toa safer runtime uid.</p><p>The resin.xml can define multiple <cluster> tags in the sameresin.xml. Resin's load-balancing will typically use two clusters,a web-tier for the HTTP servers and an app-tier for the servlets,PHP and JSP files. A sample load balancing configuration might look like:</p><example title="resin.xml for resin load balancing"><resin xmlns="http://caucho.com/ns/resin"> <cluster id="web-tier"> <server-default> <http port="80"/> </server-default> <server id="web-a" address="192.168.1.10" port="6800"/> <cache memory-size="64M"/> <host id=""> <web-app id=""> <rewrite-dispatch> <load-balance regexp="" cluster="app-tier"/> </rewrite-dispatch> </web-app> </host> </cluster> <cluster id="web-tier"> <server id="app-a" address="192.168.2.10" port="6800"/> <server id="app-b" address="192.168.2.11" port="6800"/> <server id="app-c" address="192.168.2.12" port="6800"/> <host id="www.foo.com"> ... </host> </cluster></resin></example></s1><s1 title="URL rewriting and dispatching"><p>Resin includes a <a href="rewrite-tags.xtp"><rewrite-dispatch></a>tag for general URL rewriting and dispatching similar to Apache's mod_rewrite.<rewrite-dispatch> can forward to a new location when a site moves content,it can convert host urls into paths, and rewrite "pretty" URLs intoPHP pages, load-balance to a cluster, and dispatch to normal servlets.</p><p>The following example rewrites "pretty" URLs like /wiki/Load-balance toactual urls like <var>/wiki/index.php/Load-balance</var></p><example title="resin-web.xml rewrite for Mediawiki"><web-app xmlns="http://caucho.com/ns/resin"> <rewrite-dispatch> <dispatch regexp="\.(php|gif|css|jpg|png)"/> <forward regexp="" target="/index.php"/> </rewrite-dispatch></web-app></example><s2 title="Redirecting changed hosts"><example title="resin.xml redirect"><resin xmlns="http://caucho.com/ns/resin"> <cluster id=""> ... <rewrite-dispatch> <redirect regexp="^http://www.foo.com" target="http://test.com/"/> </rewrite-dispatch> </cluster></resin></example></s2><s2 title="Load balancing"><example title="resin.xml load balancing"><resin xmlns="http://caucho.com/ns/resin"> <cluster id="web-tier"> <server id="web-a"> <http port="80"/> </server> <host id=""> <web-app id="/"> <rewrite-dispatch> <load-balance regexp="" cluster="app-tier"/> </rewrite-dispatch> </web-app> </host> </cluster> <cluster id="app-tier"> <server id="app-a" server="192.168.2.10"/> <server id="app-b" server="192.168.2.11"/> ... </cluster></resin></example></s2></s1><s1 title="Web Services: REST, Hessian, SOAP"><p>With Resin 3.1, applications can deploy<a href="../tutorial/rest-flickr/index.xtp">REST</a>, <a href="hessian.xtp">Hessian</a>, and SOAP using thesame instance class. A good introductary exampleis the <a href="soa|tutorial/soa-hello-world/index.xtp">SOA Hello, World tutorial.</a></p><s2 title="Web Service configuration"><p>The <a href="soa-tags.xtp#web-service"><web-service></a>tag configures the web service. The service is a Java object whichexposes a JAX-WS interface and receives and sends Java objectsencoded with JAXB. The service object itself is configuredusing JAXB-style IoC, i.e. standard bean-style propertyinitialization.</p><example title="resin-web.xml web-service"><web-app xmlns="http://caucho.com/ns/resin"><web-service class="example.HelloServiceImpl"> <jndi-name>service/HelloService</jndi-name> <init> <greeting>Hello, World</greeting> </init> <hessian> <url-pattern>/hello/hessian/*</url-pattern> </hessian> <rest> <url-pattern>/hello/rest/*</url-pattern> </rest> <soap> <url-pattern>/hello/soap/*</url-pattern> </soap></web-service></web-app></example></s2><s2 title="Web Service Client configuration"><p>The web service client configuration makes a Java proxyavailable to servlets and PHP pages through JNDI, or through a@Resource injection. The client can be SOAP, Hessian, or REST.A <a href="soa|tutorial/soa-flickr/index.xtp">REST tutorial</a> showshow to obtain a proxy to the Flickr REST service.</p><p>The <a href="soa-tags.xtp#web-service-client"><web-service-client></a>tag configures the client proxy. It provides a Java interface anda URL for the service. The URL specifies the encoding and the protocol,e.g. REST over HTTP or Hessian over HTTP. The client will typicallyhave a <var>jndi-name</var> to store the client proxy.</p><example title="web-service-client in resin-web.xml"><web-app xmlns="http://caucho.com/ns/resin"> <web-service-client jndi-name="rest/flickr"> <url>rest:http://foo.com/flickr/rest/</url> <interface>example.FlickrAPI</interface> <jaxb-package>example.data</jaxb-package> </web-service-client></web-app></example></s2></s1></body></document>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -