Top Description Inners Fields Constructors Methods
com.sun.faces.util.copier

public Class SerializationCopier

extends Object
implements Copier
Class Inheritance
All Implemented Interfaces
com.sun.faces.util.copier.Copier
Imports
java.io.ByteArrayInputStream, .ByteArrayOutputStream, .IOException, .InputStream, .ObjectInputStream, .ObjectOutputStream, .ObjectStreamClass, .OutputStream, .Serializable, java.util.LinkedList, .Queue

Copier that copies an object by serializing and subsequently deserializing it again.

As per the platform serialization rules, the object and all its non transient dependencies have to implement the Serializable interface.

Author
Arjan Tijms
Since
2.3

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Object
copy(Object
the object to be copied
object
)

Implements com.sun.faces.util.copier.Copier.copy.

Return an object that's logically a copy of the given object.
private static <T> T
copyOutIn(T object)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

SERIALIZATION_COPIER_ERRORback to summary
private static final String SERIALIZATION_COPIER_ERROR

Constructor Detail

SerializationCopierback to summary
public SerializationCopier()

Method Detail

copyback to summary
public Object copy(Object object)

Implements com.sun.faces.util.copier.Copier.copy.

Doc from com.sun.faces.util.copier.Copier.copy.

Return an object that's logically a copy of the given object.

Parameters
object:Object

the object to be copied

Returns:Object

a copy of the given object

Annotations
@Override
copyOutInback to summary
private static <T> T copyOutIn(T object) throws ClassNotFoundException, IOException
Annotations
@SuppressWarnings:unchecked
com.sun.faces.util.copier back to summary

private Class SerializationCopier.In

extends ObjectInputStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final SerializationCopier.Out

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected Class<?>
resolveClass(ObjectStreamClass
an instance of class ObjectStreamClass
objectStreamClass
)

Overrides java.io.ObjectInputStream.resolveClass.

Load the local class equivalent of the specified stream class description.
protected Class<?>
resolveProxyClass(String[]
the list of interface names that were deserialized in the proxy class descriptor
interfaceNames
)

Overrides java.io.ObjectInputStream.resolveProxyClass.

Returns a proxy class that implements the interfaces named in a proxy class descriptor; subclasses may implement this method to read custom data from the stream along with the descriptors for dynamic proxy classes, allowing them to use an alternate loading mechanism for the interfaces and the proxy class.
Inherited from java.io.ObjectInputStream:
availableclosedefaultReadObjectenableResolveObjectgetObjectInputFilterreadreadreadBooleanreadBytereadCharreadClassDescriptorreadDoublereadFieldsreadFloatreadFullyreadFullyreadIntreadLinereadLongreadObjectreadObjectOverridereadShortreadStreamHeaderreadUnsharedreadUnsignedBytereadUnsignedShortreadUTFregisterValidationresolveObjectsetObjectInputFilterskipBytes

Field Detail

outback to summary
private final SerializationCopier.Out out

Constructor Detail

Inback to summary
pack-priv In(InputStream inputStream, SerializationCopier.Out out) throws IOException

Method Detail

resolveClassback to summary
protected Class<?> resolveClass(ObjectStreamClass objectStreamClass) throws IOException, ClassNotFoundException

Overrides java.io.ObjectInputStream.resolveClass.

Doc from java.io.ObjectInputStream.resolveClass.

Load the local class equivalent of the specified stream class description. Subclasses may implement this method to allow classes to be fetched from an alternate source.

The corresponding method in ObjectOutputStream is annotateClass. This method will be invoked only once for each unique class in the stream. This method can be implemented by subclasses to use an alternate loading mechanism but must return a Class object. Once returned, if the class is not an array class, its serialVersionUID is compared to the serialVersionUID of the serialized class, and if there is a mismatch, the deserialization fails and an InvalidClassException is thrown.

The default implementation of this method in ObjectInputStream returns the result of calling

Class.forName(desc.getName(), false, loader)
Class.forName(desc.getName(), false, loader)
where loader is the first class loader on the current thread's stack (starting from the currently executing method) that is neither the platform class loader nor its ancestor; otherwise, loader is the platform class loader. If this call results in a ClassNotFoundException and the name of the passed ObjectStreamClass instance is the Java language keyword for a primitive type or void, then the Class object representing that primitive type or void will be returned (e.g., an ObjectStreamClass with the name "int" will be resolved to Integer.TYPE). Otherwise, the ClassNotFoundException will be thrown to the caller of this method.
Parameters
objectStreamClass:ObjectStreamClass

an instance of class ObjectStreamClass

Returns:Class<?>

a Class object corresponding to desc

Annotations
@Override
Exceptions
IOException:
any of the usual Input/Output exceptions.
ClassNotFoundException:
if class of a serialized object cannot be found.
resolveProxyClassback to summary
protected Class<?> resolveProxyClass(String[] interfaceNames) throws IOException, ClassNotFoundException

Overrides java.io.ObjectInputStream.resolveProxyClass.

Doc from java.io.ObjectInputStream.resolveProxyClass.

Returns a proxy class that implements the interfaces named in a proxy class descriptor; subclasses may implement this method to read custom data from the stream along with the descriptors for dynamic proxy classes, allowing them to use an alternate loading mechanism for the interfaces and the proxy class.

This method is called exactly once for each unique proxy class descriptor in the stream.

The corresponding method in ObjectOutputStream is annotateProxyClass. For a given subclass of ObjectInputStream that overrides this method, the annotateProxyClass method in the corresponding subclass of ObjectOutputStream must write any data or objects read by this method.

The default implementation of this method in ObjectInputStream returns the result of calling Proxy.getProxyClass with the list of Class objects for the interfaces that are named in the interfaces parameter. The Class object for each interface name i is the value returned by calling

Class.forName(i, false, loader)
Class.forName(i, false, loader)
where loader is the first class loader on the current thread's stack (starting from the currently executing method) that is neither the platform class loader nor its ancestor; otherwise, loader is the platform class loader. Unless any of the resolved interfaces are non-public, this same value of loader is also the class loader passed to Proxy.getProxyClass; if non-public interfaces are present, their class loader is passed instead (if more than one non-public interface class loader is encountered, an IllegalAccessError is thrown). If Proxy.getProxyClass throws an IllegalArgumentException, resolveProxyClass will throw a ClassNotFoundException containing the IllegalArgumentException.
Parameters
interfaceNames:String[]

the list of interface names that were deserialized in the proxy class descriptor

Returns:Class<?>

a proxy class for the specified interfaces

Annotations
@Override
Exceptions
IOException:
any exception thrown by the underlying InputStream
ClassNotFoundException:
if the proxy class or any of the named interfaces could not be found
com.sun.faces.util.copier back to summary

private Class SerializationCopier.Out

extends ObjectOutputStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv Queue<Class<?>>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected void
annotateClass(Class<?>
the class to annotate custom data for
c
)

Overrides java.io.ObjectOutputStream.annotateClass.

Subclasses may implement this method to allow class data to be stored in the stream.
protected void
annotateProxyClass(Class<?>
the proxy class to annotate custom data for
c
)

Overrides java.io.ObjectOutputStream.annotateProxyClass.

Subclasses may implement this method to store custom data in the stream along with descriptors for dynamic proxy classes.
Inherited from java.io.ObjectOutputStream:
closedefaultWriteObjectdrainenableReplaceObjectflushputFieldsreplaceObjectresetuseProtocolVersionwritewritewritewriteBooleanwriteBytewriteByteswriteCharwriteCharswriteClassDescriptorwriteDoublewriteFieldswriteFloatwriteIntwriteLongwriteObjectwriteObjectOverridewriteShortwriteStreamHeaderwriteUnsharedwriteUTF

Field Detail

queueback to summary
pack-priv Queue<Class<?>> queue

Constructor Detail

Outback to summary
pack-priv Out(OutputStream out) throws IOException

Method Detail

annotateClassback to summary
protected void annotateClass(Class<?> c)

Overrides java.io.ObjectOutputStream.annotateClass.

Doc from java.io.ObjectOutputStream.annotateClass.

Subclasses may implement this method to allow class data to be stored in the stream. By default this method does nothing. The corresponding method in ObjectInputStream is resolveClass. This method is called exactly once for each unique class in the stream. The class name and signature will have already been written to the stream. This method may make free use of the ObjectOutputStream to save any representation of the class it deems suitable (for example, the bytes of the class file). The resolveClass method in the corresponding subclass of ObjectInputStream must read and use any data or objects written by annotateClass.

Parameters
c:Class<?>

the class to annotate custom data for

Annotations
@Override
annotateProxyClassback to summary
protected void annotateProxyClass(Class<?> c)

Overrides java.io.ObjectOutputStream.annotateProxyClass.

Doc from java.io.ObjectOutputStream.annotateProxyClass.

Subclasses may implement this method to store custom data in the stream along with descriptors for dynamic proxy classes.

This method is called exactly once for each unique proxy class descriptor in the stream. The default implementation of this method in ObjectOutputStream does nothing.

The corresponding method in ObjectInputStream is resolveProxyClass. For a given subclass of ObjectOutputStream that overrides this method, the resolveProxyClass method in the corresponding subclass of ObjectInputStream must read any data or objects written by annotateProxyClass.

Parameters
c:Class<?>

the proxy class to annotate custom data for

Annotations
@Override