class ObjectMessageTranslator extends MessageTypeTranslatorImp {

  public Message translate(AdaptrisMessage msg) throws JMSException {
    ObjectMessage result = session.createObjectMessage();
    try {
      if (msg.getSize() > 0) {
        InputStream in = msg.getInputStream();
        ObjectInputStream object = new ObjectInputStream(in);
        result.setObject((Serializable) object.readObject());
        object.close();
        in.close();
      }
    }
    catch (Exception e) {
      JmsUtils.rethrowJMSException(e);
    }

    return helper.moveMetadata(msg, result);
  }

}