/**
  * Use MarshalledValue.Externalizer to serialize.
  *
  * @param mv
  * @return
  * @throws Exception
  */
 private String serializeObj(MarshalledValue mv) throws Exception {
   if (externalizer == null)
     throw new IllegalStateException("Cannot serialize object: undefined marshaller");
   ByteArrayOutputStream baos = new ByteArrayOutputStream();
   ObjectOutputStream oos = new ObjectOutputStream(baos);
   externalizer.writeObject(oos, mv);
   oos.close();
   return Base64.encodeBytes(baos.toByteArray());
 }
 /**
  * Use MarshalledValue.Externalizer to deserialize.
  *
  * @param key
  * @return
  * @throws Exception
  */
 private MarshalledValue deserializeObj(String key) throws Exception {
   if (externalizer == null)
     throw new IllegalStateException("Cannot deserialize object: undefined marshaller");
   byte[] data = Base64.decode(key);
   ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(data));
   MarshalledValue mv = externalizer.readObject(ois);
   ois.close();
   return mv;
 }