pax_global_header 0000666 0000000 0000000 00000000064 12175762007 0014521 g ustar 00root root 0000000 0000000 52 comment=3d941f7959c0f0d26243fa15725a9bdec059b783 hessian-4.0.33/ 0000775 0000000 0000000 00000000000 12175762007 0013242 5 ustar 00root root 0000000 0000000 hessian-4.0.33/com/ 0000775 0000000 0000000 00000000000 12175762007 0014020 5 ustar 00root root 0000000 0000000 hessian-4.0.33/com/caucho/ 0000775 0000000 0000000 00000000000 12175762007 0015262 5 ustar 00root root 0000000 0000000 hessian-4.0.33/com/caucho/burlap/ 0000775 0000000 0000000 00000000000 12175762007 0016547 5 ustar 00root root 0000000 0000000 hessian-4.0.33/com/caucho/burlap/client/ 0000775 0000000 0000000 00000000000 12175762007 0020025 5 ustar 00root root 0000000 0000000 hessian-4.0.33/com/caucho/burlap/client/BurlapMetaInfoAPI.java 0000664 0000000 0000000 00000005245 12175762007 0024100 0 ustar 00root root 0000000 0000000 /* * The Apache Software License, Version 1.1 * * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Caucho Technology (http://www.caucho.com/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "Burlap", "Resin", and "Caucho" must not be used to * endorse or promote products derived from this software without prior * written permission. For written permission, please contact * info@caucho.com. * * 5. Products derived from this software may not be called "Resin" * nor may "Resin" appear in their names without prior written * permission of Caucho Technology. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @author Scott Ferguson */ package com.caucho.burlap.client; /** * API retrieving burlap meta information. */ public interface BurlapMetaInfoAPI { /** * Returns a service attribute. * *
* String url = "http://localhost:8080/ejb/hello"; * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url); ** * After creation, the stub can be like a regular Java class. Because * it makes remote calls, it can throw more exceptions than a Java class. * In particular, it may throw protocol exceptions. * * The factory can also be configured as a JNDI resource. The factory * expects to parameters: "type" and "url", corresponding to the two * arguments to
create
*
* In Resin 3.0, the above example would be configured as:
* * <reference> * <name>hessian/hello</name> * <factory>com.caucho.hessian.client.HessianProxyFactory</factory> * <init url="http://localhost:8080/ejb/hello"/> * type="test.HelloHome"/> * </reference> ** * To get the above resource, use JNDI as follows: *
* Context ic = new InitialContext(); * HelloHome hello = (HelloHome) ic.lookup("java:comp/env/burlap/hello"); * * System.out.println("Hello: " + hello.helloWorld()); ** *
The proxy can use HTTP basic authentication if the user and the * password are set. */ public class BurlapProxyFactory implements ServiceProxyFactory, ObjectFactory { private BurlapRemoteResolver _resolver; private String _user; private String _password; private String _basicAuth; private long _readTimeout; private boolean _isOverloadEnabled = false; /** * Creates the new proxy factory. */ public BurlapProxyFactory() { _resolver = new BurlapProxyResolver(this); } /** * Sets the user. */ public void setUser(String user) { _user = user; _basicAuth = null; } /** * Sets the password. */ public void setPassword(String password) { _password = password; _basicAuth = null; } /** * Returns true if overloaded methods are allowed (using mangling) */ public boolean isOverloadEnabled() { return _isOverloadEnabled; } /** * set true if overloaded methods are allowed (using mangling) */ public void setOverloadEnabled(boolean isOverloadEnabled) { _isOverloadEnabled = isOverloadEnabled; } /** * Returns the remote resolver. */ public BurlapRemoteResolver getRemoteResolver() { return _resolver; } /** * Creates the URL connection. */ protected URLConnection openConnection(URL url) throws IOException { URLConnection conn = url.openConnection(); conn.setDoOutput(true); if (_basicAuth != null) conn.setRequestProperty("Authorization", _basicAuth); else if (_user != null && _password != null) { _basicAuth = "Basic " + base64(_user + ":" + _password); conn.setRequestProperty("Authorization", _basicAuth); } return conn; } /** * Creates a new proxy with the specified URL. The API class uses * the java.api.class value from _hessian_ * * @param url the URL where the client object is located. * * @return a proxy to the object with the specified interface. */ public Object create(String url) throws MalformedURLException, ClassNotFoundException { BurlapMetaInfoAPI metaInfo; metaInfo = (BurlapMetaInfoAPI) create(BurlapMetaInfoAPI.class, url); String apiClassName = (String) metaInfo._burlap_getAttribute("java.api.class"); if (apiClassName == null) throw new BurlapRuntimeException(url + " has an unknown api."); ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class apiClass = Class.forName(apiClassName, false, loader); return create(apiClass, url); } /** * Creates a new proxy with the specified URL. The returned object * is a proxy with the interface specified by api. * *
* String url = "http://localhost:8080/ejb/hello"); * HelloHome hello = (HelloHome) factory.create(HelloHome.class, url); ** * @param api the interface the proxy class needs to implement * @param url the URL where the client object is located. * * @return a proxy to the object with the specified interface. */ public Object create(Class api, String urlName) throws MalformedURLException { if (api == null) throw new NullPointerException(); URL url = new URL(urlName); try { // clear old keepalive connections HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setConnectTimeout(10); conn.setReadTimeout(10); conn.setRequestProperty("Connection", "close"); InputStream is = conn.getInputStream(); is.close(); conn.disconnect(); } catch (IOException e) { } BurlapProxy handler = new BurlapProxy(this, url); return Proxy.newProxyInstance(api.getClassLoader(), new Class[] { api, BurlapRemoteObject.class }, handler); } public AbstractBurlapInput getBurlapInput(InputStream is) { AbstractBurlapInput in = new BurlapInput(is); in.setRemoteResolver(getRemoteResolver()); return in; } public BurlapOutput getBurlapOutput(OutputStream os) { BurlapOutput out = new BurlapOutput(os); return out; } /** * JNDI object factory so the proxy can be used as a resource. */ public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable,?> environment) throws Exception { Reference ref = (Reference) obj; String api = null; String url = null; String user = null; String password = null; for (int i = 0; i < ref.size(); i++) { RefAddr addr = ref.get(i); String type = addr.getType(); String value = (String) addr.getContent(); if (type.equals("type")) api = value; else if (type.equals("url")) url = value; else if (type.equals("user")) setUser(value); else if (type.equals("password")) setPassword(value); } if (url == null) throw new NamingException("`url' must be configured for BurlapProxyFactory."); // XXX: could use meta protocol to grab this if (api == null) throw new NamingException("`type' must be configured for BurlapProxyFactory."); ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class apiClass = Class.forName(api, false, loader); return create(apiClass, url); } /** * Creates the Base64 value. */ private String base64(String value) { StringBuffer cb = new StringBuffer(); int i = 0; for (i = 0; i + 2 < value.length(); i += 3) { long chunk = (int) value.charAt(i); chunk = (chunk << 8) + (int) value.charAt(i + 1); chunk = (chunk << 8) + (int) value.charAt(i + 2); cb.append(encode(chunk >> 18)); cb.append(encode(chunk >> 12)); cb.append(encode(chunk >> 6)); cb.append(encode(chunk)); } if (i + 1 < value.length()) { long chunk = (int) value.charAt(i); chunk = (chunk << 8) + (int) value.charAt(i + 1); chunk <<= 8; cb.append(encode(chunk >> 18)); cb.append(encode(chunk >> 12)); cb.append(encode(chunk >> 6)); cb.append('='); } else if (i < value.length()) { long chunk = (int) value.charAt(i); chunk <<= 16; cb.append(encode(chunk >> 18)); cb.append(encode(chunk >> 12)); cb.append('='); cb.append('='); } return cb.toString(); } public static char encode(long d) { d &= 0x3f; if (d < 26) return (char) (d + 'A'); else if (d < 52) return (char) (d + 'a' - 26); else if (d < 62) return (char) (d + '0' - 52); else if (d == 62) return '+'; else return '/'; } } hessian-4.0.33/com/caucho/burlap/client/BurlapProxyResolver.java 0000664 0000000 0000000 00000005751 12175762007 0024711 0 ustar 00root root 0000000 0000000 /* * The Apache Software License, Version 1.1 * * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Caucho Technology (http://www.caucho.com/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "Burlap", "Resin", and "Caucho" must not be used to * endorse or promote products derived from this software without prior * written permission. For written permission, please contact * info@caucho.com. * * 5. Products derived from this software may not be called "Resin" * nor may "Resin" appear in their names without prior written * permission of Caucho Technology. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @author Scott Ferguson */ package com.caucho.burlap.client; import com.caucho.burlap.io.BurlapRemoteResolver; import java.io.IOException; /** * Looks up remote objects in the proxy. */ public class BurlapProxyResolver implements BurlapRemoteResolver { private BurlapProxyFactory factory; /** * Creates an uninitialized Burlap remote resolver. */ public BurlapProxyResolver(BurlapProxyFactory factory) { this.factory = factory; } /** * Looks up a proxy object. */ public Object lookup(String type, String url) throws IOException { ClassLoader loader = Thread.currentThread().getContextClassLoader(); try { Class api = Class.forName(type, false, loader); return factory.create(api, url); } catch (Exception e) { throw new IOException(String.valueOf(e)); } } } hessian-4.0.33/com/caucho/burlap/client/BurlapRemote.java 0000664 0000000 0000000 00000006654 12175762007 0023304 0 ustar 00root root 0000000 0000000 /* * The Apache Software License, Version 1.1 * * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Caucho Technology (http://www.caucho.com/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "Burlap", "Resin", and "Caucho" must not be used to * endorse or promote products derived from this software without prior * written permission. For written permission, please contact * info@caucho.com. * * 5. Products derived from this software may not be called "Resin" * nor may "Resin" appear in their names without prior written * permission of Caucho Technology. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @author Scott Ferguson */ package com.caucho.burlap.client; /** * Encapsulates a remote address when no stub is available, e.g. for * Java MicroEdition. */ public class BurlapRemote { private String type; private String url; /** * Creates a new Burlap remote object. * * @param type the remote stub interface * @param url the remote url */ public BurlapRemote(String type, String url) { this.type = type; this.url = url; } /** * Creates an uninitialized Burlap remote. */ public BurlapRemote() { } /** * Returns the remote api class name. */ public String getType() { return type; } /** * Returns the remote URL. */ public String getURL() { return url; } /** * Sets the remote URL. */ public void setURL(String url) { this.url = url; } /** * Defines the hashcode. */ public int hashCode() { return url.hashCode(); } /** * Defines equality */ public boolean equals(Object obj) { if (! (obj instanceof BurlapRemote)) return false; BurlapRemote remote = (BurlapRemote) obj; return url.equals(remote.url); } /** * Readable version of the remote. */ public String toString() { return "[Remote " + url + "]"; } } hessian-4.0.33/com/caucho/burlap/client/BurlapRuntimeException.java 0000664 0000000 0000000 00000006177 12175762007 0025353 0 ustar 00root root 0000000 0000000 /* * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. * * The Apache Software License, Version 1.1 * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Caucho Technology (http://www.caucho.com/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "Burlap", "Resin", and "Caucho" must not be used to * endorse or promote products derived from this software without prior * written permission. For written permission, please contact * info@caucho.com. * * 5. Products derived from this software may not be called "Resin" * nor may "Resin" appear in their names without prior written * permission of Caucho Technology. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @author Scott Ferguson */ package com.caucho.burlap.client; /** * Wrapper for protocol exceptions thrown in the proxy. */ public class BurlapRuntimeException extends RuntimeException { private Throwable rootCause; /** * Zero-arg constructor. */ public BurlapRuntimeException() { } /** * Create the exception. */ public BurlapRuntimeException(String message) { super(message); } /** * Create the exception. */ public BurlapRuntimeException(String message, Throwable rootCause) { super(message); this.rootCause = rootCause; } /** * Create the exception. */ public BurlapRuntimeException(Throwable rootCause) { super(String.valueOf(rootCause)); this.rootCause = rootCause; } /** * Returns the underlying cause. */ public Throwable getRootCause() { return this.rootCause; } /** * Returns the underlying cause. */ public Throwable getCause() { return this.rootCause; } } hessian-4.0.33/com/caucho/burlap/client/BurlapServiceException.java 0000664 0000000 0000000 00000005621 12175762007 0025321 0 ustar 00root root 0000000 0000000 /* * The Apache Software License, Version 1.1 * * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Caucho Technology (http://www.caucho.com/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "Burlap", "Resin", and "Caucho" must not be used to * endorse or promote products derived from this software without prior * written permission. For written permission, please contact * info@caucho.com. * * 5. Products derived from this software may not be called "Resin" * nor may "Resin" appear in their names without prior written * permission of Caucho Technology. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @author Scott Ferguson */ package com.caucho.burlap.client; /** * Exception for faults when the fault doesn't return a java exception. * This exception is required for MicroBurlapInput. */ public class BurlapServiceException extends Exception { private String code; private Object detail; /** * Zero-arg constructor. */ public BurlapServiceException() { } /** * Create the exception. */ public BurlapServiceException(String message, String code, Object detail) { super(message); this.code = code; this.detail = detail; } /** * Returns the code. */ public String getCode() { return code; } /** * Returns the detail. */ public Object getDetail() { return detail; } } hessian-4.0.33/com/caucho/burlap/client/MicroBurlapInput.java 0000664 0000000 0000000 00000056065 12175762007 0024143 0 ustar 00root root 0000000 0000000 /* * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. * * The Apache Software License, Version 1.1 * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Caucho Technology (http://www.caucho.com/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "Burlap", "Resin", and "Caucho" must not be used to * endorse or promote products derived from this software without prior * written permission. For written permission, please contact * info@caucho.com. * * 5. Products derived from this software may not be called "Resin" * nor may "Resin" appear in their names without prior written * permission of Caucho Technology. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @author Scott Ferguson */ package com.caucho.burlap.client; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Calendar; import java.util.Date; import java.util.Hashtable; import java.util.TimeZone; import java.util.Vector; /** * Input stream for Burlap requests, compatible with microedition * Java. It only uses classes and types available to J2ME. In * particular, it does not have any support for the <double> type. * *
MicroBurlapInput does not depend on any classes other than * in J2ME, so it can be extracted independently into a smaller package. * *
MicroBurlapInput is unbuffered, so any client needs to provide * its own buffering. * *
* InputStream is = ...; // from http connection * MicroBurlapInput in = new MicroBurlapInput(is); * String value; * * in.startReply(); // read reply header * value = in.readString(); // read string value * in.completeReply(); // read reply footer **/ public class MicroBurlapInput { private static int base64Decode[]; private InputStream is; protected int peek; protected boolean peekTag; protected Date date; protected Calendar utcCalendar; private Calendar localCalendar; protected Vector refs; protected String method; protected StringBuffer sbuf = new StringBuffer(); protected StringBuffer entity = new StringBuffer(); /** * Creates a new Burlap input stream, initialized with an * underlying input stream. * * @param is the underlying input stream. */ public MicroBurlapInput(InputStream is) { init(is); } /** * Creates an uninitialized Burlap input stream. */ public MicroBurlapInput() { } /** * Returns a call's method. */ public String getMethod() { return method; } /** * Initialize the Burlap input stream with a new underlying stream. * Applications can use
init(InputStream)
to reuse
* MicroBurlapInput to save garbage collection.
*/
public void init(InputStream is)
{
this.is = is;
this.refs = null;
}
/**
* Starts reading the call
*
* A successful completion will have a single value: * *
* <burlap:call> * <method>method</method> **/ public void startCall() throws IOException { expectStartTag("burlap:call"); expectStartTag("method"); method = parseString(); expectEndTag("method"); this.refs = null; } /** * Completes reading the call. * *
* </burlap:call> **/ public void completeCall() throws IOException { expectEndTag("burlap:call"); } /** * Reads a reply as an object. * If the reply has a fault, throws the exception. */ public Object readReply(Class expectedClass) throws Exception { if (startReply()) { Object value = readObject(expectedClass); completeReply(); return value; } else { Hashtable fault = readFault(); Object detail = fault.get("detail"); if (detail instanceof Exception) throw (Exception) detail; else { String code = (String) fault.get("code"); String message = (String) fault.get("message"); throw new BurlapServiceException(message, code, detail); } } } /** * Starts reading the reply. * *
A successful completion will have a single value. An unsuccessful * one will have a fault: * *
* <burlap:reply> ** * @return true if success, false for fault. */ public boolean startReply() throws IOException { this.refs = null; expectStartTag("burlap:reply"); if (! parseTag()) throw new BurlapProtocolException("expected
* </burlap:reply> **/ public void completeReply() throws IOException { expectEndTag("burlap:reply"); } /** * Reads a boolean value from the input stream. */ public boolean readBoolean() throws IOException { expectStartTag("boolean"); int value = parseInt(); expectEndTag("boolean"); return value != 0; } /** * Reads an integer value from the input stream. */ public int readInt() throws IOException { expectStartTag("int"); int value = parseInt(); expectEndTag("int"); return value; } /** * Reads a long value from the input stream. */ public long readLong() throws IOException { expectStartTag("long"); long value = parseLong(); expectEndTag("long"); return value; } /** * Reads a date value from the input stream. */ public long readUTCDate() throws IOException { expectStartTag("date"); if (utcCalendar == null) utcCalendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); long value = parseDate(utcCalendar); expectEndTag("date"); return value; } /** * Reads a date value from the input stream. */ public long readLocalDate() throws IOException { expectStartTag("date"); if (localCalendar == null) localCalendar = Calendar.getInstance(); long value = parseDate(localCalendar); expectEndTag("date"); return value; } /** * Reads a remote value from the input stream. */ public BurlapRemote readRemote() throws IOException { expectStartTag("remote"); String type = readType(); String url = readString(); expectEndTag("remote"); return new BurlapRemote(type, url); } /** * Reads a string value from the input stream. * *
The two valid possibilities are either a <null> * or a <string>. The string value is encoded in utf-8, and * understands the basic XML escapes: "&123;", "<", ">", * "'", """. * *
* <null></null> * <string>a utf-8 encoded string</string> **/ public String readString() throws IOException { if (! parseTag()) throw new BurlapProtocolException("expected
The two valid possibilities are either a <null>
* or a <base64>.
*/
public byte []readBytes()
throws IOException
{
if (! parseTag())
throw new BurlapProtocolException("expected MicroBurlapOutput does not depend on any classes other than
* in J2ME, so it can be extracted independently into a smaller package.
*
* MicroBurlapOutput is unbuffered, so any client needs to provide
* its own buffering.
*
*
* <type>a utf-8 encoded string</type>
*
*/
public String readType()
throws IOException
{
if (! parseTag())
throw new BurlapProtocolException("expected
* <length>integer</length>
*
*/
public int readLength()
throws IOException
{
expectStartTag("length");
int ch = skipWhitespace();
peek = ch;
if (ch == '<') {
expectEndTag("length");
return -1;
}
int value = parseInt();
expectEndTag("length");
return value;
}
/**
* Resolves a remote object.
*/
public Object resolveRemote(String type, String url)
throws IOException
{
return new BurlapRemote(type, url);
}
/**
* Reads a fault.
*/
public Hashtable readFault()
throws IOException
{
expectStartTag("fault");
Hashtable map = new Hashtable();
while (parseTag()) {
peekTag = true;
Object key = readObject(null);
Object value = readObject(null);
if (key != null && value != null)
map.put(key, value);
}
if (! sbuf.toString().equals("fault"))
throw new BurlapProtocolException("expected ");
return map;
}
/**
* Reads an object from the input stream.
*
* @param expectedClass the calling routine's expected class
* @param type the type from the stream
*/
public Object readMap(Class expectedClass, String type)
throws IOException
{
Hashtable map = new Hashtable();
if (refs == null)
refs = new Vector();
refs.addElement(map);
while (parseTag()) {
peekTag = true;
Object key = readObject(null);
Object value = readObject(null);
map.put(key, value);
}
if (! sbuf.toString().equals("map"))
throw new BurlapProtocolException("expected ");
return map;
}
/**
* Reads object unknown to MicroBurlapInput.
*/
protected Object readExtensionObject(Class expectedClass, String tag)
throws IOException
{
throw new BurlapProtocolException("unknown object tag <" + tag + ">");
}
/**
* Reads a list object from the input stream.
*
* @param expectedClass the calling routine's expected class
* @param type the type from the stream
* @param length the expected length, -1 for unspecified length
*/
public Object readList(Class expectedClass, String type, int length)
throws IOException
{
Vector list = new Vector();
if (refs == null)
refs = new Vector();
refs.addElement(list);
while (parseTag()) {
peekTag = true;
Object value = readObject(null);
list.addElement(value);
}
if (! sbuf.toString().equals("list"))
throw new BurlapProtocolException("expected ");
return list;
}
/**
* Parses an integer value from the stream.
*/
protected int parseInt()
throws IOException
{
int sign = 1;
int value = 0;
int ch = skipWhitespace();
if (ch == '+')
ch = read();
else if (ch == '-') {
sign = -1;
ch = read();
}
for (; ch >= '0' && ch <= '9'; ch = read())
value = 10 * value + ch - '0';
peek = ch;
return sign * value;
}
/**
* Parses a long value from the stream.
*/
protected long parseLong()
throws IOException
{
long sign = 1;
long value = 0;
int ch = skipWhitespace();
if (ch == '+')
ch = read();
else if (ch == '-') {
sign = -1;
ch = read();
}
for (; ch >= '0' && ch <= '9'; ch = read()) {
value = 10 * value + ch - '0';
}
peek = ch;
return sign * value;
}
/**
* Parses a date value from the stream.
*/
protected long parseDate(Calendar calendar)
throws IOException
{
int ch = skipWhitespace();
int year = 0;
for (int i = 0; i < 4; i++) {
if (ch >= '0' && ch <= '9')
year = 10 * year + ch - '0';
else
throw expectedChar("year", ch);
ch = read();
}
int month = 0;
for (int i = 0; i < 2; i++) {
if (ch >= '0' && ch <= '9')
month = 10 * month + ch - '0';
else
throw expectedChar("month", ch);
ch = read();
}
int day = 0;
for (int i = 0; i < 2; i++) {
if (ch >= '0' && ch <= '9')
day = 10 * day + ch - '0';
else
throw expectedChar("day", ch);
ch = read();
}
if (ch != 'T')
throw expectedChar("`T'", ch);
ch = read();
int hour = 0;
for (int i = 0; i < 2; i++) {
if (ch >= '0' && ch <= '9')
hour = 10 * hour + ch - '0';
else
throw expectedChar("hour", ch);
ch = read();
}
int minute = 0;
for (int i = 0; i < 2; i++) {
if (ch >= '0' && ch <= '9')
minute = 10 * minute + ch - '0';
else
throw expectedChar("minute", ch);
ch = read();
}
int second = 0;
for (int i = 0; i < 2; i++) {
if (ch >= '0' && ch <= '9')
second = 10 * second + ch - '0';
else
throw expectedChar("second", ch);
ch = read();
}
for (; ch > 0 && ch != '<'; ch = read()) {
}
peek = ch;
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month - 1);
calendar.set(Calendar.DAY_OF_MONTH, day);
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minute);
calendar.set(Calendar.SECOND, second);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime().getTime();
}
/**
* Parses a string value from the stream.
* string buffer is used for the result.
*/
protected String parseString()
throws IOException
{
StringBuffer sbuf = new StringBuffer();
return parseString(sbuf).toString();
}
/**
* Parses a string value from the stream. The burlap object's
* string buffer is used for the result.
*/
protected StringBuffer parseString(StringBuffer sbuf)
throws IOException
{
int ch = read();
for (; ch >= 0 && ch != '<'; ch = read()) {
if (ch == '&') {
ch = read();
if (ch == '#') {
ch = read();
if (ch >= '0' && ch <= '9') {
int v = 0;
for (; ch >= '0' && ch <= '9'; ch = read()) {
v = 10 * v + ch - '0';
}
sbuf.append((char) v);
}
}
else {
StringBuffer entityBuffer = new StringBuffer();
for (; ch >= 'a' && ch <= 'z'; ch = read())
entityBuffer.append((char) ch);
String entity = entityBuffer.toString();
if (entity.equals("amp"))
sbuf.append('&');
else if (entity.equals("apos"))
sbuf.append('\'');
else if (entity.equals("quot"))
sbuf.append('"');
else if (entity.equals("lt"))
sbuf.append('<');
else if (entity.equals("gt"))
sbuf.append('>');
else
throw new BurlapProtocolException("unknown XML entity &" + entity + "; at `" + (char) ch + "'");
}
if (ch != ';')
throw expectedChar("';'", ch);
}
else if (ch < 0x80)
sbuf.append((char) ch);
else if ((ch & 0xe0) == 0xc0) {
int ch1 = read();
int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f);
sbuf.append((char) v);
}
else if ((ch & 0xf0) == 0xe0) {
int ch1 = read();
int ch2 = read();
int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f);
sbuf.append((char) v);
}
else
throw new BurlapProtocolException("bad utf-8 encoding");
}
peek = ch;
return sbuf;
}
/**
* Parses a byte array.
*/
protected byte []parseBytes()
throws IOException
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
parseBytes(bos);
return bos.toByteArray();
}
/**
* Parses a byte array.
*/
protected ByteArrayOutputStream parseBytes(ByteArrayOutputStream bos)
throws IOException
{
int ch;
for (ch = read(); ch >= 0 && ch != '<'; ch = read()) {
int b1 = ch;
int b2 = read();
int b3 = read();
int b4 = read();
if (b4 != '=') {
int chunk = ((base64Decode[b1] << 18) +
(base64Decode[b2] << 12) +
(base64Decode[b3] << 6) +
(base64Decode[b4]));
bos.write(chunk >> 16);
bos.write(chunk >> 8);
bos.write(chunk);
}
else if (b3 != '=') {
int chunk = ((base64Decode[b1] << 12) +
(base64Decode[b2] << 6) +
(base64Decode[b3]));
bos.write(chunk >> 8);
bos.write(chunk);
}
else {
int chunk = ((base64Decode[b1] << 6) +
(base64Decode[b2]));
bos.write(chunk);
}
}
if (ch == '<')
peek = ch;
return bos;
}
protected void expectStartTag(String tag)
throws IOException
{
if (! parseTag())
throw new BurlapProtocolException("expected <" + tag + ">");
if (! sbuf.toString().equals(tag))
throw new BurlapProtocolException("expected <" + tag + "> at <" + sbuf + ">");
}
protected void expectEndTag(String tag)
throws IOException
{
if (parseTag())
throw new BurlapProtocolException("expected " + tag + ">");
if (! sbuf.toString().equals(tag))
throw new BurlapProtocolException("expected " + tag + "> at " + sbuf + ">");
}
/**
* Parses a tag. Returns true if it's a start tag.
*/
protected boolean parseTag()
throws IOException
{
if (peekTag) {
peekTag = false;
return true;
}
int ch = skipWhitespace();
boolean isStartTag = true;
if (ch != '<')
throw expectedChar("'<'", ch);
ch = read();
if (ch == '/') {
isStartTag = false;
ch = is.read();
}
if (! isTagChar(ch))
throw expectedChar("tag", ch);
sbuf.setLength(0);
for (; isTagChar(ch); ch = read())
sbuf.append((char) ch);
if (ch != '>')
throw expectedChar("'>'", ch);
return isStartTag;
}
protected IOException expectedChar(String expect, int actualChar)
{
return new BurlapProtocolException("expected " + expect + " at " +
(char) actualChar + "'");
}
protected IOException expectBeginTag(String expect, String tag)
{
return new BurlapProtocolException("expected <" + expect + "> at <" + tag + ">");
}
private boolean isTagChar(int ch)
{
return (ch >= 'a' && ch <= 'z' ||
ch >= 'A' && ch <= 'Z' ||
ch >= '0' && ch <= '9' ||
ch == ':' || ch == '-');
}
protected int skipWhitespace()
throws IOException
{
int ch = read();
for (;
ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r';
ch = read()) {
}
return ch;
}
protected boolean isWhitespace(int ch)
throws IOException
{
return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r';
}
protected int read()
throws IOException
{
if (peek > 0) {
int value = peek;
peek = 0;
return value;
}
return is.read();
}
static {
base64Decode = new int[256];
for (int i = 'A'; i <= 'Z'; i++)
base64Decode[i] = i - 'A';
for (int i = 'a'; i <= 'z'; i++)
base64Decode[i] = i - 'a' + 26;
for (int i = '0'; i <= '9'; i++)
base64Decode[i] = i - '0' + 52;
base64Decode['+'] = 62;
base64Decode['/'] = 63;
}
}
hessian-4.0.33/com/caucho/burlap/client/MicroBurlapOutput.java 0000664 0000000 0000000 00000040647 12175762007 0024343 0 ustar 00root root 0000000 0000000 /*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Caucho Technology (http://www.caucho.com/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "Burlap", "Resin", and "Caucho" must not be used to
* endorse or promote products derived from this software without prior
* written permission. For written permission, please contact
* info@caucho.com.
*
* 5. Products derived from this software may not be called "Resin"
* nor may "Resin" appear in their names without prior written
* permission of Caucho Technology.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @author Scott Ferguson
*/
package com.caucho.burlap.client;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Calendar;
import java.util.Date;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.TimeZone;
import java.util.Vector;
/**
* Output stream for Burlap requests, compatible with microedition
* Java. It only uses classes and types available to J2ME. In
* particular, it does not have any support for the <double> type.
*
*
* OutputStream os = ...; // from http connection
* MicroBurlapOutput out = new MicroBurlapOutput(os);
* String value;
*
* out.startCall("hello"); // start hello call
* out.writeString("arg1"); // write a string argument
* out.completeCall(); // complete the call
*
*/
public class MicroBurlapOutput {
private OutputStream os;
private Date date;
private Calendar utcCalendar;
private Calendar localCalendar;
/**
* Creates a new Burlap output stream, initialized with an
* underlying output stream.
*
* @param os the underlying output stream.
*/
public MicroBurlapOutput(OutputStream os)
{
init(os);
}
/**
* Creates an uninitialized Burlap output stream.
*/
public MicroBurlapOutput()
{
}
public void init(OutputStream os)
{
this.os = os;
}
/**
* Writes a complete method call.
*/
public void call(String method, Object []args)
throws IOException
{
startCall(method);
if (args != null) {
for (int i = 0; i < args.length; i++)
writeObject(args[i]);
}
completeCall();
}
/**
* Writes the method call:
*
*
*
* @param method the method name to call.
*/
public void startCall(String method)
throws IOException
{
print("
* <burlap:request>
* <method>add</method>
*
*/
public void completeCall()
throws IOException
{
print("
* </burlap:request>
*
*
* @param value the boolean value to write.
*/
public void writeBoolean(boolean value)
throws IOException
{
print("
* <boolean>1</boolean>
*
*
* @param value the integer value to write.
*/
public void writeInt(int value)
throws IOException
{
print("
* <int>123</int>
*
*
* @param value the long value to write.
*/
public void writeLong(long value)
throws IOException
{
print("
* <long>123</long>
*
*
* @param value the string value to write.
*/
public void writeNull()
throws IOException
{
print("
* <null></null>
*
*
* If the value is null, it will be written as
*
*
* <string>12.3e10</string>
*
*
* @param value the string value to write.
*/
public void writeString(String value)
throws IOException
{
if (value == null) {
print("
* <null></null>
*
*
* If the value is null, it will be written as
*
*
* <base64>dJmO==</base64>
*
*
* @param value the string value to write.
*/
public void writeBytes(byte []buffer, int offset, int length)
throws IOException
{
if (buffer == null) {
print("
* <null></null>
*
*
* @param value the date in milliseconds from the epoch in UTC
*/
public void writeUTCDate(long time)
throws IOException
{
print("
* <date>19980508T095131Z</date>
*
*
* @param value the date in milliseconds from the epoch in local timezone
*/
public void writeLocalDate(long time)
throws IOException
{
print("
* <date>19980508T095131Z</date>
*
*
* @param value the integer value to write.
*/
public void writeRef(int value)
throws IOException
{
print("");
printInt(value);
print("");
}
/**
* Writes a generic object. writeObject understands the following types:
*
*
* <ref>123</ref>
*
*
*
* Unknown objects will call writeCustomObject
.
*/
public void writeObject(Object object)
throws IOException
{
if (object == null)
writeNull();
else if (object instanceof String)
writeString((String) object);
else if (object instanceof Boolean)
writeBoolean(((Boolean) object).booleanValue());
else if (object instanceof Integer)
writeInt(((Integer) object).intValue());
else if (object instanceof Long)
writeLong(((Long) object).longValue());
else if (object instanceof Date)
writeUTCDate(((Date) object).getTime());
else if (object instanceof byte[]) {
byte []data = (byte []) object;
writeBytes(data, 0, data.length);
}
else if (object instanceof Vector) {
Vector vector = (Vector) object;
int size = vector.size();
writeListBegin(size, null);
for (int i = 0; i < size; i++)
writeObject(vector.elementAt(i));
writeListEnd();
}
else if (object instanceof Hashtable) {
Hashtable hashtable = (Hashtable) object;
writeMapBegin(null);
Enumeration e = hashtable.keys();
while (e.hasMoreElements()) {
Object key = e.nextElement();
Object value = hashtable.get(key);
writeObject(key);
writeObject(value);
}
writeMapEnd();
}
else
writeCustomObject(object);
}
/**
* Applications which override this can do custom serialization.
*
* @param object the object to write.
*/
public void writeCustomObject(Object object)
throws IOException
{
throw new IOException("unexpected object: " + object);
}
/**
* Writes the list header to the stream. List writers will call
* writeListBegin
followed by the list contents and then
* call writeListEnd
.
*
*
*/
public void writeListBegin(int length, String type)
throws IOException
{
print("
* <list>
* <type>java.util.ArrayList</type>
* <length>3</length>
* <int>1</int>
* <int>2</int>
* <int>3</int>
* </list>
*
");
}
/**
* Writes the map header to the stream. Map writers will call
* writeMapBegin
followed by the map contents and then
* call writeMapEnd
.
*
*
*/
public void writeMapBegin(String type)
throws IOException
{
print("");
}
/**
* Writes a remote object reference to the stream. The type is the
* type of the remote interface.
*
*
* <map>
* <type>java.util.Hashtable</type>
* <string>a</string;<int>1</int>
* <string>b</string;<int>2</int>
* <string>c</string;<int>3</int>
* </map>
*
*/
public void writeRemote(String type, String url)
throws IOException
{
print("
* <remote>
* <type>test.account.Account</type>
* <string>http://caucho.com/foo;ejbid=bar</string>
* </remote>
*
RPC Proxy Clients - BurlapProxyFactory
Most application clients will use BurlapProxyFactory to
create stub objects. The stub objects can be called with normal
Java calls. Because the objects are remote, the client application needs
to be able to deal with IOException caused by an unavailable server or
a protocol error.
import com.caucho.burlap.client.BurlapProxyFactory;
...
URL url = new URL("http://localhost:8080/ejb/hello");
HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
System.out.println("hello: " + hello.hello());
Serialization
Since the Burlap protocol serializes Java objects to XML, the
BurlapSerializerOutput and BurlapSerializerInput
can be used for serialization.
Serialization
OutputStream os = new FileOutputStream("test.xml");
BurlapOutput out = new BurlapSerializerOutput(os);
out.writeObject(obj);
os.close();
Deserialization
InputStream is = new FileInputStream("test.xml");
BurlapInput in = new BurlapSerializerInput(in);
Object obj = in.readObject();
is.close();
MicroBurlapInput and MicroBurlapOutput
These two classes only require classes from Java MicroEdition. So they
can be extracted separately into a burlap-micro.jar. Because of this
restriction and their small size, these two classes
are ideal for limited size devices like mobile phones and PDAs.