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

📄 index.xtp

📁 RESIN 3.2 最新源码
💻 XTP
字号:
<document>  <header>    <product>resin-ee</product>    <resin-2.0>$ee/ejb-tut/burlap.xtp</resin-2.0>    <title>Burlap Hello</title>  </header>  <body>    <summary/><p>The Resin-EJB implementation uses Burlap as its remote procedurecall protocol and its object serialization protocol.  Because Burlap issimple, clients from other languages can easily access the EJB services.</p><p>Because EJB clients and servers are written without knowledge of theunderlying protocol, even if you intend to deploy with another protocol,like RMI/IIOP, you can develop using Resin's Burlap.</p><p>A working draft of the<a href="../../burlap-draft-spec.xtp">Burlap 1.0 draft spec</a> isnow available.</p><s1 title="Burlap"><p>A Burlap call is just an HTTP POST to a servlet.  The arguments areserialized into an text format and passed to the server.</p><example title="Burlap call">&lt;burlap:call&gt;  &lt;method&gt;add&lt;/method&gt;  &lt;int&gt;2&lt;/int&gt;  &lt;int&gt;3&lt;/int&gt;&lt;/burlap:call&gt;</example><example title="Burlap reply">&lt;burlap:reply&gt;  &lt;int&gt;5&lt;/int&gt;&lt;/burlap:reply&gt;</example><p>The following hello, world example shows how to create a basic server so youcan test Burlap.</p></s1><s1 title="Why Burlap?"><p>Burlap is a very simple, yet complete, RPC protocol.  It's main purpose isto make testing and debugging of remote procedure calls easier.  Since it'ssimple, its performance should be usable for almost all sites.  Even if thefinal deployed site will use other protocols, you can use Burlap to speeddevelopment.</p></s1><s1 title="A Burlap Example"><p>Using Burlap requires three components:</p><ol><li>A remote interface</li><li>The server implementation</li><li>The client (JSP or servlet)</li></ol><p>These three components are also needed for any EJB implementation; they'rejust a bit more complicated in EJB.  When testing this example, you cancreate WEB-INF/classes/test/Hello.java andWEB-INF/classes/test/HelloRpcServlet.java and Resin will handlethe compilation for you.</p></s1><s1 title="Remote Interface"><p>The Java interface describes the remote API.  This example has asingle method, <var>hello()</var>.  Because you need to treat remote callswith more care than local calls, the Hello interface throws aRemoteException.</p><example title="Hello.java">package test;import javax.ejb.*;import java.rmi.*;public interface Hello extends Remote {  public String hello() throws RemoteException;}</example></s1><s1 title="Server Implementation"><p>Resin's Burlap provides a simple way of creating a server.  Just extend<code>BurlapServlet</code> with your remote methods.  The Burlap call will justbe a POST to that servlet.</p><p>This simplifies creating services.  You can ignore the complexities ofEJB and just get going.</p><example title="HelloRpcServlet.java">package test;import java.rmi.*;import com.caucho.burlap.*;public class HelloRpcServlet extends BurlapServlet implements Hello {  public String hello() throws RemoteException  {    return "Hello, world";  }}</example></s1><s1 title="Client"><p>RPC clients follow the following steps in using a remote object:</p><ol><li>Create a <var>handle</var> to the remote object.</li><li>Obtain a <var>stub</var> from the handle.</li><li>Call methods on the <var>stub</var>.</li></ol><p>The handle is a locator to the remote service.  The handle isa pair consisting of:</p><ol><li>the URL locating the remote server</li><li>the Java class of the remote interface</li></ol><example title="hello.jsp">&lt;%@ page import="com.caucho.burlap.*, test.*" %&gt;&lt;%String url = "http://localhost:8080/servlet/test.HelloRpcServlet/";BurlapHomeHandle handle = new BurlapHomeHandle(url);Hello hello = (Hello) handle.getEJBHome();%&gt;message: &lt;%= hello.hello() %&gt;</example><results>message: Hello, world</results></s1><s1 title="Burlap protocol for the example"><p>Since the example uses the burlap protocol, you can use 'telnet' as asimple client.</p><results>unix&gt; <var>telnet localhost 8080</var>Trying 127.0.0.1...Connected to localhost (127.0.0.1).Escape character is '^]'.<var>POST /servlet/test.HelloRpcServlet HTTP/1.0</var><var>Content-Length: 54</var><var>&lt;burlap:call&gt;</var><var>&lt;method&gt;hello&lt;/method&gt;</var><var>&lt;/burlap:call&gt;</var>HTTP/1.0 200 OKServer: Resin/1.3.s010312Content-Length: 73Date: Tue, 13 Mar 2001 03:15:27 GMT&lt;burlap:reply&gt;&lt;string&gt;Hello, world&lt;/string&gt;&lt;/burlap:reply&gt;</results><p>The results have some added whitespace to make the example morereadable.  The server doesn't bother trying to pretty-print the results.</p></s1>  </body></document>

⌨️ 快捷键说明

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