(This is just for completeness).
What I ended up doing was basically copy the process from JDBCMailRepository
store/retrieve methods, except putting the data in an output stream instead
of a prepared statement.

            ObjectOutputStream oos = new ...

            oos.writeObject(mail.getName());
            oos.writeObject(mail.getState());
            oos.writeObject(mail.getErrorMessage());
            oos.writeObject(mail.getSender());
            StringBuffer recipients = new StringBuffer();
            for (Iterator i = mail.getRecipients().iterator(); i.hasNext();
) {
                recipients.append(i.next().toString());
                if (i.hasNext()) {
                    recipients.append("\r\n");
                }
            }
            oos.writeObject(recipients.toString());

            oos.writeObject(mail.getRemoteHost());
            oos.writeObject(mail.getRemoteAddr());
            oos.writeObject(mail.getLastUpdated());
            MimeMessageUtil.writeTo(mail.getMessage(), oos, oos);
            oos.close()

When deserializing I do the exact opposite, with this magic at the end,
copied from JDBCMailRepository.retrieve():

            MimeMessageInputStreamSource source = new
MimeMessageInputStreamSource("temp", ois);
            MimeMessageCopyOnWriteProxy message = new
MimeMessageCopyOnWriteProxy(source);
            mail.setMessage(message);

I'm not 100% clear on what exactly goes on with the proxy business, but it
seems to work.
Thanks for replying.

Israel.

Reply via email to