diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-10 19:18:51 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-10 19:18:51 +0000 |
commit | 9833a542bb75c2008c71809e4fdfebc41e67fb46 (patch) | |
tree | d89597c3f9308f70cd89c2e8e2cf4b9adeb43994 /sdo-java/trunk/sdo-api/src/main/java/commonj/sdo/impl/ExternalizableDelegator.java | |
parent | 5b2262864f55b51575f381a823ffacf6b7c27a74 (diff) |
Move the SDO folder as new trunk for SDO sub project
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@834610 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sdo-java/trunk/sdo-api/src/main/java/commonj/sdo/impl/ExternalizableDelegator.java')
-rw-r--r-- | sdo-java/trunk/sdo-api/src/main/java/commonj/sdo/impl/ExternalizableDelegator.java | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/sdo-java/trunk/sdo-api/src/main/java/commonj/sdo/impl/ExternalizableDelegator.java b/sdo-java/trunk/sdo-api/src/main/java/commonj/sdo/impl/ExternalizableDelegator.java new file mode 100644 index 0000000000..03220a8a32 --- /dev/null +++ b/sdo-java/trunk/sdo-api/src/main/java/commonj/sdo/impl/ExternalizableDelegator.java @@ -0,0 +1,90 @@ +/** + * <copyright> + * + * Service Data Objects + * Version 2.1.0 + * Licensed Materials + * + * (c) Copyright BEA Systems, Inc., International Business Machines Corporation, + * Oracle Corporation, Primeton Technologies Ltd., Rogue Wave Software, SAP AG., + * Software AG., Sun Microsystems, Sybase Inc., Xcalia, Zend Technologies, + * 2005, 2006. All rights reserved. + * + * </copyright> + * + */ + +package commonj.sdo.impl; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.io.ObjectStreamException; + +/** + * Delegates DataObject serialization while ensuring implementation independent + * java.io.Serialization. An implementation of DataObject + * returns an ExternalizableDelegator from its writeReplace() method. + * + * The root DataObject is the object returned from do.getRootObject() where + * do is the DataObject being serialized in a java.io.ObjectOutputStream. + * When do.getContainer() == null then do is a root object. + * + * The byte format for each DataObject in the stream is: + * [0] [path] [root] // when do is not a root object + * [1] [rootXML] // when do is a root object + * + * where: + * [0] is the byte 0, serialized using writeByte(0). + * [1] is the byte 1, serialized using writeByte(1). + * + * [path] is an SDO path expression from the root DataObject to the serialized + * DataObject such that root.getDataObject(path) == do. + * Serialized using writeUTF(path). + * + * [root] is the root object serialized using writeObject(root). + * + * [rootXML] is the GZip of the XML serialization of the root DataObject. + * The XML serialization is the same as + * XMLHelper.INSTANCE.save(root, "commonj.sdo", "dataObject", stream); + * where stream is a GZIPOutputStream, length is the number of bytes + * in the stream, and bytes are the contents of the stream. + * Serialized using writeInt(length), write(bytes). + * + */ +public class ExternalizableDelegator implements Externalizable +{ + public interface Resolvable extends Externalizable + { + Object readResolve() throws ObjectStreamException; + } + + static final long serialVersionUID = 1; + transient Resolvable delegate; + + public ExternalizableDelegator() + { + delegate = HelperProvider.createResolvable(); + } + + public ExternalizableDelegator(Object target) + { + delegate = HelperProvider.createResolvable(target); + } + + public void writeExternal(ObjectOutput out) throws IOException + { + delegate.writeExternal(out); + } + + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException + { + delegate.readExternal(in); + } + + public Object readResolve() throws ObjectStreamException + { + return delegate.readResolve(); + } +} |