james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joachim Draeger <jdrae...@gmx.de>
Subject BasicMailboxSession (aka MessageRepository)
Date Sat, 28 Oct 2006 16:51:13 GMT

Hi all!

I guess it is wished that the API for just accessing user inboxes should
stay as easy as possible. 
That's why I'm proposing a separate Interface that only contains core
functionalities.

Just like addUser has been moved from James class to UsersRepository,
getUserInbox could be moved to MailboxManagerProvider (alias
MailboxService):

package org.apache.james.mailboxservice;

interface MailboxService {
  BasicMailboxSession getBasicInboxSession(User user);

  /** @param user the authorized User for checking credentials 
      @param mailboxName a logical/hierarchical mailbox name **/ 

  BasicMailboxSession getBasicMailboxSession(
       User user, String mailboxName);

}

interface BasicMailbox {

    /** @return the key */
    String store(MimeMessage message) throws MessagingException;

    /** @return keys */
    Collection list() throws MessagingException;

    MimeMessage retrieve(String key);

    /**
     * key changes by updating
     * @param key the current key
     * @return the new key
     */
    String update(String key, MimeMessage message)
            throws MessagingException;

    void remove(String key)
            throws MessagingException;
}

interface BasicMailboxSession extends BasicMailbox, MailboxSession {}

public interface MailboxSession {
    public void close();
    public boolean isWriteable();
}

The main differences to current MailRepository are:

* keys are generated by mailbox
* separate store/update
* sessions have to be explicitly closed. (and not weak referenced and
_maybe_ gc'ed away)
* logical mailbox names that are mapped to physical backends

Okay there is one point that is a bit more difficult: 
ToRepository Mailet, which accepts a url. 
It is used for mail that is not delivered to a user like spam or mail
that can't be delivered.
I guess the ability to put this repositories where ever one wants is
quite popular.
Maybe we could use a logical #system name space here like #system.spam
or #system.address-error.
For example this could be mapped like: #system.* -> file:/var/mail/*

BasicMailboxSession mailboxSession= mailboxService.
       getBasicMailboxSession(User.SMTP, "#system.spam");
mailboxSession.store(aSpamMimeMessage);
mailboxSession.close();      

Roadmap:

1. discussion
2. vote
3. deprecate MailRepository and James.getUserInbox() (not to break
backward compatibility)
4. provide BasicMailbox wrappers around MailRepository 
5. refactor current components to use MailboxService.

What do you think?

Joachim



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message