@ Override public byte [ ] encode ( final T obj ) { try ( final ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; final ObjectOutputStream out = new ObjectOutputStream ( bos ) ) { out . writeObject ( obj ) ; return bos . toByteArray ( ) ; } catch ( final IOException ex ) { throw new RemoteRuntimeException ( ex ) ; } }
Encodes the object to bytes .