📄 index.xtp
字号:
<document> <header> <product>resin</product> <title>Hessian Service</title> <description> <p>Writing a Hessian service as a plain-old Java object (POJO)eliminates protocol dependencies and simplifies service testing.</p> </description> <type>tutorial</type> <tutorial-startpage>demo.jsp</tutorial-startpage> </header> <body> <summary/> <s1><p>The <a href="../hessian-add/">addition example</a> built the Hessianservice as an extension of HessianService for simplicity. Most serviceswill want to be independent of the Hessian protocol itself.</p></s1><s1 title="Files in this tutorial"><deftable><tr> <th>File</th> <th>Description</th></tr><tr> <td><viewfile-link file="WEB-INF/classes/example/MathService.java"/></td> <td>Interface for the math service.</td></tr><tr> <td><viewfile-link file="WEB-INF/classes/example/MathServiceImpl.java"/></td> <td>The main service implementation.</td></tr><tr> <td><viewfile-link file="WEB-INF/resin-web.xml"/></td> <td>Configures the environment</td></tr><tr> <td><viewfile-link file="demo.jsp"/></td> <td>Client JSP</td></tr><tr> <td><viewfile-link file="demo.php"/></td> <td>Client PHP</td></tr></deftable></s1><s1 title="Service Implementation"><p>The MathService implementation is just a Java class that implementsthe MatchService API.</p><example title="Example: MathServiceImpl.java">package example;public class MathServiceImpl implements MathService { public int add(int a, int b) { return a + b; }}</example></s1><s1 title="Remote Interface"><p>The Java interface describes the remote API. This example has anaddition method, <var>add()</var>.</p><p>Resin's proxy client implementation uses the remote interface toexpose the API to the proxy stub. Strictly speaking, though,the Java remote interface is not required for Hessian. A non-Java clientwill not use the Java interface, except possibly as documentation.</p><example title="Example: MathService.java">package example;public interface MathService { public int add(int a, int b);}</example></s1><s1 title="Service configuration"><example title="Example: resin-web.xml"><web-app xmlns="http://caucho.com/ns/resin"> <servlet-mapping url-pattern="/math/*" servlet-class="example.MathService"> <protocol uri="hessian:"/> </servlet-mapping> <remote-client name="math"> <uri>hessian:url=${webApp.url}/math/</uri> <interface>example.MathService</interface> </remote-client></web-app></example></s1><s1 title="Java Client"><p>The client is identical to the basic example.</p><example title="Example: demo.jsp"><%@ page import="javax.webbeans.In" %><%@ page import="example.MathService" %><%!@In MathService math;%><pre>3 + 2 = <%= math.add(3, 2) %>3 - 2 = <%= math.sub(3, 2) %>3 * 2 = <%= math.mul(3, 2) %>3 / 2 = <%= math.div(3, 2) %></pre></example><results>3 + 2 = 53 - 2 = 13 * 2 = 63 / 2 = 1</results></s1><s1 title="PHP Client"><p>The client is identical to the basic example.</p><example title="Example: demo.php"><?php$math = java_bean("math");?><pre>3 + 2 = <?= $math->add(3, 2) ?>3 - 2 = <?= $math->sub(3, 2) ?>3 * 2 = <?= $math->mul(3, 2) ?>3 / 2 = <?= $math->div(3, 2) ?></pre></example><results>3 + 2 = 53 - 2 = 13 * 2 = 63 / 2 = 1</results></s1> </body></document>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -