Class SerWrapper<T extends Serializable>
- java.lang.Object
-
- org.marketcetera.util.ws.wrappers.BaseWrapper<R>
-
- org.marketcetera.util.ws.wrappers.DualWrapper<T,byte[]>
-
- org.marketcetera.util.ws.wrappers.SerWrapper<T>
-
- All Implemented Interfaces:
Externalizable,Serializable
- Direct Known Subclasses:
CompSerWrapper
public class SerWrapper<T extends Serializable> extends DualWrapper<T,byte[]>
A dual-form wrapper for marshalling a serializable object. The raw form is an object implementingSerializable, and the marshalled form is a byte array.This wrapper is itself Java serializable and JAXB-marshallable. Its own deserialization/unmarshalling succeeds without an exception even if the wrapped object cannot be deserialized, in which case the wrapper contains a null value for the wrapped object's raw and marshalled forms, logs a warning, and
getDeserializationException()returns the exception thrown during deserialization. Similarly, its own serialization/marshalling succeeds without an exception even if the wrapped object cannot be serialized, in which case the wrapper contains a null value for the wrapped object's raw and marshalled forms, logs a warning, andgetSerializationException()returns the exception thrown during serialization.- Since:
- 1.0.0
- Version:
- $Id: SerWrapper.java 16154 2012-07-14 16:34:05Z colin $
- Author:
- tlerios@marketcetera.com
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private org.apache.commons.lang.SerializationExceptionmDeserializationExceptionprivate org.apache.commons.lang.SerializationExceptionmSerializationExceptionprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description SerWrapper()Creates a new wrapper.SerWrapper(T raw)Creates a new wrapper for the given object, in its raw form.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.commons.lang.SerializationExceptiongetDeserializationException()Returns the exception encountered during the most recent deserialization attempt; it is null if that attempt was successful, or no attempt has been made yet.org.apache.commons.lang.SerializationExceptiongetSerializationException()Returns the exception encountered during the most recent serialization attempt; it is null if that attempt was successful, or no attempt has been made yet.private voidsetDeserializationException(org.apache.commons.lang.SerializationException deserializationException)Sets the exception encountered during the most recent deserialization attempt to the given exception.private voidsetSerializationException(org.apache.commons.lang.SerializationException serializationException)Sets the exception encountered during the most recent serialization attempt to the given exception.protected voidtoMarshalled()Sets the marshalled form of the receiver's value so that it corresponds to its raw form.protected voidtoRaw()Sets the raw form of the receiver's value so that it corresponds to its marshalled form.-
Methods inherited from class org.marketcetera.util.ws.wrappers.DualWrapper
getMarshalled, getRaw, readExternal, setMarshalled, setMarshalledOnly, setRaw, setRawOnly, writeExternal
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
mSerializationException
private org.apache.commons.lang.SerializationException mSerializationException
-
mDeserializationException
private org.apache.commons.lang.SerializationException mDeserializationException
-
-
Constructor Detail
-
SerWrapper
public SerWrapper(T raw)
Creates a new wrapper for the given object, in its raw form. It also sets the internal marshalled form to match.- Parameters:
raw- The object, which may be null.
-
SerWrapper
public SerWrapper()
Creates a new wrapper. This empty constructor is intended for use by JAXB and Java serialization.
-
-
Method Detail
-
getSerializationException
public org.apache.commons.lang.SerializationException getSerializationException()
Returns the exception encountered during the most recent serialization attempt; it is null if that attempt was successful, or no attempt has been made yet.- Returns:
- The exception.
-
setSerializationException
private void setSerializationException(org.apache.commons.lang.SerializationException serializationException)
Sets the exception encountered during the most recent serialization attempt to the given exception.- Parameters:
serializationException- The exception.
-
getDeserializationException
public org.apache.commons.lang.SerializationException getDeserializationException()
Returns the exception encountered during the most recent deserialization attempt; it is null if that attempt was successful, or no attempt has been made yet.- Returns:
- The exception.
-
setDeserializationException
private void setDeserializationException(org.apache.commons.lang.SerializationException deserializationException)
Sets the exception encountered during the most recent deserialization attempt to the given exception.- Parameters:
deserializationException- The exception.
-
toRaw
protected void toRaw()
Description copied from class:DualWrapperSets the raw form of the receiver's value so that it corresponds to its marshalled form. The subclass implementation can assume that the latter form is non-null. The subclass may modify both the former and latter forms (for example, if the latter form is invalid). OnlyDualWrapper.setRawOnly(Object)andDualWrapper.setMarshalledOnly(Object)should be used in setting either form, to prevent infinite recursion. The raw form is null if and only if the marshalled one is null; the caller of this method will enforce this invariant, so the subclass implementation can set just the raw form to null.- Specified by:
toRawin classDualWrapper<T extends Serializable,byte[]>
-
toMarshalled
protected void toMarshalled()
Description copied from class:DualWrapperSets the marshalled form of the receiver's value so that it corresponds to its raw form. The subclass implementation can assume that the latter form is non-null. The subclass may modify both the former and latter forms (for example, if the latter form is invalid). OnlyDualWrapper.setRawOnly(Object)andDualWrapper.setMarshalledOnly(Object)should be used in setting either form, to prevent infinite recursion. The raw form is null if and only if the marshalled one is null; the caller of this method will enforce this invariant, so the subclass implementation can set just the marshalled form to null.- Specified by:
toMarshalledin classDualWrapper<T extends Serializable,byte[]>
-
-