private void serializeRealObject() throws ObjectFailedToSerializeException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "serializeRealObject");

        if (hasRealObject) {

            // If the realObject isn't null, we need to serialize it & set it into the message
            if (realObject != null) {

                try {
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    ObjectOutputStream oos = new ObjectOutputStream(baos);
                    // Write the real object into a byte array
                    oos.writeObject(realObject);
                    // Store the bytes in the payload
                    getPayload().setField(JmsObjectBodyAccess.BODY_DATA_VALUE, baos.toByteArray());

                    // Set the flag, create a SoftReference to the Object & null out the strong reference
                    // so the object can be GCd if necessary
                    hasSerializedRealObject = true;
                    softRefToRealObject = new SoftReference<Serializable>(realObject);
                    realObject = null;
                }

                catch (IOException ioe) {
                    FFDCFilter.processException(ioe, "com.ibm.ws.sib.mfp.impl.JsJmsObjectMessageImpl.serializeRealObject", "296");
                    // Wrapper the exception, giving the object's class name, and throw.
                    String objectClassName = realObject.getClass().getName();
                    throw new ObjectFailedToSerializeException(ioe
                                    , objectClassName);
                }
            }

            // If the realObject is null, we just set the field in the message & can now claim to have serialized it.
            else {
                // Real object is null
                getPayload().setField(JmsObjectBodyAccess.BODY_DATA_VALUE, null);
                // We have not actually serialized anything, but the object data is in the payload
                hasSerializedRealObject = true;
            }
        }

        // Any length calculation will need to be redone as the message now 'owns' the payload value
        clearCachedLengths();
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "serializeRealObject");
    }
private void serializeRealObject ( ) throws ObjectFailedToSerializeException { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "serializeRealObject" ) ; if ( hasRealObject ) { if ( realObject != null ) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; ObjectOutputStream oos = new ObjectOutputStream ( baos ) ; oos . writeObject ( realObject ) ; getPayload ( ) . setField ( JmsObjectBodyAccess . BODY_DATA_VALUE , baos . toByteArray ( ) ) ; hasSerializedRealObject = true ; softRefToRealObject = new SoftReference < Serializable > ( realObject ) ; realObject = null ; } catch ( IOException ioe ) { FFDCFilter . processException ( ioe , "com.ibm.ws.sib.mfp.impl.JsJmsObjectMessageImpl.serializeRealObject" , "296" ) ; String objectClassName = realObject . getClass ( ) . getName ( ) ; throw new ObjectFailedToSerializeException ( ioe , objectClassName ) ; } } else { getPayload ( ) . setField ( JmsObjectBodyAccess . BODY_DATA_VALUE , null ) ; hasSerializedRealObject = true ; } } clearCachedLengths ( ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "serializeRealObject" ) ; }
Private method to serialize the 'real' object into the payload.

This method is only called if we have a 'real' object AND it has not already been serialized
Note that this doesn't preclude realObject being null, as null may be the real value
set using setRealObject().

@exception ObjectFailedToSerializeException Serialization of the object failed