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

📄 index.xtp

📁 RESIN 3.2 最新源码
💻 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>">&lt;servlet-mapping url-pattern="/hello/*"                 servlet-class="example.HelloServiceImpl"                 jndi-name="service/HelloService">  &lt;protocol uri="hessian:"/>&lt;/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">&lt;remote-client name="hessian">  &lt;uri>hessian:url=${webApp.url}/hello/&lt;/uri>  &lt;interface>example.HelloService&lt;/interface>&lt;/remote-client>&lt;servlet servlet-name="service-frontend"          servlet-class="example.ServiceFrontendServlet" />&lt;servlet-mapping url-pattern="/frontend/" servlet-name="service-frontend" /></example></s1>  </body></document>

⌨️ 快捷键说明

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