├── doc └── hessian-serialization.ietf ├── maven2 ├── ivy.xml └── pom.xml └── src ├── META-INF └── hessian │ ├── deserializers │ └── serializers ├── com └── caucho │ ├── burlap │ ├── client │ │ ├── BurlapMetaInfoAPI.java │ │ ├── BurlapProtocolException.java │ │ ├── BurlapProxy.java │ │ ├── BurlapProxyFactory.java │ │ ├── BurlapProxyResolver.java │ │ ├── BurlapRemote.java │ │ ├── BurlapRuntimeException.java │ │ ├── BurlapServiceException.java │ │ ├── MicroBurlapInput.java │ │ ├── MicroBurlapOutput.java │ │ └── package.html │ ├── io │ │ ├── AbstractBurlapInput.java │ │ ├── AbstractBurlapOutput.java │ │ ├── AbstractBurlapResolver.java │ │ ├── BurlapInput.java │ │ ├── BurlapOutput.java │ │ ├── BurlapProtocolException.java │ │ ├── BurlapRemote.java │ │ ├── BurlapRemoteObject.java │ │ ├── BurlapRemoteResolver.java │ │ └── BurlapServiceException.java │ └── server │ │ ├── BurlapServlet.java │ │ └── BurlapSkeleton.java │ ├── hessian │ ├── HessianException.java │ ├── HessianUnshared.java │ ├── client │ │ ├── AbstractHessianConnection.java │ │ ├── AbstractHessianConnectionFactory.java │ │ ├── HessianConnection.java │ │ ├── HessianConnectionException.java │ │ ├── HessianConnectionFactory.java │ │ ├── HessianMetaInfoAPI.java │ │ ├── HessianProxy.java │ │ ├── HessianProxyFactory.java │ │ ├── HessianProxyResolver.java │ │ ├── HessianRuntimeException.java │ │ ├── HessianURLConnection.java │ │ ├── HessianURLConnectionFactory.java │ │ └── package.html │ ├── io │ │ ├── AbstractDeserializer.java │ │ ├── AbstractDeserializerWrapper.java │ │ ├── AbstractHessianInput.java │ │ ├── AbstractHessianOutput.java │ │ ├── AbstractHessianResolver.java │ │ ├── AbstractListDeserializer.java │ │ ├── AbstractMapDeserializer.java │ │ ├── AbstractSerializer.java │ │ ├── AbstractSerializerFactory.java │ │ ├── AbstractSerializerWrapper.java │ │ ├── AbstractStreamDeserializer.java │ │ ├── AbstractStreamSerializer.java │ │ ├── AbstractStringValueDeserializer.java │ │ ├── AnnotationDeserializer.java │ │ ├── AnnotationInvocationHandler.java │ │ ├── AnnotationSerializer.java │ │ ├── ArrayDeserializer.java │ │ ├── ArraySerializer.java │ │ ├── BasicDeserializer.java │ │ ├── BasicSerializer.java │ │ ├── BeanDeserializer.java │ │ ├── BeanSerializer.java │ │ ├── BeanSerializerFactory.java │ │ ├── BigDecimalDeserializer.java │ │ ├── ByteArraySerializer.java │ │ ├── ByteHandle.java │ │ ├── CalendarHandle.java │ │ ├── CalendarSerializer.java │ │ ├── ClassDeserializer.java │ │ ├── ClassFactory.java │ │ ├── ClassSerializer.java │ │ ├── CollectionDeserializer.java │ │ ├── CollectionSerializer.java │ │ ├── ContextSerializerFactory.java │ │ ├── Deflation.java │ │ ├── Deserializer.java │ │ ├── EnumDeserializer.java │ │ ├── EnumSerializer.java │ │ ├── EnumerationDeserializer.java │ │ ├── EnumerationSerializer.java │ │ ├── EnvelopeFactory.java │ │ ├── ExtSerializerFactory.java │ │ ├── FieldDeserializer2.java │ │ ├── FieldDeserializer2Factory.java │ │ ├── FieldDeserializer2FactoryUnsafe.java │ │ ├── FileDeserializer.java │ │ ├── FloatHandle.java │ │ ├── Hessian2Constants.java │ │ ├── Hessian2Input.java │ │ ├── Hessian2Output.java │ │ ├── Hessian2StreamingInput.java │ │ ├── Hessian2StreamingOutput.java │ │ ├── HessianDebugInputStream.java │ │ ├── HessianDebugOutputStream.java │ │ ├── HessianDebugState.java │ │ ├── HessianEnvelope.java │ │ ├── HessianFactory.java │ │ ├── HessianFieldException.java │ │ ├── HessianHandle.java │ │ ├── HessianInput.java │ │ ├── HessianInputFactory.java │ │ ├── HessianMethodSerializationException.java │ │ ├── HessianOutput.java │ │ ├── HessianProtocolException.java │ │ ├── HessianRemote.java │ │ ├── HessianRemoteObject.java │ │ ├── HessianRemoteResolver.java │ │ ├── HessianSerializerInput.java │ │ ├── HessianSerializerOutput.java │ │ ├── HessianServiceException.java │ │ ├── IOExceptionWrapper.java │ │ ├── InetAddressHandle.java │ │ ├── InetAddressSerializer.java │ │ ├── InputStreamDeserializer.java │ │ ├── InputStreamSerializer.java │ │ ├── IteratorDeserializer.java │ │ ├── IteratorSerializer.java │ │ ├── JavaDeserializer.java │ │ ├── JavaSerializer.java │ │ ├── JavaUnsharedSerializer.java │ │ ├── LocaleHandle.java │ │ ├── LocaleSerializer.java │ │ ├── MapDeserializer.java │ │ ├── MapSerializer.java │ │ ├── ObjectDeserializer.java │ │ ├── ObjectHandleSerializer.java │ │ ├── ObjectNameDeserializer.java │ │ ├── ObjectSerializer.java │ │ ├── RemoteDeserializer.java │ │ ├── RemoteSerializer.java │ │ ├── Serializer.java │ │ ├── SerializerFactory.java │ │ ├── ShortHandle.java │ │ ├── SqlDateDeserializer.java │ │ ├── SqlDateSerializer.java │ │ ├── StackTraceElementDeserializer.java │ │ ├── StringValueDeserializer.java │ │ ├── StringValueSerializer.java │ │ ├── ThrowableSerializer.java │ │ ├── UnsafeDeserializer.java │ │ ├── UnsafeSerializer.java │ │ ├── UnsafeUnsharedSerializer.java │ │ ├── ValueDeserializer.java │ │ └── WriteReplaceSerializer.java │ ├── jmx │ │ ├── JMXSerializerFactory.java │ │ ├── MBeanAttributeInfoDeserializer.java │ │ ├── MBeanConstructorInfoDeserializer.java │ │ ├── MBeanInfoDeserializer.java │ │ ├── MBeanNotificationInfoDeserializer.java │ │ ├── MBeanOperationInfoDeserializer.java │ │ ├── MBeanParameterInfoDeserializer.java │ │ └── ObjectInstanceDeserializer.java │ ├── micro │ │ ├── MicroHessianInput.java │ │ └── MicroHessianOutput.java │ ├── mux │ │ ├── MuxInputStream.java │ │ ├── MuxOutputStream.java │ │ └── MuxServer.java │ ├── security │ │ ├── X509Encryption.java │ │ └── X509Signature.java │ ├── server │ │ ├── HessianServlet.java │ │ └── HessianSkeleton.java │ ├── test │ │ ├── A0.java │ │ ├── A1.java │ │ ├── A10.java │ │ ├── A11.java │ │ ├── A12.java │ │ ├── A13.java │ │ ├── A14.java │ │ ├── A15.java │ │ ├── A16.java │ │ ├── A2.java │ │ ├── A3.java │ │ ├── A4.java │ │ ├── A5.java │ │ ├── A6.java │ │ ├── A7.java │ │ ├── A8.java │ │ ├── A9.java │ │ ├── Test.java │ │ ├── TestCons.java │ │ ├── TestHessian2.java │ │ ├── TestHessian2Servlet.java │ │ ├── TestHessianServlet.java │ │ └── TestObject.java │ └── util │ │ ├── HessianFreeList.java │ │ ├── IdentityIntMap.java │ │ └── IntMap.java │ └── services │ ├── client │ └── ServiceProxyFactory.java │ ├── message │ ├── MessageSender.java │ └── MessageServiceException.java │ ├── name │ ├── NameServer.java │ ├── NameServerRemote.java │ └── NameServiceException.java │ └── server │ ├── AbstractSkeleton.java │ ├── GenericService.java │ ├── Service.java │ └── ServiceContext.java └── manifest /maven2/ivy.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /maven2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | com.caucho 7 | hessian 8 | @VERSION@ 9 | 10 | jar 11 | Hessian 12 | Hessian is a compact binary protocol for connecting web services 13 | http://hessian.caucho.com 14 | 15 | 16 | 17 | The Apache Software License, Version 1.1 18 | http://www.apache.org/licenses/LICENSE-1.1.txt 19 | repo 20 | 21 | 22 | 23 | 24 | 25 | Scott Ferguson 26 | ferg@caucho.com 27 | Caucho Technology, Inc 28 | https://www.caucho.com 29 | 30 | 31 | 32 | 33 | 34 | javax.servlet 35 | servlet-api 36 | 2.5 37 | provided 38 | 39 | 40 | 41 | 42 | scm:svn:svn://svn.caucho.com/home/svn/svnroot/resin/trunk/modules/hessian 43 | svn://svn.caucho.com/home/svn/svnroot/resin/trunk/modules/hessian 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/META-INF/hessian/deserializers: -------------------------------------------------------------------------------- 1 | java.io.File=com.caucho.hessian.io.FileDeserializer 2 | java.math.BigDecimal=com.caucho.hessian.io.BigDecimalDeserializer 3 | javax.management.ObjectName=com.caucho.hessian.io.ObjectNameDeserializer 4 | -------------------------------------------------------------------------------- /src/META-INF/hessian/serializers: -------------------------------------------------------------------------------- 1 | com.caucho.hessian.io.HessianRemoteObject=com.caucho.hessian.io.RemoteSerializer 2 | com.caucho.burlap.io.BurlapRemoteObject=com.caucho.hessian.io.RemoteSerializer 3 | java.io.File=com.caucho.hessian.io.StringValueSerializer 4 | java.math.BigDecimal=com.caucho.hessian.io.StringValueSerializer 5 | java.util.Locale=com.caucho.hessian.io.LocaleSerializer 6 | javax.management.ObjectName=com.caucho.hessian.io.StringValueSerializer 7 | -------------------------------------------------------------------------------- /src/com/caucho/burlap/client/BurlapMetaInfoAPI.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The Apache Software License, Version 1.1 3 | * 4 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.burlap.client; 50 | 51 | /** 52 | * API retrieving burlap meta information. 53 | */ 54 | public interface BurlapMetaInfoAPI { 55 | /** 56 | * Returns a service attribute. 57 | * 58 | * 64 | */ 65 | public Object _burlap_getAttribute(String name); 66 | } 67 | -------------------------------------------------------------------------------- /src/com/caucho/burlap/client/BurlapProxyResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The Apache Software License, Version 1.1 3 | * 4 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.burlap.client; 50 | 51 | import com.caucho.burlap.io.BurlapRemoteResolver; 52 | 53 | import java.io.IOException; 54 | 55 | /** 56 | * Looks up remote objects in the proxy. 57 | */ 58 | public class BurlapProxyResolver implements BurlapRemoteResolver { 59 | private BurlapProxyFactory factory; 60 | 61 | /** 62 | * Creates an uninitialized Burlap remote resolver. 63 | */ 64 | public BurlapProxyResolver(BurlapProxyFactory factory) 65 | { 66 | this.factory = factory; 67 | } 68 | 69 | /** 70 | * Looks up a proxy object. 71 | */ 72 | public Object lookup(String type, String url) 73 | throws IOException 74 | { 75 | ClassLoader loader = Thread.currentThread().getContextClassLoader(); 76 | 77 | try { 78 | Class api = Class.forName(type, false, loader); 79 | 80 | return factory.create(api, url); 81 | } catch (Exception e) { 82 | throw new IOException(String.valueOf(e)); 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/com/caucho/burlap/client/BurlapServiceException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The Apache Software License, Version 1.1 3 | * 4 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.burlap.client; 50 | 51 | /** 52 | * Exception for faults when the fault doesn't return a java exception. 53 | * This exception is required for MicroBurlapInput. 54 | */ 55 | public class BurlapServiceException extends Exception { 56 | private String code; 57 | private Object detail; 58 | 59 | /** 60 | * Zero-arg constructor. 61 | */ 62 | public BurlapServiceException() 63 | { 64 | } 65 | 66 | /** 67 | * Create the exception. 68 | */ 69 | public BurlapServiceException(String message, String code, Object detail) 70 | { 71 | super(message); 72 | this.code = code; 73 | this.detail = detail; 74 | } 75 | 76 | /** 77 | * Returns the code. 78 | */ 79 | public String getCode() 80 | { 81 | return code; 82 | } 83 | 84 | /** 85 | * Returns the detail. 86 | */ 87 | public Object getDetail() 88 | { 89 | return detail; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/com/caucho/burlap/client/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Portable client code for using Burlap services. Since this package is 4 | independent of all Resin code, its classes can be copied to a 5 | non-Resin client jar. 6 | 7 |

RPC Proxy Clients - BurlapProxyFactory

8 | 9 | Most application clients will use BurlapProxyFactory to 10 | create stub objects. The stub objects can be called with normal 11 | Java calls. Because the objects are remote, the client application needs 12 | to be able to deal with IOException caused by an unavailable server or 13 | a protocol error. 14 | 15 |
16 | import com.caucho.burlap.client.BurlapProxyFactory;
17 | 
18 | ...
19 | 
20 | URL url = new URL("http://localhost:8080/ejb/hello");
21 | HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
22 | 
23 | System.out.println("hello: " + hello.hello());
24 | 
25 | 26 |

Serialization

27 | 28 | Since the Burlap protocol serializes Java objects to XML, the 29 | BurlapSerializerOutput and BurlapSerializerInput 30 | can be used for serialization. 31 | 32 |

Serialization

33 |
34 | OutputStream os = new FileOutputStream("test.xml");
35 | BurlapOutput out = new BurlapSerializerOutput(os);
36 | 
37 | out.writeObject(obj);
38 | os.close();
39 | 
40 | 41 |

Deserialization

42 |
43 | InputStream is = new FileInputStream("test.xml");
44 | BurlapInput in = new BurlapSerializerInput(in);
45 | 
46 | Object obj = in.readObject();
47 | 
48 | is.close();
49 | 
50 | 51 |

MicroBurlapInput and MicroBurlapOutput

52 | 53 | These two classes only require classes from Java MicroEdition. So they 54 | can be extracted separately into a burlap-micro.jar. Because of this 55 | restriction and their small size, these two classes 56 | are ideal for limited size devices like mobile phones and PDAs. 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/com/caucho/burlap/io/AbstractBurlapInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.burlap.io; 50 | 51 | import com.caucho.hessian.io.AbstractHessianInput; 52 | 53 | /** 54 | * Abstract base class for Burlap requests. Burlap users should only 55 | * need to use the methods in this class. 56 | * 57 | *

Note, this class is just an extension of AbstractHessianInput. 58 | * 59 | *

60 |  * AbstractBurlapInput in = ...; // get input
61 |  * String value;
62 |  *
63 |  * in.startReply();         // read reply header
64 |  * value = in.readString(); // read string value
65 |  * in.completeReply();      // read reply footer
66 |  * 
67 | */ 68 | abstract public class AbstractBurlapInput extends AbstractHessianInput { 69 | } 70 | -------------------------------------------------------------------------------- /src/com/caucho/burlap/io/AbstractBurlapOutput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.burlap.io; 50 | 51 | import com.caucho.hessian.io.AbstractHessianOutput; 52 | import java.io.IOException; 53 | 54 | /** 55 | * Abstract output stream for Burlap requests. 56 | * 57 | *
58 |  * OutputStream os = ...; // from http connection
59 |  * AbstractOutput out = new BurlapSerializerOutput(os);
60 |  * String value;
61 |  *
62 |  * out.startCall("hello");  // start hello call
63 |  * out.writeString("arg1"); // write a string argument
64 |  * out.completeCall();      // complete the call
65 |  * 
66 | */ 67 | abstract public class AbstractBurlapOutput extends AbstractHessianOutput { 68 | @Override 69 | public void startCall(String method, int length) 70 | throws IOException 71 | { 72 | startCall(method); 73 | } 74 | 75 | abstract void startCall(String method) 76 | throws IOException; 77 | } 78 | -------------------------------------------------------------------------------- /src/com/caucho/burlap/io/AbstractBurlapResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.burlap.io; 50 | 51 | import java.io.IOException; 52 | 53 | /** 54 | * Looks up remote objects. The default just returns a BurlapRemote object. 55 | */ 56 | public class AbstractBurlapResolver implements BurlapRemoteResolver { 57 | /** 58 | * Looks up a proxy object. 59 | */ 60 | public Object lookup(String type, String url) 61 | throws IOException 62 | { 63 | return new BurlapRemote(type, url); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/com/caucho/burlap/io/BurlapProtocolException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.burlap.io; 50 | 51 | import com.caucho.hessian.io.HessianProtocolException; 52 | 53 | /** 54 | * Exception for faults when the fault doesn't return a java exception. 55 | * This exception is required for MicroBurlapInput. 56 | */ 57 | public class BurlapProtocolException extends HessianProtocolException { 58 | /** 59 | * Zero-arg constructor. 60 | */ 61 | public BurlapProtocolException() 62 | { 63 | } 64 | 65 | /** 66 | * Create the exception. 67 | */ 68 | public BurlapProtocolException(String message) 69 | { 70 | super(message); 71 | } 72 | 73 | /** 74 | * Create the exception. 75 | */ 76 | public BurlapProtocolException(String message, Throwable rootCause) 77 | { 78 | super(message, rootCause); 79 | } 80 | 81 | /** 82 | * Create the exception. 83 | */ 84 | public BurlapProtocolException(Throwable rootCause) 85 | { 86 | super(rootCause); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/com/caucho/burlap/io/BurlapRemoteObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.burlap.io; 50 | 51 | /** 52 | * Interface for any burlap remote object. 53 | */ 54 | public interface BurlapRemoteObject { 55 | public String getBurlapType(); 56 | public String getBurlapURL(); 57 | } 58 | -------------------------------------------------------------------------------- /src/com/caucho/burlap/io/BurlapRemoteResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.burlap.io; 50 | 51 | import com.caucho.hessian.io.HessianRemoteResolver; 52 | 53 | import java.io.IOException; 54 | /** 55 | * Looks up remote objects. The default just returns a BurlapRemote object. 56 | */ 57 | public interface BurlapRemoteResolver extends HessianRemoteResolver { 58 | /** 59 | * Looks up a proxy object. 60 | */ 61 | public Object lookup(String type, String url) 62 | throws IOException; 63 | } 64 | -------------------------------------------------------------------------------- /src/com/caucho/burlap/io/BurlapServiceException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.burlap.io; 50 | 51 | import com.caucho.hessian.io.HessianServiceException; 52 | 53 | /** 54 | * Exception for faults when the fault doesn't return a java exception. 55 | * This exception is required for MicroBurlapInput. 56 | */ 57 | public class BurlapServiceException extends HessianServiceException { 58 | /** 59 | * Zero-arg constructor. 60 | */ 61 | public BurlapServiceException() 62 | { 63 | } 64 | 65 | /** 66 | * Create the exception. 67 | */ 68 | public BurlapServiceException(String message, String code, Object detail) 69 | { 70 | super(message, code, detail); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/HessianException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian; 50 | 51 | /** 52 | * Base runtime exception for Hessian exceptions. 53 | */ 54 | public class HessianException extends RuntimeException { 55 | /** 56 | * Zero-arg constructor. 57 | */ 58 | public HessianException() 59 | { 60 | } 61 | 62 | /** 63 | * Create the exception. 64 | */ 65 | public HessianException(String message) 66 | { 67 | super(message); 68 | } 69 | 70 | /** 71 | * Create the exception. 72 | */ 73 | public HessianException(String message, Throwable rootCause) 74 | { 75 | super(message, rootCause); 76 | } 77 | 78 | /** 79 | * Create the exception. 80 | */ 81 | public HessianException(Throwable rootCause) 82 | { 83 | super(rootCause); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/HessianUnshared.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | 50 | package com.caucho.hessian; 51 | 52 | import java.lang.annotation.ElementType; 53 | import java.lang.annotation.Retention; 54 | import java.lang.annotation.RetentionPolicy; 55 | import java.lang.annotation.Target; 56 | 57 | /** 58 | * Marks the class and all children as unshared. 59 | * A reference item will be created, but will not be stored in a 60 | * mapped or checked for duplicated. 61 | * 62 | * Used for efficiency to avoid the cost of the map lookup. 63 | */ 64 | @Target({ElementType.TYPE }) 65 | @Retention(RetentionPolicy.RUNTIME) 66 | public @interface HessianUnshared 67 | { 68 | } 69 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/client/AbstractHessianConnectionFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.client; 50 | 51 | import java.net.URL; 52 | import java.io.IOException; 53 | 54 | /** 55 | * Internal factory for creating connections to the server. The default 56 | * factory is java.net 57 | */ 58 | abstract public class AbstractHessianConnectionFactory 59 | implements HessianConnectionFactory 60 | { 61 | private HessianProxyFactory _factory; 62 | 63 | /** 64 | * The HessianProxyFactory contains some common network 65 | * configuration like timeouts. 66 | */ 67 | public void setHessianProxyFactory(HessianProxyFactory factory) 68 | { 69 | _factory = factory; 70 | } 71 | 72 | /** 73 | * The HessianProxyFactory contains some common network 74 | * configuration like timeouts. 75 | */ 76 | public HessianProxyFactory getHessianProxyFactory() 77 | { 78 | return _factory; 79 | } 80 | 81 | /** 82 | * Opens a new or recycled connection to the HTTP server. 83 | */ 84 | abstract public HessianConnection open(URL url) 85 | throws IOException; 86 | } 87 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/client/HessianConnectionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.client; 50 | 51 | import com.caucho.hessian.HessianException; 52 | 53 | /** 54 | * Exception caused by failure of the client proxy to connect to the server. 55 | */ 56 | public class HessianConnectionException extends HessianException { 57 | /** 58 | * Zero-arg constructor. 59 | */ 60 | public HessianConnectionException() 61 | { 62 | } 63 | 64 | /** 65 | * Create the exception. 66 | */ 67 | public HessianConnectionException(String message) 68 | { 69 | super(message); 70 | } 71 | 72 | /** 73 | * Create the exception. 74 | */ 75 | public HessianConnectionException(String message, Throwable rootCause) 76 | { 77 | super(message, rootCause); 78 | } 79 | 80 | /** 81 | * Create the exception. 82 | */ 83 | public HessianConnectionException(Throwable rootCause) 84 | { 85 | super(rootCause); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/client/HessianConnectionFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.client; 50 | 51 | import java.net.URL; 52 | import java.io.IOException; 53 | 54 | /** 55 | * Internal factory for creating connections to the server. The default 56 | * factory is java.net 57 | */ 58 | public interface HessianConnectionFactory { 59 | /** 60 | * Sets the HessianProxyFactory 61 | */ 62 | public void setHessianProxyFactory(HessianProxyFactory factory); 63 | 64 | /** 65 | * Opens a new or recycled connection to the HTTP server. 66 | */ 67 | public HessianConnection open(URL url) 68 | throws IOException; 69 | } 70 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/client/HessianMetaInfoAPI.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The Apache Software License, Version 1.1 3 | * 4 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.client; 50 | 51 | /** 52 | * API retrieving hessian meta information. 53 | */ 54 | public interface HessianMetaInfoAPI { 55 | /** 56 | * Returns a service attribute. 57 | * 58 | * 64 | */ 65 | public Object _hessian_getAttribute(String name); 66 | } 67 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/client/HessianProxyResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.client; 50 | 51 | import com.caucho.hessian.io.HessianRemoteResolver; 52 | 53 | import java.io.IOException; 54 | 55 | /** 56 | * Looks up remote objects in the proxy. 57 | */ 58 | public class HessianProxyResolver implements HessianRemoteResolver { 59 | private HessianProxyFactory _factory; 60 | 61 | /** 62 | * Creates an uninitialized Hessian remote resolver. 63 | */ 64 | public HessianProxyResolver(HessianProxyFactory factory) 65 | { 66 | _factory = factory; 67 | } 68 | 69 | /** 70 | * Looks up a proxy object. 71 | */ 72 | public Object lookup(String type, String url) 73 | throws IOException 74 | { 75 | ClassLoader loader = Thread.currentThread().getContextClassLoader(); 76 | 77 | try { 78 | Class api = Class.forName(type, false, loader); 79 | 80 | return _factory.create(api, url); 81 | } catch (Exception e) { 82 | throw new IOException(String.valueOf(e)); 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/client/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Portable client code for using Hessian services. Since this package is 4 | independent of all Resin code, its classes can be copied to a 5 | non-Resin client jar. 6 | 7 |

RPC Proxy Clients - HessianProxyFactory

8 | 9 | Most application clients will use HessianProxyFactory to 10 | create stub objects. The stub objects can be called with normal 11 | Java calls. Because the objects are remote, the client application needs 12 | to be able to deal with IOException caused by an unavailable server or 13 | a protocol error. 14 | 15 |
16 | import com.caucho.hessian.client.HessianProxyFactory;
17 | 
18 | ...
19 | 
20 | URL url = new URL("http://localhost:8080/ejb/hello");
21 | HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
22 | 
23 | System.out.println("hello: " + hello.hello());
24 | 
25 | 26 |

Serialization

27 | 28 | Since the Hessian protocol serializes Java objects to XML, the 29 | HessianSerializerOutput and HessianSerializerInput 30 | can be used for serialization. 31 | 32 |

Serialization

33 |
34 | OutputStream os = new FileOutputStream("test.xml");
35 | HessianOutput out = new HessianSerializerOutput(os);
36 | 
37 | out.writeObject(obj);
38 | os.close();
39 | 
40 | 41 |

Deserialization

42 |
43 | InputStream is = new FileInputStream("test.xml");
44 | HessianInput in = new HessianSerializerInput(in);
45 | 
46 | Object obj = in.readObject();
47 | 
48 | is.close();
49 | 
50 | 51 |

MicroHessianInput and MicroHessianOutput

52 | 53 | These two classes only require classes from Java MicroEdition. So they 54 | can be extracted separately into a hessian-micro.jar. Because of this 55 | restriction and their small size, these two classes 56 | are ideal for limited size devices like mobile phones and PDAs. 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/AbstractHessianResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | 53 | /** 54 | * Looks up remote objects. The default just returns a HessianRemote object. 55 | */ 56 | public class AbstractHessianResolver implements HessianRemoteResolver { 57 | /** 58 | * Looks up a proxy object. 59 | */ 60 | public Object lookup(String type, String url) 61 | throws IOException 62 | { 63 | return new HessianRemote(type, url); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/AbstractListDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | 53 | /** 54 | * Deserializing a JDK 1.2 Collection. 55 | */ 56 | public class AbstractListDeserializer extends AbstractDeserializer { 57 | public Object readObject(AbstractHessianInput in) 58 | throws IOException 59 | { 60 | Object obj = in.readObject(); 61 | 62 | if (obj != null) 63 | throw error("expected list at " + obj.getClass().getName() + " (" + obj + ")"); 64 | else 65 | throw error("expected list at null"); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/AbstractMapDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | import java.util.HashMap; 53 | 54 | /** 55 | * Serializing an object for known object types. 56 | */ 57 | public class AbstractMapDeserializer extends AbstractDeserializer { 58 | 59 | public Class getType() 60 | { 61 | return HashMap.class; 62 | } 63 | 64 | public Object readObject(AbstractHessianInput in) 65 | throws IOException 66 | { 67 | Object obj = in.readObject(); 68 | 69 | if (obj != null) 70 | throw error("expected map/object at " + obj.getClass().getName() + " (" + obj + ")"); 71 | else 72 | throw error("expected map/object at null"); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/AbstractSerializerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | /** 52 | * Factory for returning serialization methods. 53 | */ 54 | abstract public class AbstractSerializerFactory { 55 | /** 56 | * Returns the serializer for a class. 57 | * 58 | * @param cl the class of the object that needs to be serialized. 59 | * 60 | * @return a serializer object for the serialization. 61 | */ 62 | abstract public Serializer getSerializer(Class cl) 63 | throws HessianProtocolException; 64 | 65 | /** 66 | * Returns the deserializer for a class. 67 | * 68 | * @param cl the class of the object that needs to be deserialized. 69 | * 70 | * @return a deserializer object for the serialization. 71 | */ 72 | abstract public Deserializer getDeserializer(Class cl) 73 | throws HessianProtocolException; 74 | } 75 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/AbstractSerializerWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | import java.util.logging.Logger; 53 | 54 | /** 55 | * Serializing an object. 56 | */ 57 | abstract public class AbstractSerializerWrapper implements Serializer { 58 | protected static final Logger log 59 | = Logger.getLogger(AbstractSerializerWrapper.class.getName()); 60 | 61 | abstract protected Serializer getDelegate(); 62 | 63 | @Override 64 | public void writeObject(Object obj, AbstractHessianOutput out) 65 | throws IOException 66 | { 67 | getDelegate().writeObject(obj, out); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/BeanSerializerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | /** 52 | * Factory for returning serialization methods. 53 | */ 54 | public class BeanSerializerFactory extends SerializerFactory { 55 | /** 56 | * Returns the default serializer for a class that isn't matched 57 | * directly. Application can override this method to produce 58 | * bean-style serialization instead of field serialization. 59 | * 60 | * @param cl the class of the object that needs to be serialized. 61 | * 62 | * @return a serializer object for the serialization. 63 | */ 64 | protected Serializer getDefaultSerializer(Class cl) 65 | { 66 | return new BeanSerializer(cl, getClassLoader()); 67 | } 68 | 69 | /** 70 | * Returns the default deserializer for a class that isn't matched 71 | * directly. Application can override this method to produce 72 | * bean-style serialization instead of field serialization. 73 | * 74 | * @param cl the class of the object that needs to be serialized. 75 | * 76 | * @return a serializer object for the serialization. 77 | */ 78 | protected Deserializer getDefaultDeserializer(Class cl) 79 | { 80 | return new BeanDeserializer(cl); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/BigDecimalDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.math.BigDecimal; 52 | 53 | /** 54 | * Deserializing a BigDecimal 55 | */ 56 | public class BigDecimalDeserializer extends AbstractStringValueDeserializer { 57 | @Override 58 | public Class getType() 59 | { 60 | return BigDecimal.class; 61 | } 62 | 63 | @Override 64 | protected Object create(String value) 65 | { 66 | return new BigDecimal(value); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/ByteArraySerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | 53 | /** 54 | * Serializing an object for known object types. 55 | */ 56 | public class ByteArraySerializer extends AbstractSerializer 57 | implements ObjectSerializer 58 | { 59 | public static final ByteArraySerializer SER = new ByteArraySerializer(); 60 | 61 | private ByteArraySerializer() 62 | { 63 | } 64 | 65 | @Override 66 | public Serializer getObjectSerializer() 67 | { 68 | return this; 69 | } 70 | 71 | @Override 72 | public void writeObject(Object obj, AbstractHessianOutput out) 73 | throws IOException 74 | { 75 | byte []data = (byte []) obj; 76 | 77 | if (data != null) 78 | out.writeBytes(data, 0, data.length); 79 | else 80 | out.writeNull(); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/ByteHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.net.URL; 52 | import java.io.Serializable; 53 | 54 | /** 55 | * Handle for Java Byte objects. 56 | */ 57 | public class ByteHandle implements Serializable { 58 | private byte _value; 59 | 60 | private ByteHandle() 61 | { 62 | } 63 | 64 | public ByteHandle(byte value) 65 | { 66 | _value = value; 67 | } 68 | 69 | public byte getValue() 70 | { 71 | return _value; 72 | } 73 | 74 | public Object readResolve() 75 | { 76 | return new Byte(_value); 77 | } 78 | 79 | public String toString() 80 | { 81 | return getClass().getSimpleName() + "[" + _value + "]"; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/CalendarHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.util.Calendar; 52 | import java.util.Date; 53 | import java.util.GregorianCalendar; 54 | 55 | /** 56 | * Handle for a calendar object. 57 | */ 58 | public class CalendarHandle implements java.io.Serializable, HessianHandle { 59 | private Class type; 60 | private Date date; 61 | 62 | public CalendarHandle() 63 | { 64 | } 65 | 66 | public CalendarHandle(Class type, long time) 67 | { 68 | if (! GregorianCalendar.class.equals(type)) 69 | this.type = type; 70 | 71 | this.date = new Date(time); 72 | } 73 | 74 | private Object readResolve() 75 | { 76 | try { 77 | Calendar cal; 78 | 79 | if (this.type != null) 80 | cal = (Calendar) this.type.newInstance(); 81 | else 82 | cal = new GregorianCalendar(); 83 | 84 | cal.setTimeInMillis(this.date.getTime()); 85 | 86 | return cal; 87 | } catch (RuntimeException e) { 88 | throw e; 89 | } catch (Exception e) { 90 | throw new RuntimeException(e); 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/CalendarSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | import java.util.Calendar; 53 | 54 | /** 55 | * Serializing a calendar. 56 | */ 57 | public class CalendarSerializer extends AbstractSerializer { 58 | public static final Serializer SER = new CalendarSerializer(); 59 | 60 | /** 61 | * java.util.Calendar serializes to com.caucho.hessian.io.CalendarHandle 62 | */ 63 | @Override 64 | public Object writeReplace(Object obj) 65 | { 66 | Calendar cal = (Calendar) obj; 67 | 68 | return new CalendarHandle(cal.getClass(), cal.getTimeInMillis()); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/ClassSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | 53 | /** 54 | * Serializing a remote object. 55 | */ 56 | public class ClassSerializer extends AbstractSerializer { 57 | public void writeObject(Object obj, AbstractHessianOutput out) 58 | throws IOException 59 | { 60 | Class cl = (Class) obj; 61 | 62 | if (cl == null) { 63 | out.writeNull(); 64 | } 65 | else if (out.addRef(obj)) { 66 | return; 67 | } 68 | else { 69 | int ref = out.writeObjectBegin("java.lang.Class"); 70 | 71 | if (ref < -1) { 72 | out.writeString("name"); 73 | out.writeString(cl.getName()); 74 | out.writeMapEnd(); 75 | } 76 | else { 77 | if (ref == -1) { 78 | out.writeInt(1); 79 | out.writeString("name"); 80 | out.writeObjectBegin("java.lang.Class"); 81 | } 82 | 83 | out.writeString(cl.getName()); 84 | } 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/EnumerationDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | import java.util.Vector; 53 | 54 | /** 55 | * Deserializing a JDK 1.2 Collection. 56 | */ 57 | public class EnumerationDeserializer extends AbstractListDeserializer { 58 | private static EnumerationDeserializer _deserializer; 59 | 60 | public static EnumerationDeserializer create() 61 | { 62 | if (_deserializer == null) 63 | _deserializer = new EnumerationDeserializer(); 64 | 65 | return _deserializer; 66 | } 67 | 68 | public Object readList(AbstractHessianInput in, int length) 69 | throws IOException 70 | { 71 | Vector list = new Vector(); 72 | 73 | in.addRef(list); 74 | 75 | while (! in.isEnd()) 76 | list.add(in.readObject()); 77 | 78 | in.readEnd(); 79 | 80 | return list.elements(); 81 | } 82 | } 83 | 84 | 85 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/EnumerationSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | import java.util.Enumeration; 53 | 54 | /** 55 | * Serializing a JDK 1.2 Enumeration. 56 | */ 57 | public class EnumerationSerializer extends AbstractSerializer { 58 | private static EnumerationSerializer _serializer; 59 | 60 | public static EnumerationSerializer create() 61 | { 62 | if (_serializer == null) 63 | _serializer = new EnumerationSerializer(); 64 | 65 | return _serializer; 66 | } 67 | 68 | public void writeObject(Object obj, AbstractHessianOutput out) 69 | throws IOException 70 | { 71 | Enumeration iter = (Enumeration) obj; 72 | 73 | boolean hasEnd = out.writeListBegin(-1, null); 74 | 75 | while (iter.hasMoreElements()) { 76 | Object value = iter.nextElement(); 77 | 78 | out.writeObject(value); 79 | } 80 | 81 | if (hasEnd) 82 | out.writeListEnd(); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/EnvelopeFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.util.logging.*; 52 | 53 | public class EnvelopeFactory 54 | { 55 | private static final Logger log 56 | = Logger.getLogger(EnvelopeFactory.class.getName()); 57 | } 58 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/FieldDeserializer2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | 53 | /** 54 | * Serializing an object for known object types. 55 | */ 56 | public interface FieldDeserializer2 { 57 | void deserialize(AbstractHessianInput in, Object obj) 58 | throws IOException; 59 | } 60 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/FileDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | import java.io.File; 53 | 54 | import com.caucho.hessian.HessianException; 55 | 56 | /** 57 | * Deserializing a File 58 | */ 59 | public class FileDeserializer extends AbstractStringValueDeserializer { 60 | @Override 61 | public Class getType() 62 | { 63 | return File.class; 64 | } 65 | 66 | @Override 67 | protected Object create(String value) 68 | { 69 | return new File(value); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/FloatHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.net.URL; 52 | import java.io.Serializable; 53 | 54 | /** 55 | * Handle for Java Float objects. 56 | */ 57 | public class FloatHandle implements Serializable { 58 | private float _value; 59 | 60 | private FloatHandle() 61 | { 62 | } 63 | 64 | public FloatHandle(float value) 65 | { 66 | _value = value; 67 | } 68 | 69 | public float getValue() 70 | { 71 | return _value; 72 | } 73 | 74 | public Object readResolve() 75 | { 76 | return new Float(_value); 77 | } 78 | 79 | public String toString() 80 | { 81 | return getClass().getSimpleName() + "[" + _value + "]"; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/HessianEnvelope.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.*; 52 | 53 | /** 54 | * Factory class for wrapping and unwrapping hessian streams. 55 | */ 56 | abstract public class HessianEnvelope { 57 | /** 58 | * Wrap the Hessian output stream in an envelope. 59 | */ 60 | abstract public Hessian2Output wrap(Hessian2Output out) 61 | throws IOException; 62 | 63 | /** 64 | * Unwrap the Hessian input stream with this envelope. It is an 65 | * error if the actual envelope does not match the expected envelope 66 | * class. 67 | */ 68 | abstract public Hessian2Input unwrap(Hessian2Input in) 69 | throws IOException; 70 | 71 | /** 72 | * Unwrap the envelope after having read the envelope code ('E') and 73 | * the envelope method. Called by the EnvelopeFactory for dynamic 74 | * reading of the envelopes. 75 | */ 76 | abstract public Hessian2Input unwrapHeaders(Hessian2Input in) 77 | throws IOException; 78 | } 79 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/HessianFieldException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | 53 | /** 54 | * Exception during field reading. 55 | */ 56 | public class HessianFieldException extends HessianProtocolException { 57 | /** 58 | * Zero-arg constructor. 59 | */ 60 | public HessianFieldException() 61 | { 62 | } 63 | 64 | /** 65 | * Create the exception. 66 | */ 67 | public HessianFieldException(String message) 68 | { 69 | super(message); 70 | } 71 | 72 | /** 73 | * Create the exception. 74 | */ 75 | public HessianFieldException(String message, Throwable cause) 76 | { 77 | super(message, cause); 78 | } 79 | 80 | /** 81 | * Create the exception. 82 | */ 83 | public HessianFieldException(Throwable cause) 84 | { 85 | super(cause); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/HessianHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | /** 52 | * Marks a type as a handle 53 | */ 54 | public interface HessianHandle { 55 | } 56 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/HessianMethodSerializationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import com.caucho.hessian.HessianException; 52 | 53 | /** 54 | * Exception for faults when the fault doesn't return a java exception. 55 | * This exception is required for MicroHessianInput. 56 | */ 57 | public class HessianMethodSerializationException extends HessianException { 58 | /** 59 | * Zero-arg constructor. 60 | */ 61 | public HessianMethodSerializationException() 62 | { 63 | } 64 | 65 | /** 66 | * Create the exception. 67 | */ 68 | public HessianMethodSerializationException(String message) 69 | { 70 | super(message); 71 | } 72 | 73 | /** 74 | * Create the exception. 75 | */ 76 | public HessianMethodSerializationException(String message, Throwable cause) 77 | { 78 | super(message, cause); 79 | } 80 | 81 | /** 82 | * Create the exception. 83 | */ 84 | public HessianMethodSerializationException(Throwable cause) 85 | { 86 | super(cause); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/HessianRemoteObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | /** 52 | * Interface for any hessian remote object. 53 | */ 54 | public interface HessianRemoteObject { 55 | public String getHessianType(); 56 | public String getHessianURL(); 57 | } 58 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/HessianRemoteResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | 53 | /** 54 | * Looks up remote objects. The default just returns a HessianRemote object. 55 | */ 56 | public interface HessianRemoteResolver { 57 | /** 58 | * Looks up a proxy object. 59 | */ 60 | public Object lookup(String type, String url) 61 | throws IOException; 62 | } 63 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/HessianServiceException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | /** 52 | * Exception for faults when the fault doesn't return a java exception. 53 | * This exception is required for MicroHessianInput. 54 | */ 55 | public class HessianServiceException extends Exception { 56 | private String code; 57 | private Object detail; 58 | 59 | /** 60 | * Zero-arg constructor. 61 | */ 62 | public HessianServiceException() 63 | { 64 | } 65 | 66 | /** 67 | * Create the exception. 68 | */ 69 | public HessianServiceException(String message, String code, Object detail) 70 | { 71 | super(message); 72 | this.code = code; 73 | this.detail = detail; 74 | } 75 | 76 | /** 77 | * Returns the code. 78 | */ 79 | public String getCode() 80 | { 81 | return code; 82 | } 83 | 84 | /** 85 | * Returns the detail. 86 | */ 87 | public Object getDetail() 88 | { 89 | return detail; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/IOExceptionWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | 53 | /** 54 | * Exception wrapper for IO. 55 | */ 56 | public class IOExceptionWrapper extends IOException { 57 | private Throwable _cause; 58 | 59 | public IOExceptionWrapper(Throwable cause) 60 | { 61 | super(cause.toString()); 62 | 63 | _cause = cause; 64 | } 65 | 66 | public IOExceptionWrapper(String msg, Throwable cause) 67 | { 68 | super(msg); 69 | 70 | _cause = cause; 71 | } 72 | 73 | public Throwable getCause() 74 | { 75 | return _cause; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/InetAddressHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.net.InetAddress; 52 | import java.util.logging.Level; 53 | import java.util.logging.Logger; 54 | 55 | /** 56 | * Handle for an InetAddress object. 57 | */ 58 | public class InetAddressHandle implements java.io.Serializable, HessianHandle 59 | { 60 | private static final Logger log = Logger.getLogger(InetAddressHandle.class.getName()); 61 | 62 | private String hostName; 63 | private byte []address; 64 | 65 | public InetAddressHandle(String hostName, byte []address) 66 | { 67 | this.hostName = hostName; 68 | this.address = address; 69 | } 70 | 71 | private Object readResolve() 72 | { 73 | try { 74 | return InetAddress.getByAddress(this.hostName, this.address); 75 | } catch (Exception e) { 76 | log.log(Level.FINE, e.toString(), e); 77 | 78 | return null; 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/InetAddressSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | import java.net.InetAddress; 53 | 54 | /** 55 | * Serializing a locale. 56 | */ 57 | public class InetAddressSerializer extends AbstractSerializer { 58 | private static InetAddressSerializer SERIALIZER = new InetAddressSerializer(); 59 | 60 | public static InetAddressSerializer create() 61 | { 62 | return SERIALIZER; 63 | } 64 | 65 | @Override 66 | public void writeObject(Object obj, AbstractHessianOutput out) 67 | throws IOException 68 | { 69 | if (obj == null) 70 | out.writeNull(); 71 | else { 72 | InetAddress addr = (InetAddress) obj; 73 | out.writeObject(new InetAddressHandle(addr.getHostName(), 74 | addr.getAddress())); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/InputStreamDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | import java.io.InputStream; 53 | 54 | /** 55 | * Serializing a stream object. 56 | */ 57 | public class InputStreamDeserializer extends AbstractDeserializer { 58 | public static final InputStreamDeserializer DESER 59 | = new InputStreamDeserializer(); 60 | 61 | public InputStreamDeserializer() 62 | { 63 | } 64 | 65 | public Object readObject(AbstractHessianInput in) 66 | throws IOException 67 | { 68 | return in.readInputStream(); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/InputStreamSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | import java.io.InputStream; 53 | 54 | /** 55 | * Serializing a stream object. 56 | */ 57 | public class InputStreamSerializer extends AbstractSerializer { 58 | public InputStreamSerializer() 59 | { 60 | } 61 | 62 | public void writeObject(Object obj, AbstractHessianOutput out) 63 | throws IOException 64 | { 65 | InputStream is = (InputStream) obj; 66 | 67 | if (is == null) 68 | out.writeNull(); 69 | else { 70 | out.writeByteStream(is); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/IteratorDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | import java.util.ArrayList; 53 | 54 | /** 55 | * Deserializing a JDK 1.2 Collection. 56 | */ 57 | public class IteratorDeserializer extends AbstractListDeserializer { 58 | private static IteratorDeserializer _deserializer; 59 | 60 | public static IteratorDeserializer create() 61 | { 62 | if (_deserializer == null) 63 | _deserializer = new IteratorDeserializer(); 64 | 65 | return _deserializer; 66 | } 67 | 68 | @Override 69 | public Object readList(AbstractHessianInput in, int length) 70 | throws IOException 71 | { 72 | ArrayList list = new ArrayList(); 73 | 74 | in.addRef(list); 75 | 76 | while (! in.isEnd()) 77 | list.add(in.readObject()); 78 | 79 | in.readEnd(); 80 | 81 | return list.iterator(); 82 | } 83 | } 84 | 85 | 86 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/IteratorSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | import java.util.Iterator; 53 | 54 | /** 55 | * Serializing a JDK 1.2 Iterator. 56 | */ 57 | public class IteratorSerializer extends AbstractSerializer { 58 | private static IteratorSerializer _serializer; 59 | 60 | public static IteratorSerializer create() 61 | { 62 | if (_serializer == null) 63 | _serializer = new IteratorSerializer(); 64 | 65 | return _serializer; 66 | } 67 | 68 | public void writeObject(Object obj, AbstractHessianOutput out) 69 | throws IOException 70 | { 71 | Iterator iter = (Iterator) obj; 72 | 73 | boolean hasEnd = out.writeListBegin(-1, null); 74 | 75 | while (iter.hasNext()) { 76 | Object value = iter.next(); 77 | 78 | out.writeObject(value); 79 | } 80 | 81 | if (hasEnd) 82 | out.writeListEnd(); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/JavaUnsharedSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | import java.lang.ref.SoftReference; 53 | import java.lang.reflect.Field; 54 | import java.lang.reflect.Method; 55 | import java.lang.reflect.Modifier; 56 | import java.util.ArrayList; 57 | import java.util.WeakHashMap; 58 | import java.util.logging.Level; 59 | import java.util.logging.Logger; 60 | 61 | /** 62 | * Serializing an object for known object types. 63 | */ 64 | public class JavaUnsharedSerializer extends JavaSerializer 65 | { 66 | private static final Logger log 67 | = Logger.getLogger(JavaUnsharedSerializer.class.getName()); 68 | 69 | public JavaUnsharedSerializer(Class cl) 70 | { 71 | super(cl); 72 | } 73 | 74 | @Override 75 | public void writeObject(Object obj, AbstractHessianOutput out) 76 | throws IOException 77 | { 78 | boolean oldUnshared = out.setUnshared(true); 79 | 80 | try { 81 | super.writeObject(obj, out); 82 | } finally { 83 | out.setUnshared(oldUnshared); 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/LocaleSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | import java.util.Locale; 53 | 54 | /** 55 | * Serializing a locale. 56 | */ 57 | public class LocaleSerializer extends AbstractSerializer { 58 | private static LocaleSerializer SERIALIZER = new LocaleSerializer(); 59 | 60 | public static LocaleSerializer create() 61 | { 62 | return SERIALIZER; 63 | } 64 | 65 | public void writeObject(Object obj, AbstractHessianOutput out) 66 | throws IOException 67 | { 68 | if (obj == null) 69 | out.writeNull(); 70 | else { 71 | Locale locale = (Locale) obj; 72 | 73 | out.writeObject(new LocaleHandle(locale.toString())); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/ObjectHandleSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | 53 | /** 54 | * Serializing a remote object. 55 | */ 56 | public class ObjectHandleSerializer extends AbstractSerializer { 57 | public static final Serializer SER = new ObjectHandleSerializer(); 58 | 59 | public void writeObject(Object obj, AbstractHessianOutput out) 60 | throws IOException 61 | { 62 | if (obj == null) 63 | out.writeNull(); 64 | else { 65 | if (out.addRef(obj)) 66 | return; 67 | 68 | int ref = out.writeObjectBegin("object"); 69 | 70 | if (ref < -1) { 71 | out.writeMapEnd(); 72 | } 73 | else { 74 | if (ref == -1) { 75 | out.writeInt(0); 76 | out.writeObjectBegin("object"); 77 | } 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/ObjectNameDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import javax.management.ObjectName; 52 | 53 | import com.caucho.hessian.HessianException; 54 | 55 | /** 56 | * Deserializing an ObjectName 57 | */ 58 | public class ObjectNameDeserializer extends AbstractStringValueDeserializer { 59 | @Override 60 | public Class getType() 61 | { 62 | return ObjectName.class; 63 | } 64 | 65 | @Override 66 | protected Object create(String value) 67 | { 68 | try { 69 | return new ObjectName(value); 70 | } catch (RuntimeException e) { 71 | throw e; 72 | } catch (Exception e) { 73 | throw new HessianException(e); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/ObjectSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | 53 | /** 54 | * Serializing an object. 55 | */ 56 | public interface ObjectSerializer { 57 | public Serializer getObjectSerializer(); 58 | } 59 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/RemoteDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.util.logging.Logger; 52 | 53 | /** 54 | * Serializing an object for known object types. 55 | */ 56 | public class RemoteDeserializer extends JavaDeserializer { 57 | private static final Logger log 58 | = Logger.getLogger(RemoteDeserializer.class.getName()); 59 | 60 | public static final Deserializer DESER = new RemoteDeserializer(); 61 | 62 | public RemoteDeserializer() 63 | { 64 | super(HessianRemote.class, FieldDeserializer2Factory.create()); 65 | } 66 | 67 | @Override 68 | public boolean isReadResolve() 69 | { 70 | return true; 71 | } 72 | 73 | @Override 74 | protected Object resolve(AbstractHessianInput in, Object obj) 75 | throws Exception 76 | { 77 | HessianRemote remote = (HessianRemote) obj; 78 | HessianRemoteResolver resolver = in.getRemoteResolver(); 79 | 80 | if (resolver != null) { 81 | Object proxy = resolver.lookup(remote.getType(), remote.getURL()); 82 | 83 | return proxy; 84 | } 85 | else 86 | return remote; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/RemoteSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import com.caucho.burlap.io.BurlapRemoteObject; 52 | 53 | import java.io.IOException; 54 | 55 | /** 56 | * Serializing a remote object. 57 | */ 58 | public class RemoteSerializer extends AbstractSerializer { 59 | public void writeObject(Object obj, AbstractHessianOutput out) 60 | throws IOException 61 | { 62 | HessianRemoteObject remoteObject = (HessianRemoteObject) obj; 63 | 64 | out.writeObject(new HessianRemote(remoteObject.getHessianType(), 65 | remoteObject.getHessianURL())); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/Serializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | 53 | /** 54 | * Serializing an object. 55 | */ 56 | public interface Serializer { 57 | public void writeObject(Object obj, AbstractHessianOutput out) 58 | throws IOException; 59 | } 60 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/ShortHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.net.URL; 52 | import java.io.Serializable; 53 | 54 | /** 55 | * Handle for Java Short objects. 56 | */ 57 | public class ShortHandle implements Serializable { 58 | private short _value; 59 | 60 | private ShortHandle() 61 | { 62 | } 63 | 64 | public ShortHandle(short value) 65 | { 66 | _value = value; 67 | } 68 | 69 | public short getValue() 70 | { 71 | return _value; 72 | } 73 | 74 | public Object readResolve() 75 | { 76 | return new Short(_value); 77 | } 78 | 79 | public String toString() 80 | { 81 | return getClass().getSimpleName() + "[" + _value + "]"; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/SqlDateSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | import java.util.Date; 53 | 54 | /** 55 | * Serializing a sql date object. 56 | */ 57 | public class SqlDateSerializer extends AbstractSerializer 58 | { 59 | public void writeObject(Object obj, AbstractHessianOutput out) 60 | throws IOException 61 | { 62 | if (obj == null) 63 | out.writeNull(); 64 | else { 65 | Class cl = obj.getClass(); 66 | 67 | if (out.addRef(obj)) 68 | return; 69 | 70 | int ref = out.writeObjectBegin(cl.getName()); 71 | 72 | if (ref < -1) { 73 | out.writeString("value"); 74 | out.writeUTCDate(((Date) obj).getTime()); 75 | out.writeMapEnd(); 76 | } 77 | else { 78 | if (ref == -1) { 79 | out.writeInt(1); 80 | out.writeString("value"); 81 | out.writeObjectBegin(cl.getName()); 82 | } 83 | 84 | out.writeUTCDate(((Date) obj).getTime()); 85 | } 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/StackTraceElementDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.lang.reflect.Constructor; 52 | 53 | /** 54 | * Deserializing a JDK 1.4 StackTraceElement 55 | */ 56 | public class StackTraceElementDeserializer extends JavaDeserializer { 57 | public StackTraceElementDeserializer(FieldDeserializer2Factory fieldFactory) 58 | { 59 | super(StackTraceElement.class, fieldFactory); 60 | } 61 | 62 | @Override 63 | protected Constructor getConstructor(Class cl) 64 | { 65 | return null; 66 | } 67 | 68 | @Override 69 | protected Object instantiate() 70 | throws Exception 71 | { 72 | return new StackTraceElement("", "", "", 0); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/StringValueSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | 53 | /** 54 | * Serializing a remote object. 55 | */ 56 | public class StringValueSerializer extends AbstractSerializer { 57 | public static final Serializer SER = new StringValueSerializer(); 58 | 59 | public void writeObject(Object obj, AbstractHessianOutput out) 60 | throws IOException 61 | { 62 | if (obj == null) 63 | out.writeNull(); 64 | else { 65 | if (out.addRef(obj)) 66 | return; 67 | 68 | Class cl = obj.getClass(); 69 | 70 | int ref = out.writeObjectBegin(cl.getName()); 71 | 72 | if (ref < -1) { 73 | out.writeString("value"); 74 | out.writeString(obj.toString()); 75 | out.writeMapEnd(); 76 | } 77 | else { 78 | if (ref == -1) { 79 | out.writeInt(1); 80 | out.writeString("value"); 81 | out.writeObjectBegin(cl.getName()); 82 | } 83 | 84 | out.writeString(obj.toString()); 85 | } 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/ThrowableSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | 53 | /** 54 | * Serializing an object for known object types. 55 | */ 56 | public class ThrowableSerializer extends AbstractSerializerWrapper { 57 | private final Serializer _ser; 58 | 59 | public ThrowableSerializer(Serializer ser) 60 | { 61 | _ser = ser; 62 | } 63 | 64 | @Override 65 | protected Serializer getDelegate() 66 | { 67 | return _ser; 68 | } 69 | 70 | @Override 71 | public void writeObject(Object obj, AbstractHessianOutput out) 72 | throws IOException 73 | { 74 | Throwable e = (Throwable) obj; 75 | 76 | e.getStackTrace(); 77 | 78 | _ser.writeObject(obj, out); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/UnsafeUnsharedSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Burlap", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | import java.lang.ref.SoftReference; 53 | import java.lang.reflect.Field; 54 | import java.lang.reflect.Method; 55 | import java.lang.reflect.Modifier; 56 | import java.util.ArrayList; 57 | import java.util.WeakHashMap; 58 | import java.util.logging.Level; 59 | import java.util.logging.Logger; 60 | 61 | /** 62 | * Serializing an object for known object types. 63 | */ 64 | public class UnsafeUnsharedSerializer extends UnsafeSerializer 65 | { 66 | private static final Logger log 67 | = Logger.getLogger(UnsafeUnsharedSerializer.class.getName()); 68 | 69 | public UnsafeUnsharedSerializer(Class cl) 70 | { 71 | super(cl); 72 | } 73 | 74 | @Override 75 | public void writeObject(Object obj, AbstractHessianOutput out) 76 | throws IOException 77 | { 78 | boolean oldUnshared = out.setUnshared(true); 79 | 80 | try { 81 | super.writeObject(obj, out); 82 | } finally { 83 | out.setUnshared(oldUnshared); 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/io/ValueDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Caucho Technology, Inc. All rights reserved. 3 | * 4 | * The Apache Software License, Version 1.1 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * 3. The end-user documentation included with the redistribution, if 19 | * any, must include the following acknowlegement: 20 | * "This product includes software developed by the 21 | * Caucho Technology (http://www.caucho.com/)." 22 | * Alternately, this acknowlegement may appear in the software itself, 23 | * if and wherever such third-party acknowlegements normally appear. 24 | * 25 | * 4. The names "Hessian", "Resin", and "Caucho" must not be used to 26 | * endorse or promote products derived from this software without prior 27 | * written permission. For written permission, please contact 28 | * info@caucho.com. 29 | * 30 | * 5. Products derived from this software may not be called "Resin" 31 | * nor may "Resin" appear in their names without prior written 32 | * permission of Caucho Technology. 33 | * 34 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 35 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 36 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS 38 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 39 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 40 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 42 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 43 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 44 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 45 | * 46 | * @author Scott Ferguson 47 | */ 48 | 49 | package com.caucho.hessian.io; 50 | 51 | import java.io.IOException; 52 | 53 | /** 54 | * Deserializing a string valued object 55 | */ 56 | abstract public class ValueDeserializer extends AbstractDeserializer { 57 | public Object readMap(AbstractHessianInput in) 58 | throws IOException 59 | { 60 | String initValue = null; 61 | 62 | while (! in.isEnd()) { 63 | String key = in.readString(); 64 | 65 | if (key.equals("value")) 66 | initValue = in.readString(); 67 | else 68 | in.readObject(); 69 | } 70 | 71 | in.readMapEnd(); 72 | 73 | return create(initValue); 74 | } 75 | 76 | public Object readObject(AbstractHessianInput in, String []fieldNames) 77 | throws IOException 78 | { 79 | String initValue = null; 80 | 81 | for (int i = 0; i < fieldNames.length; i++) { 82 | if ("value".equals(fieldNames[i])) 83 | initValue = in.readString(); 84 | else 85 | in.readObject(); 86 | } 87 | 88 | return create(initValue); 89 | } 90 | 91 | abstract Object create(String value) 92 | throws IOException; 93 | } 94 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/test/A0.java: -------------------------------------------------------------------------------- 1 | package com.caucho.hessian.test; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * Empty object for short-encoding testing 7 | */ 8 | public class A0 implements java.io.Serializable { 9 | public boolean equals(Object v) 10 | { 11 | return v != null && getClass().equals(v.getClass()); 12 | } 13 | 14 | public String toString() 15 | { 16 | return getClass().getName() + "[]"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/test/A1.java: -------------------------------------------------------------------------------- 1 | package com.caucho.hessian.test; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * Empty object for short-encoding testing 7 | */ 8 | public class A1 implements java.io.Serializable { 9 | public boolean equals(Object v) 10 | { 11 | return v != null && getClass().equals(v.getClass()); 12 | } 13 | 14 | public String toString() 15 | { 16 | return getClass().getName() + "[]"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/test/A10.java: -------------------------------------------------------------------------------- 1 | package com.caucho.hessian.test; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * Empty object for short-encoding testing 7 | */ 8 | public class A10 implements java.io.Serializable { 9 | public boolean equals(Object v) 10 | { 11 | return v != null && getClass().equals(v.getClass()); 12 | } 13 | 14 | public String toString() 15 | { 16 | return getClass().getName() + "[]"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/test/A11.java: -------------------------------------------------------------------------------- 1 | package com.caucho.hessian.test; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * Empty object for short-encoding testing 7 | */ 8 | public class A11 implements java.io.Serializable { 9 | public boolean equals(Object v) 10 | { 11 | return v != null && getClass().equals(v.getClass()); 12 | } 13 | 14 | public String toString() 15 | { 16 | return getClass().getName() + "[]"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/test/A12.java: -------------------------------------------------------------------------------- 1 | package com.caucho.hessian.test; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * Empty object for short-encoding testing 7 | */ 8 | public class A12 implements java.io.Serializable { 9 | public boolean equals(Object v) 10 | { 11 | return v != null && getClass().equals(v.getClass()); 12 | } 13 | 14 | public String toString() 15 | { 16 | return getClass().getName() + "[]"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/test/A13.java: -------------------------------------------------------------------------------- 1 | package com.caucho.hessian.test; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * Empty object for short-encoding testing 7 | */ 8 | public class A13 implements java.io.Serializable { 9 | public boolean equals(Object v) 10 | { 11 | return v != null && getClass().equals(v.getClass()); 12 | } 13 | 14 | public String toString() 15 | { 16 | return getClass().getName() + "[]"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/test/A14.java: -------------------------------------------------------------------------------- 1 | package com.caucho.hessian.test; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * Empty object for short-encoding testing 7 | */ 8 | public class A14 implements java.io.Serializable { 9 | public boolean equals(Object v) 10 | { 11 | return v != null && getClass().equals(v.getClass()); 12 | } 13 | 14 | public String toString() 15 | { 16 | return getClass().getName() + "[]"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/test/A15.java: -------------------------------------------------------------------------------- 1 | package com.caucho.hessian.test; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * Empty object for short-encoding testing 7 | */ 8 | public class A15 implements java.io.Serializable { 9 | public boolean equals(Object v) 10 | { 11 | return v != null && getClass().equals(v.getClass()); 12 | } 13 | 14 | public String toString() 15 | { 16 | return getClass().getName() + "[]"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/test/A16.java: -------------------------------------------------------------------------------- 1 | package com.caucho.hessian.test; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * Empty object for short-encoding testing 7 | */ 8 | public class A16 implements java.io.Serializable { 9 | public boolean equals(Object v) 10 | { 11 | return v != null && getClass().equals(v.getClass()); 12 | } 13 | 14 | public String toString() 15 | { 16 | return getClass().getName() + "[]"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/test/A2.java: -------------------------------------------------------------------------------- 1 | package com.caucho.hessian.test; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * Empty object for short-encoding testing 7 | */ 8 | public class A2 implements java.io.Serializable { 9 | public boolean equals(Object v) 10 | { 11 | return v != null && getClass().equals(v.getClass()); 12 | } 13 | 14 | public String toString() 15 | { 16 | return getClass().getName() + "[]"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/test/A3.java: -------------------------------------------------------------------------------- 1 | package com.caucho.hessian.test; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * Empty object for short-encoding testing 7 | */ 8 | public class A3 implements java.io.Serializable { 9 | public boolean equals(Object v) 10 | { 11 | return v != null && getClass().equals(v.getClass()); 12 | } 13 | 14 | public String toString() 15 | { 16 | return getClass().getName() + "[]"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/test/A4.java: -------------------------------------------------------------------------------- 1 | package com.caucho.hessian.test; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * Empty object for short-encoding testing 7 | */ 8 | public class A4 implements java.io.Serializable { 9 | public boolean equals(Object v) 10 | { 11 | return v != null && getClass().equals(v.getClass()); 12 | } 13 | 14 | public String toString() 15 | { 16 | return getClass().getName() + "[]"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/test/A5.java: -------------------------------------------------------------------------------- 1 | package com.caucho.hessian.test; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * Empty object for short-encoding testing 7 | */ 8 | public class A5 implements java.io.Serializable { 9 | public boolean equals(Object v) 10 | { 11 | return v != null && getClass().equals(v.getClass()); 12 | } 13 | 14 | public String toString() 15 | { 16 | return getClass().getName() + "[]"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/test/A6.java: -------------------------------------------------------------------------------- 1 | package com.caucho.hessian.test; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * Empty object for short-encoding testing 7 | */ 8 | public class A6 implements java.io.Serializable { 9 | public boolean equals(Object v) 10 | { 11 | return v != null && getClass().equals(v.getClass()); 12 | } 13 | 14 | public String toString() 15 | { 16 | return getClass().getName() + "[]"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/test/A7.java: -------------------------------------------------------------------------------- 1 | package com.caucho.hessian.test; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * Empty object for short-encoding testing 7 | */ 8 | public class A7 implements java.io.Serializable { 9 | public boolean equals(Object v) 10 | { 11 | return v != null && getClass().equals(v.getClass()); 12 | } 13 | 14 | public String toString() 15 | { 16 | return getClass().getName() + "[]"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/test/A8.java: -------------------------------------------------------------------------------- 1 | package com.caucho.hessian.test; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * Empty object for short-encoding testing 7 | */ 8 | public class A8 implements java.io.Serializable { 9 | public boolean equals(Object v) 10 | { 11 | return v != null && getClass().equals(v.getClass()); 12 | } 13 | 14 | public String toString() 15 | { 16 | return getClass().getName() + "[]"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/test/A9.java: -------------------------------------------------------------------------------- 1 | package com.caucho.hessian.test; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * Empty object for short-encoding testing 7 | */ 8 | public class A9 implements java.io.Serializable { 9 | public boolean equals(Object v) 10 | { 11 | return v != null && getClass().equals(v.getClass()); 12 | } 13 | 14 | public String toString() 15 | { 16 | return getClass().getName() + "[]"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/caucho/hessian/test/Test.java: -------------------------------------------------------------------------------- 1 | package com.caucho.hessian.test; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * The Test service is a quick sanity check service. Developers of a 7 | * new Hessian implementation can use this service as an initial test. 8 | */ 9 | public interface Test { 10 | /** 11 | * Does nothing. 12 | */ 13 | public void nullCall(); 14 | 15 | /** 16 | * Hello, World. 17 | */ 18 | public String hello(); 19 | 20 | /** 21 | * Subtraction 22 | */ 23 | public int subtract(int a, int b); 24 | 25 | /** 26 | * Echos the object to the server. 27 | *
28 |    */
29 |   public Object echo(Object value);
30 |   
31 |   /**
32 |    * Throws an application fault.
33 |    */
34 |   public void fault()
35 |     throws IOException;
36 | }
37 | 


--------------------------------------------------------------------------------
/src/com/caucho/hessian/test/TestCons.java:
--------------------------------------------------------------------------------
 1 | package com.caucho.hessian.test;
 2 | 
 3 | import java.io.IOException;
 4 | import java.util.*;
 5 | 
 6 | /**
 7 |  * Cons-cell for testing
 8 |  */
 9 | public class TestCons implements java.io.Serializable {
10 |   private Object _first;
11 |   private Object _rest;
12 | 
13 |   public TestCons()
14 |   {
15 |   }
16 | 
17 |   public TestCons(Object first)
18 |   {
19 |     _first = first;
20 |   }
21 | 
22 |   public TestCons(Object first, Object rest)
23 |   {
24 |     _first = first;
25 |     _rest = rest;
26 |   }
27 | 
28 |   public Object getFirst()
29 |   {
30 |     return _first;
31 |   }
32 | 
33 |   public void setFirst(Object first)
34 |   {
35 |     _first = first;
36 |   }
37 | 
38 |   public Object getRest()
39 |   {
40 |     return _rest;
41 |   }
42 | 
43 |   public void setRest(Object rest)
44 |   {
45 |     _rest = rest;
46 |   }
47 | 
48 |   public boolean equals(Object o)
49 |   {
50 |     return toString().equals(o.toString());
51 |   }
52 |   
53 |   public String toString()
54 |   {
55 |     return toString(new HashMap());
56 |   }
57 |   
58 |   public String toString(HashMap map)
59 |   {
60 |     Object ref = map.get(this);
61 | 
62 |     if (ref != null)
63 |       return "#" + ref;
64 | 
65 |     map.put(this, map.size());
66 | 
67 |     StringBuilder sb = new StringBuilder();
68 |     sb.append(getClass().getSimpleName()).append("[");
69 | 
70 |     if (_first instanceof TestCons)
71 |       sb.append(((TestCons) _first).toString(map));
72 |     else
73 |       sb.append(_first);
74 | 
75 |     sb.append(",");
76 | 
77 |     if (_rest instanceof TestCons)
78 |       sb.append(((TestCons) _rest).toString(map));
79 |     else
80 |       sb.append(_rest);
81 | 
82 |     sb.append("[");
83 |     
84 |     return sb.toString();
85 |   }
86 | }
87 | 


--------------------------------------------------------------------------------
/src/com/caucho/hessian/test/TestHessianServlet.java:
--------------------------------------------------------------------------------
 1 | package com.caucho.hessian.test;
 2 | 
 3 | import com.caucho.hessian.io.*;
 4 | import com.caucho.hessian.server.HessianServlet;
 5 | import java.io.*;
 6 | import java.util.*;
 7 | 
 8 | /**
 9 |  * The test service is a Hessian 2.0 protocol test for developers of
10 |  * Hessian 2.0 clients.  For a new client the recommended order is:
11 |  *
12 |  * 
16 |  */
17 | public class TestHessianServlet
18 |   extends HessianServlet
19 |   implements Test
20 | {
21 |   private ThreadLocal _threadWriter
22 |     = new ThreadLocal();
23 |   
24 |   /**
25 |    * Does nothing.
26 |    */
27 |   public void nullCall()
28 |   {
29 |   }
30 |   
31 |   /**
32 |    * Hello, World.
33 |    */
34 |   public String hello()
35 |   {
36 |     return "Hello, World";
37 |   }
38 |   
39 |   /**
40 |    * Subtraction
41 |    */
42 |   public int subtract(int a, int b)
43 |   {
44 |     return a - b;
45 |   }
46 |   
47 |   /**
48 |    * Echos the object to the server.
49 |    * 
50 |    */
51 |   public Object echo(Object value)
52 |   {
53 |     return value;
54 |   }
55 |   
56 |   /**
57 |    * Throws an application fault.
58 |    */
59 |   public void fault()
60 |     throws IOException
61 |   {
62 |     throw new NullPointerException("sample exception");
63 |   }
64 | }
65 | 


--------------------------------------------------------------------------------
/src/com/caucho/hessian/test/TestObject.java:
--------------------------------------------------------------------------------
 1 | package com.caucho.hessian.test;
 2 | 
 3 | import java.io.IOException;
 4 | 
 5 | /**
 6 |  * Empty object for short-encoding testing
 7 |  */
 8 | public class TestObject implements java.io.Serializable {
 9 |   private Object _value;
10 | 
11 |   public TestObject()
12 |   {
13 |   }
14 | 
15 |   public TestObject(Object value)
16 |   {
17 |     _value = value;
18 |   }
19 | 
20 |   public Object getValue()
21 |   {
22 |     return _value;
23 |   }
24 | 
25 |   public int hashCode()
26 |   {
27 |     if (_value != null)
28 |       return _value.hashCode();
29 |     else
30 |       return 0;
31 |   }
32 | 
33 |   public boolean equals(Object o)
34 |   {
35 |     if (! (o instanceof TestObject))
36 |       return false;
37 | 
38 |     TestObject obj = (TestObject) o;
39 | 
40 |     if (_value != null)
41 |       return _value.equals(obj._value);
42 |     else
43 |       return _value == obj._value;
44 |   }
45 |   
46 |   public String toString()
47 |   {
48 |     return getClass().getName() + "[" + _value + "]";
49 |   }
50 | }
51 | 


--------------------------------------------------------------------------------
/src/com/caucho/services/server/Service.java:
--------------------------------------------------------------------------------
 1 | /*
 2 |  * Copyright (c) 2001-2004 Caucho Technology, Inc.  All rights reserved.
 3 |  *
 4 |  * The Apache Software License, Version 1.1
 5 |  *
 6 |  * Redistribution and use in source and binary forms, with or without
 7 |  * modification, are permitted provided that the following conditions
 8 |  * are met:
 9 |  *
10 |  * 1. Redistributions of source code must retain the above copyright
11 |  *    notice, this list of conditions and the following disclaimer.
12 |  *
13 |  * 2. Redistributions in binary form must reproduce the above copyright
14 |  *    notice, this list of conditions and the following disclaimer in
15 |  *    the documentation and/or other materials provided with the
16 |  *    distribution.
17 |  *
18 |  * 3. The end-user documentation included with the redistribution, if
19 |  *    any, must include the following acknowlegement:
20 |  *       "This product includes software developed by the
21 |  *        Caucho Technology (http://www.caucho.com/)."
22 |  *    Alternately, this acknowlegement may appear in the software itself,
23 |  *    if and wherever such third-party acknowlegements normally appear.
24 |  *
25 |  * 4. The names "Hessian", "Resin", and "Caucho" must not be used to
26 |  *    endorse or promote products derived from this software without prior
27 |  *    written permission. For written permission, please contact
28 |  *    info@caucho.com.
29 |  *
30 |  * 5. Products derived from this software may not be called "Resin"
31 |  *    nor may "Resin" appear in their names without prior written
32 |  *    permission of Caucho Technology.
33 |  *
34 |  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
35 |  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
36 |  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37 |  * DISCLAIMED.  IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS
38 |  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
39 |  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
40 |  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
41 |  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
42 |  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
43 |  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
44 |  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 |  *
46 |  * @author Scott Ferguson
47 |  */
48 | 
49 | package com.caucho.services.server;
50 | 
51 | import javax.servlet.ServletConfig;
52 | import javax.servlet.ServletException;
53 | 
54 | /**
55 |  * Interface for a service lifecycle.
56 |  *
57 |  * 

The lifecycle for a service starts with the init 58 | * method when the service starts. 59 | * 60 | *

61 |  * myService.init(config);
62 |  * ...
63 |  * myService.hello();
64 |  * ...
65 |  * myService.hello();
66 |  * ...
67 |  * myService.destroy();
68 |  * 
69 | */ 70 | public interface Service { 71 | /** 72 | * Initialize the service instance. 73 | * 74 | * @param config the configuration for the service. 75 | */ 76 | public void init(ServletConfig config) 77 | throws ServletException; 78 | 79 | /** 80 | * Cleanup the service instance. 81 | */ 82 | public void destroy(); 83 | } 84 | -------------------------------------------------------------------------------- /src/manifest: -------------------------------------------------------------------------------- 1 | Implementation-Vendor: Caucho Technology, Inc. 2 | Implementation-Version: 3.1.0 3 | 4 | 5 | --------------------------------------------------------------------------------