📄 index.xtp
字号:
<document> <header> <product>resin</product> <title>A frontend client for a Hessian service</title> <description> <p>This tutorial shows how to access services with Resin WebBeans injection. A servlet does frontend presentation for the results of a Hessian web service. </p> </description> <type>tutorial</type> <tutorial-startpage>frontend/</tutorial-startpage> </header> <body> <summary/><s1 title="Files in this tutorial"><deftable><tr> <th>File</th> <th>Description</th></tr><tr> <td><viewfile-link file="WEB-INF/classes/example/HelloService.java"/></td> <td>Interface for the hello service.</td></tr><tr><td><viewfile-link file="WEB-INF/classes/example/HelloServiceImpl.java"/></td></tr><tr><td><viewfile-link file="WEB-INF/classes/example/ServiceFrontendServlet.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></deftable></s1><s1 title="Service Interface and Configuration"><p>The service used in this example is the same hello world service usedin <a href="../soa-hello-world/index.xtp">the simple service tutorial</a>. Theinterface used by the frontend is shown below.</p><example title="HelloService.java">package example;public interface HelloService { /** * Returns "hello, world". */ public String hello();}</example><p>Configuring the service is also the same as in the <a href="../soa-hello-world/index.xtp">the simple service tutorial</a>.</p><example title="<servlet>"><servlet-mapping url-pattern="/hello/*" servlet-class="example.HelloServiceImpl" jndi-name="service/HelloService"> <protocol uri="hessian:"/></servlet-mapping></example></s1><s1 title="Frontend Client"><p>The client in this case is simply a servlet that uses J2EE injectionto access the service.</p><example title="ServiceFrontendServlet.java">package example;import java.io.*;import javax.annotation.*;import javax.servlet.*;import javax.servlet.http.*;public class ServiceFrontendServlet extends HttpServlet { @Named("hessian") private HelloService _helloService; public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { PrintStream out = new PrintStream(resp.getOutputStream()); out.println("service result: " + _helloService.hello()); }}</example><p>Configuring the client is nearly the same as in the <a href="../soa-hello-world/index.xtp">the simple service tutorial</a>, theonly difference being adding the mapping for the servlet.</p><example title="Client configuration"><remote-client name="hessian"> <uri>hessian:url=${webApp.url}/hello/</uri> <interface>example.HelloService</interface></remote-client><servlet servlet-name="service-frontend" servlet-class="example.ServiceFrontendServlet" /><servlet-mapping url-pattern="/frontend/" servlet-name="service-frontend" /></example></s1> </body></document>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -