⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 config-overview.xtp

📁 RESIN 3.2 最新源码
💻 XTP
📖 第 1 页 / 共 2 页
字号:
    &lt;host id="www.foo.com">      &lt;host-alias>foo.com&lt;/host-alias>      &lt;root-directory>foo.com&lt;/root-directory>    &lt;/host>    &lt;host id="">      &lt;root-directory>default-host&lt;/root-directory>    &lt;/host>    &lt;host-deploy path="hosts"/>  &lt;/cluster>&lt;/resin></example><p>The above example also introduces the &lt;host-default> tag.  The&lt;host-default> defines configuration common to all hosts following the&lt;host-default>.   In this case, we define an optional hostconfiguration file <var>host.xml</var> and a standard <var>webapps</var>deployment directory.  The &lt;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">&lt;server></a> tag toa <a href="cluster-tags.xtp#cluster">&lt;cluster></a> block.Each &lt;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">&lt;resin xmlns="http://caucho.com/ns/resin">  &lt;cluster id="app-tier">    &lt;server-default>      &lt;http port="80"/>      &lt;user-name>resin&lt;/user-name>    &lt;/server-default>    &lt;server id="app-a" address="192.168.2.10" port="6800"/>    &lt;server id="app-b" address="192.168.2.11" port="6800"/>    &lt;server id="app-c" address="192.168.2.12" port="6800"/>    &lt;host id="">       ...    &lt;/host>  &lt;/cluster>&lt;/resin></example><p>In the previous example, each server listens to port 80 as definedin the &lt;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">&lt;user-name></a> switches from root toa safer runtime uid.</p><p>The resin.xml can define multiple &lt;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">&lt;resin xmlns="http://caucho.com/ns/resin">  &lt;cluster id="web-tier">    &lt;server-default>      &lt;http port="80"/>    &lt;/server-default>    &lt;server id="web-a" address="192.168.1.10" port="6800"/>    &lt;cache memory-size="64M"/>    &lt;host id="">      &lt;web-app id="">        &lt;rewrite-dispatch>          &lt;load-balance regexp="" cluster="app-tier"/>        &lt;/rewrite-dispatch>      &lt;/web-app>    &lt;/host>  &lt;/cluster>  &lt;cluster id="web-tier">    &lt;server id="app-a" address="192.168.2.10" port="6800"/>    &lt;server id="app-b" address="192.168.2.11" port="6800"/>    &lt;server id="app-c" address="192.168.2.12" port="6800"/>    &lt;host id="www.foo.com">       ...    &lt;/host>  &lt;/cluster>&lt;/resin></example></s1><s1 title="URL rewriting and dispatching"><p>Resin includes a <a href="rewrite-tags.xtp">&lt;rewrite-dispatch&gt;</a>tag for general URL rewriting and dispatching similar to Apache's mod_rewrite.&lt;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">&lt;web-app xmlns="http://caucho.com/ns/resin">  &lt;rewrite-dispatch>    &lt;dispatch regexp="\.(php|gif|css|jpg|png)"/>    &lt;forward regexp="" target="/index.php"/>  &lt;/rewrite-dispatch>&lt;/web-app></example><s2 title="Redirecting changed hosts"><example title="resin.xml redirect">&lt;resin xmlns="http://caucho.com/ns/resin">  &lt;cluster id="">    ...    &lt;rewrite-dispatch>      &lt;redirect regexp="^http://www.foo.com" target="http://test.com/"/>  &lt;/rewrite-dispatch>  &lt;/cluster>&lt;/resin></example></s2><s2 title="Load balancing"><example title="resin.xml load balancing">&lt;resin xmlns="http://caucho.com/ns/resin">  &lt;cluster id="web-tier">    &lt;server id="web-a">       &lt;http port="80"/>    &lt;/server>    &lt;host id="">      &lt;web-app id="/">        &lt;rewrite-dispatch>          &lt;load-balance regexp="" cluster="app-tier"/>        &lt;/rewrite-dispatch>      &lt;/web-app>    &lt;/host>  &lt;/cluster>  &lt;cluster id="app-tier">     &lt;server id="app-a" server="192.168.2.10"/>     &lt;server id="app-b" server="192.168.2.11"/>     ...  &lt;/cluster>&lt;/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">&lt;web-service&gt;</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">&lt;web-app xmlns="http://caucho.com/ns/resin">&lt;web-service class="example.HelloServiceImpl">  &lt;jndi-name>service/HelloService&lt;/jndi-name>  &lt;init>    &lt;greeting>Hello, World&lt;/greeting>  &lt;/init>  &lt;hessian>    &lt;url-pattern>/hello/hessian/*&lt;/url-pattern>  &lt;/hessian>  &lt;rest>    &lt;url-pattern>/hello/rest/*&lt;/url-pattern>  &lt;/rest>  &lt;soap>    &lt;url-pattern>/hello/soap/*&lt;/url-pattern>  &lt;/soap>&lt;/web-service>&lt;/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">&lt;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">&lt;web-app xmlns="http://caucho.com/ns/resin">  &lt;web-service-client jndi-name="rest/flickr">    &lt;url>rest:http://foo.com/flickr/rest/&lt;/url>    &lt;interface>example.FlickrAPI&lt;/interface>    &lt;jaxb-package>example.data&lt;/jaxb-package>  &lt;/web-service-client>&lt;/web-app></example></s2></s1></body></document>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -