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

📄 burlap.xtp

📁 RESIN 3.2 最新源码
💻 XTP
字号:
<document>  <header>    <product>resin</product>    <title>Burlap</title>    <description>      <p>Burlap is a simple XML-based protocol for connecting web        services.  The com.caucho.burlap.client and com.caucho.burlap.server        packages do not require any other Resin classes, so can be used in        smaller clients, like applets.</p>      <p>Because Burlap is a small protocol, J2ME devices like cell-phones can use        it to connect to Resin servers.  Because it's powerful, it can be used        for EJB services.</p>    </description>  </header>  <body>    <localtoc/><s1 title="Burlap Client"><p>Using a Burlap service from a Java client is like calling a method.The BurlapProxyFactory creates proxies which act like normal Javaobjects, with possibility that the method might throw a protocol exceptionif the remote connection fails.  Using BurlapProxyFactory requiresJDK&#160;1.3.</p><p>Each service will have a normal Java interface describing theservice.  The trivial hello, world example just returns a string.Because the Burlap services support Java serialization, any Java typecan be used.</p><example title="API for Basic service">package burlap.test;public interface Basic {  public String hello();}</example><p>The following is an example of a standalone Burlap client.  Theclient creates a BurlapProxyFactory.  The client uses the factory tocreate client stubs with the given target URL and a Java interface forthe API.  The returned object is a stub implementing the API.</p><example title="Burlap Client for Basic service">package burlap.test;import java.net.URL;import com.caucho.burlap.client.BurlapProxyFactory;public class BasicClient {  public static void main(String []args)    throws Exception  {    URL url = new URL("http://www.caucho.com/burlap/test/basic");    BurlapProxyFactory factory = new BurlapProxyFactory();    Basic basic = (Basic) factory.create(Basic.class, url);    System.out.println("Hello: " + basic.hello());  }}</example><p>There are no more complications to using the client.  Theservice can add methods and use any Java type for parameters and results.</p></s1><s1 title="Burlap Service"><p>While most Burlap services will use Resin-CMP or Resin-EJB, to takeadvantage of the benefits of EJB, the Burlap library makes it possibleto write services by extending BurlapServlet.</p><p>Any public method is treated as a service method.  So adding newmethods is as easy as writing a normal Java class.</p><p>Because the service is implemented as a Servlet, it can use allthe familiar servlet data in the ServletContext, just like anormal servlet.</p><example title="Hello Service">package burlap.test;import com.caucho.burlap.server.BurlapServlet;public class BasicService extends BurlapServlet implements Basic {  public String hello()  {    return "Hello, world";  }}</example></s1><s1 title="Burlap Client for a cell-phone"><p>Burlap can be used for even small Java devices.  The following classesfrom com.caucho.burlap.client can be extracted into a J2ME jar:</p><ul><li>MicroBurlapInput</li><li>MicroBurlapOutput</li><li>BurlapRemote</li><li>BurlapServiceException</li><li>BurlapProtocolException</li></ul><p>The following example shows the code for using a cell phone as aclient.  It's a bit more complicated than using the proxy, since theclient is responsible for creating the connection and writing thedata.</p><example title="Hello, world">import javax.microedition.io.Connector;import javax.microedition.io.HttpConnection;...MicroBurlapInput in = new MicroBurlapInput();String url = "http://www.caucho.com/burlap/test/basic";HttpConnection c = (HttpConnection) Connector.open(url);c.setRequestMethod(HttpConnection.POST);OutputStream os = c.openOutputStream();MicroBurlapOutput out = new MicroBurlapOutput(os);out.call("hello", null);os.flush();is = c.openInputStream();MicroBurlapInput in = new MicroBurlapInput(is);Object value = in.readReply(null);</example></s1><s1 title="Burlap Serialization"><p>The Burlap classes can be used for serialization and deserialization.</p><example title="Serialization">Object obj = ...;OutputStream os = new FileOutputStream("test.xml");BurlapOutput out = new BurlapOutput(os);out.writeObject(obj);os.close();</example><example title="Deserialization">InputStream is = new FileInputStream("test.xml");BurlapInput in = new BurlapInput(is);Object obj = in.readObject(null);is.close();</example></s1>  </body></document>

⌨️ 快捷键说明

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