public final byte [ ] serialize ( Object object ) throws IOException { if ( object == null ) return null ; ByteArrayOutputStream bout = new ByteArrayOutputStream ( ) ; SerializationService serializationSvc = serializationSvcRef . getServiceWithException ( ) ; ObjectOutputStream oout = serializationSvc . createObjectOutputStream ( new DeflaterOutputStream ( bout ) ) ; oout . writeObject ( object ) ; oout . flush ( ) ; oout . close ( ) ; byte [ ] bytes = bout . toByteArray ( ) ; return bytes ; }
Utility method that serializes an object to bytes .