Package org.jboss.marshalling.serial
Class SerialMarshaller
- java.lang.Object
-
- java.io.OutputStream
-
- org.jboss.marshalling.SimpleByteOutput
-
- org.jboss.marshalling.ByteOutputStream
-
- org.jboss.marshalling.SimpleDataOutput
-
- org.jboss.marshalling.AbstractObjectOutput
-
- org.jboss.marshalling.AbstractMarshaller
-
- org.jboss.marshalling.serial.SerialMarshaller
-
- All Implemented Interfaces:
java.io.Closeable,java.io.DataOutput,java.io.Flushable,java.io.ObjectOutput,java.io.ObjectStreamConstants,java.lang.AutoCloseable,ByteOutput,Marshaller,ExtendedObjectStreamConstants
public final class SerialMarshaller extends AbstractMarshaller implements Marshaller, ExtendedObjectStreamConstants
-
-
Field Summary
Fields Modifier and Type Field Description private BlockMarshallerblockMarshallerprivate intbufferSizeprivate java.security.PrivilegedExceptionAction<SerialObjectOutputStream>createObjectOutputStreamActionprivate IdentityIntMap<java.lang.Class<?>>descriptorCacheprivate java.util.IdentityHashMap<java.lang.Class<?>,Externalizer>externalizersprivate IdentityIntMap<java.lang.Object>instanceCacheprivate intinstanceSeqprivate static intMIN_BUFFER_SIZEprivate SerialObjectOutputStreamoosprivate static IdentityIntMap<java.lang.Class<?>>primitivesprivate SerializableClassRegistryregistryprivate java.util.IdentityHashMap<java.lang.Object,java.lang.Object>replacementCache-
Fields inherited from class org.jboss.marshalling.AbstractMarshaller
classExternalizerFactory, classResolver, classTable, configuredVersion, exceptionListener, objectPreResolver, objectResolver, objectTable, serializabilityChecker, streamHeader
-
Fields inherited from class org.jboss.marshalling.SimpleDataOutput
buffer
-
Fields inherited from class org.jboss.marshalling.ByteOutputStream
byteOutput
-
Fields inherited from interface org.jboss.marshalling.serial.ExtendedObjectStreamConstants
TC_CLASSTABLEDESC, TC_OBJECTTABLE
-
Fields inherited from interface java.io.ObjectStreamConstants
baseWireHandle, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, SC_BLOCK_DATA, SC_ENUM, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, SERIAL_FILTER_PERMISSION, STREAM_MAGIC, STREAM_VERSION, SUBCLASS_IMPLEMENTATION_PERMISSION, SUBSTITUTION_PERMISSION, TC_ARRAY, TC_BASE, TC_BLOCKDATA, TC_BLOCKDATALONG, TC_CLASS, TC_CLASSDESC, TC_ENDBLOCKDATA, TC_ENUM, TC_EXCEPTION, TC_LONGSTRING, TC_MAX, TC_NULL, TC_OBJECT, TC_PROXYCLASSDESC, TC_REFERENCE, TC_RESET, TC_STRING
-
-
Constructor Summary
Constructors Constructor Description SerialMarshaller(AbstractMarshallerFactory marshallerFactory, SerializableClassRegistry registry, MarshallingConfiguration configuration)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearClassCache()Discard the class cache.voidclearInstanceCache()Discard the instance cache.private SerialObjectOutputStreamcreateObjectOutputStream()private voiddoEndBlock()protected voiddoWriteFields(SerializableClass info, java.lang.Object obj)protected voiddoWriteObject(java.lang.Object orig, boolean unshared)Implementation of the actual object-writing method.voidfinish()Finish writing to a stream.voidflush()private SerialObjectOutputStreamgetObjectOutputStream()private static java.lang.StringgetSignature(java.lang.Class<?> type)voidstart(ByteOutput byteOutput)Begin writing to a stream.private voidwriteClassDescFor(java.lang.Class<?> forClass)private voidwriteNewClassDescFor(java.lang.Class<?> forClass)private voidwriteNewPlainClassDesc(java.lang.Class<?> forClass)private voidwriteNewProxyClassDesc(java.lang.Class<?> forClass)(package private) voidwriteNoBlockFlush(byte[] bytes, int off, int len)private voidwriteSerialData(java.lang.Class<?> objClass, java.lang.Object obj)-
Methods inherited from class org.jboss.marshalling.AbstractMarshaller
close, writeObject, writeObjectUnshared
-
Methods inherited from class org.jboss.marshalling.SimpleDataOutput
shallowFlush, write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jboss.marshalling.ByteOutput
write, write, write
-
Methods inherited from interface java.io.DataOutput
writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
-
Methods inherited from interface org.jboss.marshalling.Marshaller
writeObjectUnshared
-
-
-
-
Field Detail
-
MIN_BUFFER_SIZE
private static final int MIN_BUFFER_SIZE
- See Also:
- Constant Field Values
-
registry
private final SerializableClassRegistry registry
-
instanceCache
private final IdentityIntMap<java.lang.Object> instanceCache
-
descriptorCache
private final IdentityIntMap<java.lang.Class<?>> descriptorCache
-
replacementCache
private final java.util.IdentityHashMap<java.lang.Object,java.lang.Object> replacementCache
-
externalizers
private final java.util.IdentityHashMap<java.lang.Class<?>,Externalizer> externalizers
-
bufferSize
private final int bufferSize
-
oos
private SerialObjectOutputStream oos
-
blockMarshaller
private BlockMarshaller blockMarshaller
-
instanceSeq
private int instanceSeq
-
createObjectOutputStreamAction
private final java.security.PrivilegedExceptionAction<SerialObjectOutputStream> createObjectOutputStreamAction
-
primitives
private static final IdentityIntMap<java.lang.Class<?>> primitives
-
-
Constructor Detail
-
SerialMarshaller
SerialMarshaller(AbstractMarshallerFactory marshallerFactory, SerializableClassRegistry registry, MarshallingConfiguration configuration) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
doWriteObject
protected void doWriteObject(java.lang.Object orig, boolean unshared) throws java.io.IOExceptionDescription copied from class:AbstractObjectOutputImplementation of the actual object-writing method.- Specified by:
doWriteObjectin classAbstractObjectOutput- Parameters:
orig- the object to writeunshared-trueif the instance is unshared,falseif it is shared- Throws:
java.io.IOException- if an I/O error occurs
-
writeSerialData
private void writeSerialData(java.lang.Class<?> objClass, java.lang.Object obj) throws java.io.IOException- Throws:
java.io.IOException
-
createObjectOutputStream
private SerialObjectOutputStream createObjectOutputStream() throws java.io.IOException
- Throws:
java.io.IOException
-
getObjectOutputStream
private SerialObjectOutputStream getObjectOutputStream() throws java.io.IOException
- Throws:
java.io.IOException
-
doWriteFields
protected void doWriteFields(SerializableClass info, java.lang.Object obj) throws java.io.IOException
- Throws:
java.io.IOException
-
writeClassDescFor
private void writeClassDescFor(java.lang.Class<?> forClass) throws java.io.IOException- Throws:
java.io.IOException
-
writeNewClassDescFor
private void writeNewClassDescFor(java.lang.Class<?> forClass) throws java.io.IOException- Throws:
java.io.IOException
-
writeNewProxyClassDesc
private void writeNewProxyClassDesc(java.lang.Class<?> forClass) throws java.io.IOException- Throws:
java.io.IOException
-
writeNewPlainClassDesc
private void writeNewPlainClassDesc(java.lang.Class<?> forClass) throws java.io.IOException- Throws:
java.io.IOException
-
doEndBlock
private void doEndBlock() throws java.io.IOException- Throws:
java.io.IOException
-
getSignature
private static java.lang.String getSignature(java.lang.Class<?> type)
-
clearInstanceCache
public void clearInstanceCache() throws java.io.IOExceptionDescription copied from interface:MarshallerDiscard the instance cache. May also discard the class cache in implementations that do not support separated class and instance caches.- Specified by:
clearInstanceCachein interfaceMarshaller- Throws:
java.io.IOException- if an error occurs
-
clearClassCache
public void clearClassCache() throws java.io.IOExceptionDescription copied from interface:MarshallerDiscard the class cache. Implicitly also discards the instance cache.- Specified by:
clearClassCachein interfaceMarshaller- Throws:
java.io.IOException- if an error occurs
-
start
public void start(ByteOutput byteOutput) throws java.io.IOException
Description copied from class:AbstractMarshallerBegin writing to a stream.- Specified by:
startin interfaceMarshaller- Overrides:
startin classAbstractMarshaller- Parameters:
byteOutput- the new stream- Throws:
java.io.IOException- if an error occurs
-
finish
public void finish() throws java.io.IOExceptionDescription copied from class:AbstractMarshallerFinish writing to a stream. The stream is released. No further writing may be done until theSimpleDataOutput.start(ByteOutput)method is again invoked.- Specified by:
finishin interfaceMarshaller- Overrides:
finishin classAbstractMarshaller- Throws:
java.io.IOException- if an error occurs
-
flush
public void flush() throws java.io.IOExceptionDescription copied from class:SimpleDataOutput- Specified by:
flushin interfacejava.io.Flushable- Specified by:
flushin interfacejava.io.ObjectOutput- Overrides:
flushin classSimpleDataOutput- Throws:
java.io.IOException
-
writeNoBlockFlush
void writeNoBlockFlush(byte[] bytes, int off, int len) throws java.io.IOException- Throws:
java.io.IOException
-
-