You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Robert Burrell Donkin <ro...@gmail.com> on 2007/10/26 23:29:18 UTC

[MailboxManager] API Design

from https://issues.apache.org/jira/browse/JAMES-808

> Currently the implementation of the FETCH command is not very efficient. For example to
> retrieve one mail the following conversions will happens:
> 1, the backend creates a MimeMessage from a file/database blob/thin air/etc
> 2, the frontend converts into a byte array, with correct CRLF line endings. (I don't get, why it's
> needed, every incoming MimeMessage is already in this format, isn't it ?)
> 3, the frontend appends it into a StringBuffer in the FetchCommand class
> 4, after some String manipulation it gets sent over an InternetPrintWriter which checks also that
all line endings in correct style.

this mess is the primary reason why the current implementation is
unreasonably slow. i've been running alternative code on my local fork
and the implementation is now quite enough to be usable.

> I'm not sure that the whole thing is absolutly necessary.

i'm sure that it is unnecessary

IMHO the approach in JAMES-808 is the right one (adding more function
and options to http://svn.apache.org/repos/asf/james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/MessageResult.java)
but there are a few broader design issues around MailboxManager that
i'd like to throw open for wider debate

in terms of general API design, i tend to prefer to use subsidary
objects to tie together data. so (for example) i prefer a Headers
interfaces and a getHeaders method rather than adding three or four
header related methods into the general API.

AIUI MailboxManager was intended to be a general API without coupling
to any particular protocol (please jump in if i have this wrong). if
this is still a useful design requirement then we need to do something
a little more sophisticated.

in particular, the structure use cases are difficult. here, IMAP needs
to know about the outline structure of a message: if it's a mime and
if so, it's composition. JAMES-808 approaching this by returning
protocol specific values coupling the API to IMAP.

i've been considering using Mime4J instead to allow generic
information to be obtained about the structure. this requires (as
jochen suggested) factoring out a suitable interface for the pull
parser. i hope that this would be good enough to allow backend
optimisation without coupling so strongly to IMAP.

opinions?

- robert

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


Re: [MailboxManager] API Design

Posted by Zsombor <gz...@gmail.com>.
On 11/5/07, Paulo Sergio <pa...@gmail.com> wrote:
>
> Hi Robert,
>
> On 11/5/07, Robert Burrell Donkin <ro...@gmail.com> wrote:
> >
> > On Nov 4, 2007 8:21 PM, Paulo Sergio <pa...@gmail.com> wrote:
> > > Hi all,
> >
> > hi paulo
> >
> > > i've been following the  discussion  and  i would like to give my
> > opinion
> > > (although i'm not an expert).
> > > i think we are forgetting an important thing, we are designing an API
> > > thinking about the existent protocols, although i think we should
> think
> > also
> > > in  what's next :) .
> > >
> > > In my case, i'm currently working in a web-service backend for james
> > using
> > > IMAP as a "front end protocol". Now i would like to start working in a
> > push
> > > mechanism, and i think about implementing IMAP Idle, i would have a
> > server
> > > sending the notification to james server, witch then would send the
> > > notification to the client.
> > >
> > > Well, this is one of the problems i think james has (correct me if i'm
> > > wrong), it lacks any type of push mechanism.
> > > In my case the server could send a session id to james, indicating
> what
> > > client should retrieve the new mails, the problem would be to get the
> > > session of the user that should be notified..
> > >
> > >
> > > in my opinion i believe we should have some king of way of sending a
> > > notification/event to the mailbox or even  better to any session,
> these
> > > would be send by an external server (my case) or by events sent by
> james
> > > server (ex:  when a message is received, check if the user is
> connected
> > and
> > > if it is send a notification to the session)
> >
> > ATM the API allows mailbox listeners to be registered but the current
> > interfaces aren't great. a single method accepting an event is more
> > concise and extensible than including all calls in an interface.
> >
> > IDLE was touched upon earlier. Zsombor suggested that listeners would
> > registered at the mailboxmanager level. if the API were switched to
> > use events then every listener could receive events for every mailbox
> > and then ignore any that were of no interest. novel events could be
> > injected into the system by the backend implementation. listeners
> > would ignore any events they did not understand.
> >
> > would this mechanism be good enough?
>
>
> i believe so, but you mean  that each  user connected would be able to
> register as a listener and then be notified when something happens?
> what about notifications from an external service ? how will these work?


With shared mailboxes and the NOTIFY extension the user can receive
notifications about new mails. I don't know what do you want from external
services, and how it is related to the IMAP protocol. Probably you can
hijack this infrastructure, to add some custom IMAP command and response,
but in that case, you have to write a specific client too, but I think it's
simpler to write your own protocol, and own little server application.

BR,
 Zsombor


ps. however I hope that you can contribute to the IMAP module, anyway :)


Thanks,
> paulo f
>
> another open question is whether an explicit API session would be a
> > useful to tie things together. something like a session would probably
> > be needed to reduce the number of factory method calls required to
> > obtain an API for a particular mailbox.
> >
> > - robert
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> > For additional commands, e-mail: server-dev-help@james.apache.org
> >
> >
>

Re: [MailboxManager] API Design

Posted by Paulo Sergio <pa...@gmail.com>.
Hi Robert,

On 11/5/07, Robert Burrell Donkin <ro...@gmail.com> wrote:
>
> On Nov 4, 2007 8:21 PM, Paulo Sergio <pa...@gmail.com> wrote:
> > Hi all,
>
> hi paulo
>
> > i've been following the  discussion  and  i would like to give my
> opinion
> > (although i'm not an expert).
> > i think we are forgetting an important thing, we are designing an API
> > thinking about the existent protocols, although i think we should think
> also
> > in  what's next :) .
> >
> > In my case, i'm currently working in a web-service backend for james
> using
> > IMAP as a "front end protocol". Now i would like to start working in a
> push
> > mechanism, and i think about implementing IMAP Idle, i would have a
> server
> > sending the notification to james server, witch then would send the
> > notification to the client.
> >
> > Well, this is one of the problems i think james has (correct me if i'm
> > wrong), it lacks any type of push mechanism.
> > In my case the server could send a session id to james, indicating what
> > client should retrieve the new mails, the problem would be to get the
> > session of the user that should be notified..
> >
> >
> > in my opinion i believe we should have some king of way of sending a
> > notification/event to the mailbox or even  better to any session, these
> > would be send by an external server (my case) or by events sent by james
> > server (ex:  when a message is received, check if the user is connected
> and
> > if it is send a notification to the session)
>
> ATM the API allows mailbox listeners to be registered but the current
> interfaces aren't great. a single method accepting an event is more
> concise and extensible than including all calls in an interface.
>
> IDLE was touched upon earlier. Zsombor suggested that listeners would
> registered at the mailboxmanager level. if the API were switched to
> use events then every listener could receive events for every mailbox
> and then ignore any that were of no interest. novel events could be
> injected into the system by the backend implementation. listeners
> would ignore any events they did not understand.
>
> would this mechanism be good enough?


i believe so, but you mean  that each  user connected would be able to
register as a listener and then be notified when something happens?
what about notifications from an external service ? how will these work?

Thanks,
paulo f

another open question is whether an explicit API session would be a
> useful to tie things together. something like a session would probably
> be needed to reduce the number of factory method calls required to
> obtain an API for a particular mailbox.
>
> - robert
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
>
>

Re: [MailboxManager] API Design

Posted by Stefano Bagnara <ap...@bago.org>.
Robert Burrell Donkin ha scritto:
> On Nov 2, 2007 12:54 AM, Stefano Bagnara <ap...@bago.org> wrote:
>> Robert Burrell Donkin ha scritto:
>>> the problem is that session is used in two different senses: database
>>> session and a session of a (session-oriented) protocol
>>>
>>> if you're using a transactional datastore then yes, you'll need a
>>> datastore session to execute transactions but there is no necessity
>>> for this to equal the MailboxAPI session
>> Maybe there are *3* different sessions: the protocol session (for POP3,
>> IMAP, SMTP), the mailboxapi session, the datastore session.
>> Or you are saying that the MailboxAPI session will be the same as (or 1
>> to 1 to) the protocols session?
> 
> it's not clearly defined how the MailboxAPI session relates to the
> protocol and database sessions
> 
> i've done a class diagram for the interfaces in MailboxAPI see
> http://wiki.apache.org/james/BackendMailboxAPI
> 
> IMO this is excessively complex
> 
> in particular:
> 
> * what is the difference between the various Mailbox interfaces and
> the various MailboxSession interfaces?
> * why are so many interfaces necessary?
> 
> - robert

AFAIK Joachim was comfortable with the "facets". I think the real
advantages of that many interfaces was that he was comfortable with them
and he was the only one working on the code, so this was a good advantage.

I'm fine with a simplification of the interfaces (reduce their number).

IMHO the diagram is not so complex. The complexity is in how the objects
are linked together and in the dependencies. It's been a long time since
I looked at IMAP code last time but IIRC each service depends on too
many of this interfaces to have a real gain from splitting the
interfaces so much. In the end there are really few users of the Mailbox
interface or the MailboxSession interface because most code directly
depend on GeneralMailboxSession.

I also agree that the fact that MailboxSession extends Mailbox is really
weird. Even if I don't know what are their responsibility I don't think
that a "Session of something" should extend "something". Maybe they
simply need a better name.

Stefano


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


Re: [MailboxManager] API Design

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On Nov 4, 2007 8:21 PM, Paulo Sergio <pa...@gmail.com> wrote:
> Hi all,

hi paulo

> i've been following the  discussion  and  i would like to give my opinion
> (although i'm not an expert).
> i think we are forgetting an important thing, we are designing an API
> thinking about the existent protocols, although i think we should think also
> in  what's next :) .
>
> In my case, i'm currently working in a web-service backend for james using
> IMAP as a "front end protocol". Now i would like to start working in a push
> mechanism, and i think about implementing IMAP Idle, i would have a server
> sending the notification to james server, witch then would send the
> notification to the client.
>
> Well, this is one of the problems i think james has (correct me if i'm
> wrong), it lacks any type of push mechanism.
> In my case the server could send a session id to james, indicating what
> client should retrieve the new mails, the problem would be to get the
> session of the user that should be notified..
>
>
> in my opinion i believe we should have some king of way of sending a
> notification/event to the mailbox or even  better to any session, these
> would be send by an external server (my case) or by events sent by james
> server (ex:  when a message is received, check if the user is connected and
> if it is send a notification to the session)

ATM the API allows mailbox listeners to be registered but the current
interfaces aren't great. a single method accepting an event is more
concise and extensible than including all calls in an interface.

IDLE was touched upon earlier. Zsombor suggested that listeners would
registered at the mailboxmanager level. if the API were switched to
use events then every listener could receive events for every mailbox
and then ignore any that were of no interest. novel events could be
injected into the system by the backend implementation. listeners
would ignore any events they did not understand.

would this mechanism be good enough?

another open question is whether an explicit API session would be a
useful to tie things together. something like a session would probably
be needed to reduce the number of factory method calls required to
obtain an API for a particular mailbox.

- robert

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


Re: [MailboxManager] API Design

Posted by Paulo Sergio <pa...@gmail.com>.
Hi all,
i've been following the  discussion  and  i would like to give my opinion
(although i'm not an expert).
i think we are forgetting an important thing, we are designing an API
thinking about the existent protocols, although i think we should think also
in  what's next :) .

In my case, i'm currently working in a web-service backend for james using
IMAP as a "front end protocol". Now i would like to start working in a push
mechanism, and i think about implementing IMAP Idle, i would have a server
sending the notification to james server, witch then would send the
notification to the client.

Well, this is one of the problems i think james has (correct me if i'm
wrong), it lacks any type of push mechanism.
In my case the server could send a session id to james, indicating what
client should retrieve the new mails, the problem would be to get the
session of the user that should be notified..


in my opinion i believe we should have some king of way of sending a
notification/event to the mailbox or even  better to any session, these
would be send by an external server (my case) or by events sent by james
server (ex:  when a message is received, check if the user is connected and
if it is send a notification to the session)

Cheers,
Paulo F.




On 11/4/07, Robert Burrell Donkin <ro...@gmail.com> wrote:
>
> On Nov 3, 2007 4:44 PM, Zsombor <gz...@gmail.com> wrote:
> > On 11/2/07, Robert Burrell Donkin < robertburrelldonkin@gmail.com>
> wrote:
> > >
> > > On Nov 2, 2007 12:54 AM, Stefano Bagnara <ap...@bago.org> wrote:
> > > > Robert Burrell Donkin ha scritto:
> > > > > the problem is that session is used in two different senses:
> database
> > > > > session and a session of a (session-oriented) protocol
> > > > >
> > > > > if you're using a transactional datastore then yes, you'll need a
> > > > > datastore session to execute transactions but there is no
> necessity
> > > > > for this to equal the MailboxAPI session
> > > >
> > > > Maybe there are *3* different sessions: the protocol session (for
> POP3,
> > > > IMAP, SMTP), the mailboxapi session, the datastore session.
> > > > Or you are saying that the MailboxAPI session will be the same as
> (or 1
> > > > to 1 to) the protocols session?
> > >
> > > it's not clearly defined how the MailboxAPI session relates to the
> > > protocol and database sessions
> > >
> > > i've done a class diagram for the interfaces in MailboxAPI see
> > > http://wiki.apache.org/james/BackendMailboxAPI
> > >
> > > IMO this is excessively complex
> >
> >
> > Yes, I feel the same pain :) And you skipped the drawing of lots of
> wrapper
> > classes :)
>
> IMHO the diagram was complex enough with just the interfaces :-)
>
> IMHO it would be simpler to factor the function in the wrappers into
> POJOs and use delegation
>
> i also left out the complex series of factory classes above
> MailboxManager. IMHO these would benefit from simplification.
>
> > in particular:
> > >
> > > * what is the difference between the various Mailbox interfaces and
> > > the various MailboxSession interfaces?
> > > * why are so many interfaces necessary?
> > >
> > > - robert
> >
> >
> >
> > I understand the reasoning behind the multiple interfaces - it tries to
> > group various separate feature which the IMAP frontend needs from the
> > backend (SearchableMailbox,FlaggedMailbox, etc) It is, i think a good
> thing,
>
> i call this type of thing 'facets'. i like facets but IMHO it's more
> usually to use facets to enable downcasting to discover whether a
> particular implementation supports that particular group of functions.
>
> however, the current API is inconsistent: it has monsters such as
> GeneralMailboxSession. IMHO it would be easier to comprehend the API
> if either the facets were eliminated or consistently extended.
>
> ATM the API has half-a-dozen ways of getting an interface for a
> mailbox scattered over several different interfaces. IMHO it's more
> natural if the facets are retained to have a single, canonical way of
> getting a basic mailbox  which can then be downcast to a facet.
>
> > the problem lies in the mixing the Mailbox and the MailboxSession and
> the
> > wrapping of the objects.
>
> +1
>
> plus the multiple factory classes
>
> > I'm not sure how to simplify the code, but I think,
> > if i were the original author I would done in the following way:
> >  The backend constitutes the following class/interfaces :
> > - MailboxName - it groups namespace,username,folder name
>
> +1
>
> > - MailboxListener - similar to the current MailboxListener interface
>
> IMHO it would be more flexible to unify the calls by using an event
>
> > - Mailbox - with add/remove/expunge/search/flag functionality (probably
> with
> > some IMAP specific methods for getting unseen/recent count), The object
> > should be stateless. For every MailboxName, it should be one Mailbox
> object
> > in the VM.
>
> +1
>
> > - MailboxManager - the entry point for the backend, with the following
> > methods:
> >    Mailbox getMailbox(MailboxName);
> >    void registerListener(MailboxName, MailboxListener)
> >    void unregisterListener(MailboxName, MailboxListener)
>
> i've been thinking about this and now wonder whether registration per
> mailbox is worthwhile. if the listener used events then the
> MailboxName could be obtained from a property. the listener could then
> ignore any events not of interest.
>
> stefano hopes to support transactions and that implies some concept of
> a session to tie operations together
>
> one of the current problems with IMAP is that the event feeding best
> when external events can be distinguished from events generated from
> operations performed by the current session so some concept of session
> sounds like it's required. if the event exposed the session which
> performed the operation then the listener would be free to ignore any
> generated by it's session.
>
> > The IMAP module should contain the MSN number, UID mappings, and the
> other
> > 'mailbox session' related codes, but probably names as
> Imap(Client)Session,
> > which is a MailboxListener also to get notification from other clients,
> and
> > from itself. So the implementation of the IDLE command would be easier.
> It
> > just set the 'session' object to 'forwardEveryMailboxChangeToClient'
> mode,
> > until it receives the 'DONE' command. And in that mode, every
> > MailboxListener method call results in an apropriate IDLE response line.
> >
> >  What do you think?
>
> sounds good :-)
>
> any other opinions?
>
> - robert
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
>
>

Re: [MailboxManager] API Design

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On Nov 3, 2007 4:44 PM, Zsombor <gz...@gmail.com> wrote:
> On 11/2/07, Robert Burrell Donkin < robertburrelldonkin@gmail.com> wrote:
> >
> > On Nov 2, 2007 12:54 AM, Stefano Bagnara <ap...@bago.org> wrote:
> > > Robert Burrell Donkin ha scritto:
> > > > the problem is that session is used in two different senses: database
> > > > session and a session of a (session-oriented) protocol
> > > >
> > > > if you're using a transactional datastore then yes, you'll need a
> > > > datastore session to execute transactions but there is no necessity
> > > > for this to equal the MailboxAPI session
> > >
> > > Maybe there are *3* different sessions: the protocol session (for POP3,
> > > IMAP, SMTP), the mailboxapi session, the datastore session.
> > > Or you are saying that the MailboxAPI session will be the same as (or 1
> > > to 1 to) the protocols session?
> >
> > it's not clearly defined how the MailboxAPI session relates to the
> > protocol and database sessions
> >
> > i've done a class diagram for the interfaces in MailboxAPI see
> > http://wiki.apache.org/james/BackendMailboxAPI
> >
> > IMO this is excessively complex
>
>
> Yes, I feel the same pain :) And you skipped the drawing of lots of wrapper
> classes :)

IMHO the diagram was complex enough with just the interfaces :-)

IMHO it would be simpler to factor the function in the wrappers into
POJOs and use delegation

i also left out the complex series of factory classes above
MailboxManager. IMHO these would benefit from simplification.

> in particular:
> >
> > * what is the difference between the various Mailbox interfaces and
> > the various MailboxSession interfaces?
> > * why are so many interfaces necessary?
> >
> > - robert
>
>
>
> I understand the reasoning behind the multiple interfaces - it tries to
> group various separate feature which the IMAP frontend needs from the
> backend (SearchableMailbox,FlaggedMailbox, etc) It is, i think a good thing,

i call this type of thing 'facets'. i like facets but IMHO it's more
usually to use facets to enable downcasting to discover whether a
particular implementation supports that particular group of functions.

however, the current API is inconsistent: it has monsters such as
GeneralMailboxSession. IMHO it would be easier to comprehend the API
if either the facets were eliminated or consistently extended.

ATM the API has half-a-dozen ways of getting an interface for a
mailbox scattered over several different interfaces. IMHO it's more
natural if the facets are retained to have a single, canonical way of
getting a basic mailbox  which can then be downcast to a facet.

> the problem lies in the mixing the Mailbox and the MailboxSession and the
> wrapping of the objects.

+1

plus the multiple factory classes

> I'm not sure how to simplify the code, but I think,
> if i were the original author I would done in the following way:
>  The backend constitutes the following class/interfaces :
> - MailboxName - it groups namespace,username,folder name

+1

> - MailboxListener - similar to the current MailboxListener interface

IMHO it would be more flexible to unify the calls by using an event

> - Mailbox - with add/remove/expunge/search/flag functionality (probably with
> some IMAP specific methods for getting unseen/recent count), The object
> should be stateless. For every MailboxName, it should be one Mailbox object
> in the VM.

+1

> - MailboxManager - the entry point for the backend, with the following
> methods:
>    Mailbox getMailbox(MailboxName);
>    void registerListener(MailboxName, MailboxListener)
>    void unregisterListener(MailboxName, MailboxListener)

i've been thinking about this and now wonder whether registration per
mailbox is worthwhile. if the listener used events then the
MailboxName could be obtained from a property. the listener could then
ignore any events not of interest.

stefano hopes to support transactions and that implies some concept of
a session to tie operations together

one of the current problems with IMAP is that the event feeding best
when external events can be distinguished from events generated from
operations performed by the current session so some concept of session
sounds like it's required. if the event exposed the session which
performed the operation then the listener would be free to ignore any
generated by it's session.

> The IMAP module should contain the MSN number, UID mappings, and the other
> 'mailbox session' related codes, but probably names as Imap(Client)Session,
> which is a MailboxListener also to get notification from other clients, and
> from itself. So the implementation of the IDLE command would be easier. It
> just set the 'session' object to 'forwardEveryMailboxChangeToClient' mode,
> until it receives the 'DONE' command. And in that mode, every
> MailboxListener method call results in an apropriate IDLE response line.
>
>  What do you think?

sounds good :-)

any other opinions?

- robert

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


Re: [MailboxManager] API Design

Posted by Zsombor <gz...@gmail.com>.
On 11/2/07, Robert Burrell Donkin < robertburrelldonkin@gmail.com> wrote:
>
> On Nov 2, 2007 12:54 AM, Stefano Bagnara <ap...@bago.org> wrote:
> > Robert Burrell Donkin ha scritto:
> > > the problem is that session is used in two different senses: database
> > > session and a session of a (session-oriented) protocol
> > >
> > > if you're using a transactional datastore then yes, you'll need a
> > > datastore session to execute transactions but there is no necessity
> > > for this to equal the MailboxAPI session
> >
> > Maybe there are *3* different sessions: the protocol session (for POP3,
> > IMAP, SMTP), the mailboxapi session, the datastore session.
> > Or you are saying that the MailboxAPI session will be the same as (or 1
> > to 1 to) the protocols session?
>
> it's not clearly defined how the MailboxAPI session relates to the
> protocol and database sessions
>
> i've done a class diagram for the interfaces in MailboxAPI see
> http://wiki.apache.org/james/BackendMailboxAPI
>
> IMO this is excessively complex


Yes, I feel the same pain :) And you skipped the drawing of lots of wrapper
classes :)


in particular:
>
> * what is the difference between the various Mailbox interfaces and
> the various MailboxSession interfaces?
> * why are so many interfaces necessary?
>
> - robert



I understand the reasoning behind the multiple interfaces - it tries to
group various separate feature which the IMAP frontend needs from the
backend (SearchableMailbox,FlaggedMailbox, etc) It is, i think a good thing,
the problem lies in the mixing the Mailbox and the MailboxSession and the
wrapping of the objects. I'm not sure how to simplify the code, but I think,
if i were the original author I would done in the following way:
 The backend constitutes the following class/interfaces :
- MailboxName - it groups namespace,username,folder name
- MailboxListener - similar to the current MailboxListener interface
- Mailbox - with add/remove/expunge/search/flag functionality (probably with
some IMAP specific methods for getting unseen/recent count), The object
should be stateless. For every MailboxName, it should be one Mailbox object
in the VM.
- MailboxManager - the entry point for the backend, with the following
methods:
   Mailbox getMailbox(MailboxName);
   void registerListener(MailboxName, MailboxListener)
   void unregisterListener(MailboxName, MailboxListener)
The IMAP module should contain the MSN number, UID mappings, and the other
'mailbox session' related codes, but probably names as Imap(Client)Session,
which is a MailboxListener also to get notification from other clients, and
from itself. So the implementation of the IDLE command would be easier. It
just set the 'session' object to 'forwardEveryMailboxChangeToClient' mode,
until it receives the 'DONE' command. And in that mode, every
MailboxListener method call results in an apropriate IDLE response line.

 What do you think?

Zsombor

Re: [MailboxManager] API Design

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On Nov 2, 2007 12:54 AM, Stefano Bagnara <ap...@bago.org> wrote:
> Robert Burrell Donkin ha scritto:
> > the problem is that session is used in two different senses: database
> > session and a session of a (session-oriented) protocol
> >
> > if you're using a transactional datastore then yes, you'll need a
> > datastore session to execute transactions but there is no necessity
> > for this to equal the MailboxAPI session
>
> Maybe there are *3* different sessions: the protocol session (for POP3,
> IMAP, SMTP), the mailboxapi session, the datastore session.
> Or you are saying that the MailboxAPI session will be the same as (or 1
> to 1 to) the protocols session?

it's not clearly defined how the MailboxAPI session relates to the
protocol and database sessions

i've done a class diagram for the interfaces in MailboxAPI see
http://wiki.apache.org/james/BackendMailboxAPI

IMO this is excessively complex

in particular:

* what is the difference between the various Mailbox interfaces and
the various MailboxSession interfaces?
* why are so many interfaces necessary?

- robert

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


Re: [MailboxManager] API Design

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On Nov 4, 2007 11:37 PM, Stefano Bagnara <ap...@bago.org> wrote:
> Robert Burrell Donkin ha scritto:
> > On Nov 2, 2007 12:54 AM, Stefano Bagnara <ap...@bago.org> wrote:
> >> Robert Burrell Donkin ha scritto:

<snip>

> >>>> Maybe the problem is that I don't know what the MailboxManager
> >>>> responsibility and API users are/will be so I don't know what layer of
> >>>> the architecture will be involved by this "API Design" thread.
> >>> i agree that this is the major problem: we need to understand the use
> >>> cases better
> >>>
> >>> - robert
> >> Maybe you are the one that better know both the implementations we
> >> currently have and the requirement for IMAP.
> >
> > Zsombor has made a start collecting requirements
> > http://wiki.apache.org/james/BackendMailboxAPI
>
> I don't see references about what I/O should be supported by the
> BackendMailboxAPI (BIO/NIO, SEDA/standard multithreaded). Had this been
> left out by purpose at the current level of analysis?

(this was touched on earlier)

a well design API should be able to cope with these different approaches

- robert

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


Re: [MailboxManager] API Design

Posted by Stefano Bagnara <ap...@bago.org>.
Robert Burrell Donkin ha scritto:
> On Nov 2, 2007 12:54 AM, Stefano Bagnara <ap...@bago.org> wrote:
>> Robert Burrell Donkin ha scritto:
>>> the problem is that session is used in two different senses: database
>>> session and a session of a (session-oriented) protocol
>>>
>>> if you're using a transactional datastore then yes, you'll need a
>>> datastore session to execute transactions but there is no necessity
>>> for this to equal the MailboxAPI session
>> Maybe there are *3* different sessions: the protocol session (for POP3,
>> IMAP, SMTP), the mailboxapi session, the datastore session.
>> Or you are saying that the MailboxAPI session will be the same as (or 1
>> to 1 to) the protocols session?
> 
> depends on the design. however, the MailboxAPI session is stored in
> the IMAP session. this is necessary since the MailboxAPI session is
> heavyweight (~1 second to create). for more protocols, creating a
> session for a limited number of operations makes no sense.

I'm happy for this response because now it's much more clear that I
misunderstood some your previous (old) messages. I was under the
impression that you wanted to go stateless for every operation in API
and I was worried about that "1 second" to be repeated for each
operation because there was no more a real session concept in the API.

>>>> Maybe the problem is that I don't know what the MailboxManager
>>>> responsibility and API users are/will be so I don't know what layer of
>>>> the architecture will be involved by this "API Design" thread.
>>> i agree that this is the major problem: we need to understand the use
>>> cases better
>>>
>>> - robert
>> Maybe you are the one that better know both the implementations we
>> currently have and the requirement for IMAP.
> 
> Zsombor has made a start collecting requirements
> http://wiki.apache.org/james/BackendMailboxAPI

I don't see references about what I/O should be supported by the
BackendMailboxAPI (BIO/NIO, SEDA/standard multithreaded). Had this been
left out by purpose at the current level of analysis?

>> Do you think we should evolve some of the currently existing api or do
>> you think it's better to start from scratch a new design?
> 
> people are already using the existing API so creating a new one from
> scratch would probably be unpopular. but a review (and simplification)
> is well overdue.
> 
> - robert

+1

Stefano


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


Re: [MailboxManager] API Design

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On Nov 2, 2007 12:54 AM, Stefano Bagnara <ap...@bago.org> wrote:
> Robert Burrell Donkin ha scritto:
> > the problem is that session is used in two different senses: database
> > session and a session of a (session-oriented) protocol
> >
> > if you're using a transactional datastore then yes, you'll need a
> > datastore session to execute transactions but there is no necessity
> > for this to equal the MailboxAPI session
>
> Maybe there are *3* different sessions: the protocol session (for POP3,
> IMAP, SMTP), the mailboxapi session, the datastore session.
> Or you are saying that the MailboxAPI session will be the same as (or 1
> to 1 to) the protocols session?

depends on the design. however, the MailboxAPI session is stored in
the IMAP session. this is necessary since the MailboxAPI session is
heavyweight (~1 second to create). for more protocols, creating a
session for a limited number of operations makes no sense.

> >> Maybe the problem is that I don't know what the MailboxManager
> >> responsibility and API users are/will be so I don't know what layer of
> >> the architecture will be involved by this "API Design" thread.
> >
> > i agree that this is the major problem: we need to understand the use
> > cases better
> >
> > - robert
>
> Maybe you are the one that better know both the implementations we
> currently have and the requirement for IMAP.

Zsombor has made a start collecting requirements
http://wiki.apache.org/james/BackendMailboxAPI

> Do you think we should evolve some of the currently existing api or do
> you think it's better to start from scratch a new design?

people are already using the existing API so creating a new one from
scratch would probably be unpopular. but a review (and simplification)
is well overdue.

- robert

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


Re: [MailboxManager] API Design

Posted by Stefano Bagnara <ap...@bago.org>.
Robert Burrell Donkin ha scritto:
> the problem is that session is used in two different senses: database
> session and a session of a (session-oriented) protocol
> 
> if you're using a transactional datastore then yes, you'll need a
> datastore session to execute transactions but there is no necessity
> for this to equal the MailboxAPI session

Maybe there are *3* different sessions: the protocol session (for POP3,
IMAP, SMTP), the mailboxapi session, the datastore session.
Or you are saying that the MailboxAPI session will be the same as (or 1
to 1 to) the protocols session?

>> Maybe the problem is that I don't know what the MailboxManager
>> responsibility and API users are/will be so I don't know what layer of
>> the architecture will be involved by this "API Design" thread.
> 
> i agree that this is the major problem: we need to understand the use
> cases better
> 
> - robert

Maybe you are the one that better know both the implementations we
currently have and the requirement for IMAP.

Do you think we should evolve some of the currently existing api or do
you think it's better to start from scratch a new design?

Stefano


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


Re: [MailboxManager] API Design

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On Oct 31, 2007 9:49 AM, Stefano Bagnara <ap...@bago.org> wrote:
> Robert Burrell Donkin ha scritto:
> > On Oct 30, 2007 2:16 PM, Stefano Bagnara <ap...@bago.org> wrote:
> >> Robert Burrell Donkin ha scritto:
> >>> for example, in the current API to perform an operation, it's
> >>> necessary to create a session. however, sessions are heavyweight:
> >>> performing extensive pre-emptive caching. this is fine when dealing
> >>> with heavyweight session oriented front ends but not so good for
> >>> lightweight front ends. IMAP is session oriented but this design
> >>> decision in the MailboxAPI results in poor performance for any calls
> >>> that do not run against the selected session.
> >> How do you handle transactions if you don't use a Session or a similar
> >> concept?
> >
> > there are various ways that transactions can be handled and a session
> > can mean many different things. equating transaction with session is
> > an error.
> >
> > IMAP opens a mailbox session and may well leave it open for 30 minutes
> > or more. if a transaction were associated with a session then this
> > would probably time out but (more importantly) it would no deliver the
> > correct semantics. commands are atomic and many can be issues within a
> > single session. the results of each command should be immediately
> > visible to all other users.
>
> I don't tell that a session should have a single transaction. It is
> possible to manage multiple transactions in a session. My question was
> how you manage transactions if you don't have a session at all.

the problem is that session is used in two different senses: database
session and a session of a (session-oriented) protocol

if you're using a transactional datastore then yes, you'll need a
datastore session to execute transactions but there is no necessity
for this to equal the MailboxAPI session

> >> IMHO one of the missing things in JAMES Server is transaction support.
> >> When a processor run a mail through a single step  (a mailet) it should
> >> either completely fail or completely succeed.
> >>
> >> How do you plan to support a simple LIST, RETR, DELE scenario without a
> >> session? The list gives you identifier that are valid only in that
> >> session, the following retr and the dele must use the same numbers.
> >>
> >> Are you simply saying that MailboxManager should be stateless and the
> >> session should be managed on top of this?
> >
> > a stateless Mailbox shared by many users would prevent confusion about
> > what a mailbox session really is
> >
> > explicit data store session and transaction management would at least
> > then be clear
> >
> > - robert
>
> Not sure I understand: so you tell we need a "data store session" that
> is something different from the IMAP session. Well, if so, I agree with it.

the question is whether MailboxAPI session should equal data store session

> Maybe the problem is that I don't know what the MailboxManager
> responsibility and API users are/will be so I don't know what layer of
> the architecture will be involved by this "API Design" thread.

i agree that this is the major problem: we need to understand the use
cases better

- robert

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


Re: [MailboxManager] API Design

Posted by Stefano Bagnara <ap...@bago.org>.
Robert Burrell Donkin ha scritto:
> On Oct 30, 2007 2:16 PM, Stefano Bagnara <ap...@bago.org> wrote:
>> Robert Burrell Donkin ha scritto:
>>> for example, in the current API to perform an operation, it's
>>> necessary to create a session. however, sessions are heavyweight:
>>> performing extensive pre-emptive caching. this is fine when dealing
>>> with heavyweight session oriented front ends but not so good for
>>> lightweight front ends. IMAP is session oriented but this design
>>> decision in the MailboxAPI results in poor performance for any calls
>>> that do not run against the selected session.
>> How do you handle transactions if you don't use a Session or a similar
>> concept?
> 
> there are various ways that transactions can be handled and a session
> can mean many different things. equating transaction with session is
> an error.
> 
> IMAP opens a mailbox session and may well leave it open for 30 minutes
> or more. if a transaction were associated with a session then this
> would probably time out but (more importantly) it would no deliver the
> correct semantics. commands are atomic and many can be issues within a
> single session. the results of each command should be immediately
> visible to all other users.

I don't tell that a session should have a single transaction. It is
possible to manage multiple transactions in a session. My question was
how you manage transactions if you don't have a session at all.

>> IMHO one of the missing things in JAMES Server is transaction support.
>> When a processor run a mail through a single step  (a mailet) it should
>> either completely fail or completely succeed.
>>
>> How do you plan to support a simple LIST, RETR, DELE scenario without a
>> session? The list gives you identifier that are valid only in that
>> session, the following retr and the dele must use the same numbers.
>>
>> Are you simply saying that MailboxManager should be stateless and the
>> session should be managed on top of this?
> 
> a stateless Mailbox shared by many users would prevent confusion about
> what a mailbox session really is
> 
> explicit data store session and transaction management would at least
> then be clear
> 
> - robert

Not sure I understand: so you tell we need a "data store session" that
is something different from the IMAP session. Well, if so, I agree with it.

Maybe the problem is that I don't know what the MailboxManager
responsibility and API users are/will be so I don't know what layer of
the architecture will be involved by this "API Design" thread.

Stefano


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


Re: [MailboxManager] API Design

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On Oct 30, 2007 2:16 PM, Stefano Bagnara <ap...@bago.org> wrote:
> Robert Burrell Donkin ha scritto:
> > for example, in the current API to perform an operation, it's
> > necessary to create a session. however, sessions are heavyweight:
> > performing extensive pre-emptive caching. this is fine when dealing
> > with heavyweight session oriented front ends but not so good for
> > lightweight front ends. IMAP is session oriented but this design
> > decision in the MailboxAPI results in poor performance for any calls
> > that do not run against the selected session.
>
> How do you handle transactions if you don't use a Session or a similar
> concept?

there are various ways that transactions can be handled and a session
can mean many different things. equating transaction with session is
an error.

IMAP opens a mailbox session and may well leave it open for 30 minutes
or more. if a transaction were associated with a session then this
would probably time out but (more importantly) it would no deliver the
correct semantics. commands are atomic and many can be issues within a
single session. the results of each command should be immediately
visible to all other users.

> IMHO one of the missing things in JAMES Server is transaction support.
> When a processor run a mail through a single step  (a mailet) it should
> either completely fail or completely succeed.
>
> How do you plan to support a simple LIST, RETR, DELE scenario without a
> session? The list gives you identifier that are valid only in that
> session, the following retr and the dele must use the same numbers.
>
> Are you simply saying that MailboxManager should be stateless and the
> session should be managed on top of this?

a stateless Mailbox shared by many users would prevent confusion about
what a mailbox session really is

explicit data store session and transaction management would at least
then be clear

- robert

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


Re: [MailboxManager] API Design

Posted by Stefano Bagnara <ap...@bago.org>.
Robert Burrell Donkin ha scritto:
> for example, in the current API to perform an operation, it's
> necessary to create a session. however, sessions are heavyweight:
> performing extensive pre-emptive caching. this is fine when dealing
> with heavyweight session oriented front ends but not so good for
> lightweight front ends. IMAP is session oriented but this design
> decision in the MailboxAPI results in poor performance for any calls
> that do not run against the selected session.

How do you handle transactions if you don't use a Session or a similar
concept?

IMHO one of the missing things in JAMES Server is transaction support.
When a processor run a mail through a single step  (a mailet) it should
either completely fail or completely succeed.

How do you plan to support a simple LIST, RETR, DELE scenario without a
session? The list gives you identifier that are valid only in that
session, the following retr and the dele must use the same numbers.

Are you simply saying that MailboxManager should be stateless and the
session should be managed on top of this?

Stefano


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


Re: [MailboxManager] API Design

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On Oct 30, 2007 10:50 AM, Zsombor <gz...@gmail.com> wrote:
> On 10/30/07, Robert Burrell Donkin <ro...@gmail.com> wrote:
> >
> > On 10/29/07, Zsombor <gz...@gmail.com> wrote:

<snip>

> >
> > +1
> >
> > > Ok, am I missed something?
> >
> > front ends :-)
> >
> > BIO verses NIO; mina verses excalibor; concurrent command processing
>
> You mean, we want a backend API with callbacks and j.u.c.Future-s ? It would
> be enormous rewrite, or we need a compatibility layer over it.

not right now ;-)

one of the more subtle issues i discovered is that there's a tendency
to focus on just on particular type of client for the API

for example, in the current API to perform an operation, it's
necessary to create a session. however, sessions are heavyweight:
performing extensive pre-emptive caching. this is fine when dealing
with heavyweight session oriented front ends but not so good for
lightweight front ends. IMAP is session oriented but this design
decision in the MailboxAPI results in poor performance for any calls
that do not run against the selected session.

then there's concurrency: how should the responsibility be split
between the API implementations and the call?

one requirement that is missing from the list and which is difficult
ATM are events (i think that this is missing from the list). IMAP
requires that the client is informed about changes that are made. so,
the MailboxAPI some way to push events out. (this is currently not
working very well and requires revision.)

> > Some important, or nice to have feature, which we
> > > want to support ? Any hidden protocol, which I've forgot ? Is there
> > other
> > > dreams about the future of James? :-) I know, from some of the features
> > are
> > > very far  from the current codebase - for example the clustered james
> > > deployment - others are simple matters of time, and interest - for
> > example
> > > the hierarchical db less backend.
> > >  Anyway, the main thing which I want to say, we should collect the
> > features,
> > > which we want to have,  and mark the features which we dont think it's
> > > important in the near, or far future. For example adding web-services to
> > > James, or to become an email specific JCR server (I'm not sure it is
> > > meaningful :) ), I think it's not so interesting/important, but probably
> > > others thinks other way.
> >
> > the cool thing about open source is that you never know when someone's
> > going to show up with an itch. if someone has the energy and skill to
> > add web services then i say: great :-)
> >
> > but i agree that we're probably going to duplicate effort and make
> > things harder if we don't organise some sort of reasonable list of
> > features. we can then highlight any architectural dependencies.
> >
> > >  My main preference is to have an easy deployable IMAP server, which
> > stores
> > > their data in a database, works over TLS or STARTTLS, and supports the
> > > mobile friendly IMAP extensions.
> >
> > storing mail in a JCR is my itch but i need to sort out the MailboxAPI
> > first
> >
> > (well, ok - actually replacing IMAP with a RESTful protocol is my long
> > term aim)
>
>
> Yes, that would be nice, but which email client will it support ? I don't
> want to write one just for this :-) But definitely it would be nice,to have
> one, with a nice web frontend :-)

define the protocol and they will come ;-)

but this is orthogonal - if the MailboxAPI is well design, this should
not introduce any new functions. yes, it will be internally stateless
but IMO the MailboxAPI should be able to cope with stateless protocols
as well as stateful ones.

- robert

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


Re: [MailboxManager] API Design

Posted by Zsombor <gz...@gmail.com>.
On 10/30/07, Robert Burrell Donkin <ro...@gmail.com> wrote:
>
> On 10/29/07, Zsombor <gz...@gmail.com> wrote:
>
> <snip>
>
> > It would be good, if we can start to collect the requirements for the
> > backend API, with the various protocols, which James currently supports,
> or
> > in the future supports.
>
> +1
>
> <snip>
>
> care to start a page on the wiki  (http://wiki.apache.org/james/) with
> the content?



Yes, i've added here: http://wiki.apache.org/james/BackendMailboxAPI


>
> +1
>
> > Ok, am I missed something?
>
> front ends :-)
>
> BIO verses NIO; mina verses excalibor; concurrent command processing



You mean, we want a backend API with callbacks and j.u.c.Future-s ? It would
be enormous rewrite, or we need a compatibility layer over it.


> Some important, or nice to have feature, which we
> > want to support ? Any hidden protocol, which I've forgot ? Is there
> other
> > dreams about the future of James? :-) I know, from some of the features
> are
> > very far  from the current codebase - for example the clustered james
> > deployment - others are simple matters of time, and interest - for
> example
> > the hierarchical db less backend.
> >  Anyway, the main thing which I want to say, we should collect the
> features,
> > which we want to have,  and mark the features which we dont think it's
> > important in the near, or far future. For example adding web-services to
> > James, or to become an email specific JCR server (I'm not sure it is
> > meaningful :) ), I think it's not so interesting/important, but probably
> > others thinks other way.
>
> the cool thing about open source is that you never know when someone's
> going to show up with an itch. if someone has the energy and skill to
> add web services then i say: great :-)
>
> but i agree that we're probably going to duplicate effort and make
> things harder if we don't organise some sort of reasonable list of
> features. we can then highlight any architectural dependencies.
>
> >  My main preference is to have an easy deployable IMAP server, which
> stores
> > their data in a database, works over TLS or STARTTLS, and supports the
> > mobile friendly IMAP extensions.
>
> storing mail in a JCR is my itch but i need to sort out the MailboxAPI
> first
>
> (well, ok - actually replacing IMAP with a RESTful protocol is my long
> term aim)


Yes, that would be nice, but which email client will it support ? I don't
want to write one just for this :-) But definitely it would be nice,to have
one, with a nice web frontend :-)




<snip>
>
> +1
>
> the mime4j pull parser comsumes less memory, is usually more
> performant (but could be much quicker) and is usually more accurate.
> since it's our source, we can fix bugs and optimise performance.
>
> - robert
>

Great !

BR,
Zsombor

Re: [MailboxManager] API Design

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On 10/29/07, Zsombor <gz...@gmail.com> wrote:

<snip>

> It would be good, if we can start to collect the requirements for the
> backend API, with the various protocols, which James currently supports, or
> in the future supports.

+1

<snip>

care to start a page on the wiki  (http://wiki.apache.org/james/) with
the content?

>   - custom properties for mail, the MIME structure is important, but some
> useful imap extensions needs others, for example CONDSTORE/QRESYNC as I
> remember needs a 'transaction number'.

i think that being able to associate meta-data would be good

> Other features, which we want to consider comes from the deployment
> scenarios :
>  - db only backend
>  - db for the metadata, file system for the data, in maildir/mbox/custom
> format
>  - db less backend, pure file system
>  - mixed backend (for example, the user mailbox are in a db, the shared,
> read only mailboxes are on the disk.
>  - jcr backend
>  - james servers in front of the same backend (probably db-only, or jcr)

+1

> Ok, am I missed something?

front ends :-)

BIO verses NIO; mina verses excalibor; concurrent command processing

> Some important, or nice to have feature, which we
> want to support ? Any hidden protocol, which I've forgot ? Is there other
> dreams about the future of James? :-) I know, from some of the features are
> very far  from the current codebase - for example the clustered james
> deployment - others are simple matters of time, and interest - for example
> the hierarchical db less backend.
>  Anyway, the main thing which I want to say, we should collect the features,
> which we want to have,  and mark the features which we dont think it's
> important in the near, or far future. For example adding web-services to
> James, or to become an email specific JCR server (I'm not sure it is
> meaningful :) ), I think it's not so interesting/important, but probably
> others thinks other way.

the cool thing about open source is that you never know when someone's
going to show up with an itch. if someone has the energy and skill to
add web services then i say: great :-)

but i agree that we're probably going to duplicate effort and make
things harder if we don't organise some sort of reasonable list of
features. we can then highlight any architectural dependencies.

>  My main preference is to have an easy deployable IMAP server, which stores
> their data in a database, works over TLS or STARTTLS, and supports the
> mobile friendly IMAP extensions.

storing mail in a JCR is my itch but i need to sort out the MailboxAPI first

(well, ok - actually replacing IMAP with a RESTful protocol is my long term aim)

<snip>

> i've been considering using Mime4J instead to allow generic
> > information to be obtained about the structure. this requires (as
> > jochen suggested) factoring out a suitable interface for the pull
> > parser. i hope that this would be good enough to allow backend
> > optimisation without coupling so strongly to IMAP.
>
>  I cant understand, why Mime4J is better than javax.mail to collect
> information about a mail message, and why it's better for the backend to use
> that one, but honestly I'm not too familiar in either of them. In my
> hibernate based backend, I was able to use MimeMessage, and worked fine.
>  If it's more performant - consumes less memory - than I'm with you, but I
> think if we can cache the resulting information in the backend, that it
> doesn't really matters :)

+1

the mime4j pull parser comsumes less memory, is usually more
performant (but could be much quicker) and is usually more accurate.
since it's our source, we can fix bugs and optimise performance.

- robert

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


Re: [MailboxManager] API Design

Posted by Zsombor <gz...@gmail.com>.
On 10/26/07, Robert Burrell Donkin <ro...@gmail.com> wrote:
>
> from https://issues.apache.org/jira/browse/JAMES-808
>
> > Currently the implementation of the FETCH command is not very efficient.
> For example to
> > retrieve one mail the following conversions will happens:
> > 1, the backend creates a MimeMessage from a file/database blob/thin
> air/etc
> > 2, the frontend converts into a byte array, with correct CRLF line
> endings. (I don't get, why it's
> > needed, every incoming MimeMessage is already in this format, isn't it
> ?)
> > 3, the frontend appends it into a StringBuffer in the FetchCommand class
> > 4, after some String manipulation it gets sent over an
> InternetPrintWriter which checks also that
> all line endings in correct style.
>
> this mess is the primary reason why the current implementation is
> unreasonably slow. i've been running alternative code on my local fork
> and the implementation is now quite enough to be usable.
>
> > I'm not sure that the whole thing is absolutly necessary.
>
> i'm sure that it is unnecessary
>
> IMHO the approach in JAMES-808 is the right one (adding more function
> and options to
> http://svn.apache.org/repos/asf/james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/MessageResult.java
> )
> but there are a few broader design issues around MailboxManager that
> i'd like to throw open for wider debate
>
> in terms of general API design, i tend to prefer to use subsidary
> objects to tie together data. so (for example) i prefer a Headers
> interfaces and a getHeaders method rather than adding three or four
> header related methods into the general API.
>
> AIUI MailboxManager was intended to be a general API without coupling
> to any particular protocol (please jump in if i have this wrong). if
> this is still a useful design requirement then we need to do something
> a little more sophisticated.
>
> in particular, the structure use cases are difficult. here, IMAP needs
> to know about the outline structure of a message: if it's a mime and
> if so, it's composition. JAMES-808 approaching this by returning
> protocol specific values coupling the API to IMAP.



It would be good, if we can start to collect the requirements for the
backend API, with the various protocols, which James currently supports, or
in the future supports.
- POP3 needs
  - 'username+password' -> 'inbox' mapping,
  - listing of the content of inbox, with subject only (?)
  - getting the content of an email by it's id
  - deleting messages from the inbox
-  SMTP needs
  - 'email address' -> 'mailbox' mapping
  - putting an email into the mailbox
- NNTP needs
   - ???? I don't know :)
-  Internal  James API needs  (spooling, fetchmail, etc):
  - handling various  'spool' 'mailbox'es, adding and removing items to
them.
- IMAP needs:
  - handle mail specific flags (Answered, Deleted, Draft, Flagged, Recent,
Seen...)
  - ability to search by various header parameters (From, Subject...), flags
  - handle mailbox hierarchy per user (this would be nice for JSieve also,
as I know)
  - shared/readonly mailboxes  (this is optional)
  - custom properties for mail, the MIME structure is important, but some
useful imap extensions needs others, for example CONDSTORE/QRESYNC as I
remember needs a 'transaction number'.

Other features, which we want to consider comes from the deployment
scenarios :
 - db only backend
 - db for the metadata, file system for the data, in maildir/mbox/custom
format
 - db less backend, pure file system
 - mixed backend (for example, the user mailbox are in a db, the shared,
read only mailboxes are on the disk.
 - jcr backend
 - james servers in front of the same backend (probably db-only, or jcr)

Ok, am I missed something? Some important, or nice to have feature, which we
want to support ? Any hidden protocol, which I've forgot ? Is there other
dreams about the future of James? :-) I know, from some of the features are
very far  from the current codebase - for example the clustered james
deployment - others are simple matters of time, and interest - for example
the hierarchical db less backend.
 Anyway, the main thing which I want to say, we should collect the features,
which we want to have,  and mark the features which we dont think it's
important in the near, or far future. For example adding web-services to
James, or to become an email specific JCR server (I'm not sure it is
meaningful :) ), I think it's not so interesting/important, but probably
others thinks other way.
 My main preference is to have an easy deployable IMAP server, which stores
their data in a database, works over TLS or STARTTLS, and supports the
mobile friendly IMAP extensions.




i've been considering using Mime4J instead to allow generic
> information to be obtained about the structure. this requires (as
> jochen suggested) factoring out a suitable interface for the pull
> parser. i hope that this would be good enough to allow backend
> optimisation without coupling so strongly to IMAP.



 I cant understand, why Mime4J is better than javax.mail to collect
information about a mail message, and why it's better for the backend to use
that one, but honestly I'm not too familiar in either of them. In my
hibernate based backend, I was able to use MimeMessage, and worked fine.
 If it's more performant - consumes less memory - than I'm with you, but I
think if we can cache the resulting information in the backend, that it
doesn't really matters :)

BR,
 Zsombor