public Message setObject(Object obj) {
        if(obj == null) return this;
        if(obj instanceof byte[])
            return setBuffer((byte[])obj);
        if(obj instanceof Buffer)
            return setBuffer((Buffer)obj);
        try {
            return setBuffer(Util.objectToByteBuffer(obj));
        }
        catch(Exception ex) {
            throw new IllegalArgumentException(ex);
        }
    }
public Message setObject ( Object obj ) { if ( obj == null ) return this ; if ( obj instanceof byte [ ] ) return setBuffer ( ( byte [ ] ) obj ) ; if ( obj instanceof Buffer ) return setBuffer ( ( Buffer ) obj ) ; try { return setBuffer ( Util . objectToByteBuffer ( obj ) ) ; } catch ( Exception ex ) { throw new IllegalArgumentException ( ex ) ; } }
Takes an object and uses Java serialization to generate the byte[] buffer which is set in the
message. Parameter 'obj' has to be serializable (e.g. implementing Serializable,
Externalizable or Streamable, or be a basic type (e.g. Integer, Short etc)).