Serge Knystautas wrote:
> 
> Federico,
> 
> Glad to see you're actively working on James.  I should be leaving for a
> meeting now, but here are my quick 2 cents:  My approach was designed on
> the assumption that 90%-95% of the time, you're not making a significant
> change to the email message (if any)... you're changing a header,
> rerouting this message, etc...  My approach was more a mail filter than
> a request/response system (which I had trouble when I started
> considering usages of this).

Take a look at Pier and Stefano Mail Servlet draft. I't very elegant and
incredibly simple to use. It lacks of some smart way to clone the body
into the response without pain but that's not so difficult.

> 
> I *agree* it would be nice to support forking messages, but I never was
> happy with anything that supported this approach because then most of
> the time, it's a pain... do you have a Vector or array of response
> messages?  I'm thinking the best way we can do this is to offer a
> convenient clone () method (either called directly on the Message object
> or through the message queue handler).  You could clone the message,
> make whatever modifications to the new fork you want, and have it
> properly go into the message queue in an identical situation as the
> other.  Reasonable?
> 

Quite agree:

I like the idea of a MailServletequest and MailServletResponse since
this patter is really evident and well known. But since this do not
allow forking... consider this:

    public void service(MailServletRequest req, MailServletResponse res) 

MailServletRequest gives you methods to easily access routing info,
headers and read body
MailServletResponse has some methods like
copyBodyFrom(MailServletRequest req) and copyMailFrom(MailServletRequest
req) etc to make easy and painless duplication of messages.

This is just a filter and do not allw forking.

Adding to the AbstractMailServlet a method like
        MailServletResponse getNewMailServletResponse()

gives the mailServlet the ability if necessary to fork a message while
should not make 
criptic the use if just a filtering is needed. 

some example...

<processor match="[*]" class="Find">
    <find> aliens UFO cospiration </find>
    <action> mailto:[EMAIL PROTECTED] </action>
    <action> mailto:[EMAIL PROTECTED] </action>
</processor>

IMPLEMENTATION

public void service(MailServletRequest req, MailServletResponse res) {
  res.copyMailFrom(req);
  InputStream in = req.getBody();
  if (findInStream(in, "aliens UFO cospiration")) {
    MailServletResponse alarm = this.getNewMailServletResponse();
    alarm.setSender("james@myhost");
    alarm.copyMailAsAttachment(req);
    alarm.setSubject("alarm");
    this.send(alarm);
  }
}

while a simple MailingListServlet...

public void service(MailServletRequest req, MailServletResponse res) {
  res.copyMailFrom(req);
  res.setRecipients(thisListRecipients);
}

Sounds good to you?

Federico

*-----------------------------------*
 "Troubles occurr when two people try 
 to be intelligent in the same time."
    - Murphy
*-----------------------------------*




------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/>
Problems?:           [EMAIL PROTECTED]

Reply via email to