Federico Barbieri wrote:
> 
> 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 just looked at the mail servlet example that is listed in the docs and
it's blinding you: the while() loop we wrote was to identify the
operation of the servlet, but if you remove it you get the exact same
functionality.

On the other hand, I agree we should cleanup the spec and, for example,
add methods like

 getOutputStream(boolean append)

that would indicate if you want to append something, or start over
again.
 
> > 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?

Hmmmm, the above is still a filter.

 mail --> ufo cospiracy mail servlet -> untouched mail
                     |
                     v
                   signal

the signal is a log signal. If this logs gets forwarded as a mail
message, or stored into a database, this is _NOT_ of mail servlet
concern. This is a system dependend feature. Same thing happens in case


  mail -> james -> mail
            |
            V
      critical error

that is gets forwarded to your pager, nothing different.

So, instead of extending the Mail Servlet API, I'd write something like

   public class UFOCospiracyMailServlet 
     extends JamesSignalProducer 
     implements MailServlet
   {

  public void service(MailServletRequest req, MailServletResponse res) {
   res.copyMailFrom(req);
   InputStream in = req.getBody();
   if (findInStream(in, "aliens UFO cospiration")) {
     signal("UFO", req.getSender());
   }
 }    

that also allows you to "decouple" molder and schully from the
parameters of this servlet, which job is to filter a mail, not to send a
message!!!

Do I make sense?

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<[EMAIL PROTECTED]>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Come to the first official Apache Software Foundation Conference!  
------------------------- http://ApacheCon.Com ---------------------




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

Reply via email to