Version 3

    Mail Listener refactoring

     

    Presently every mail listener in the chain gets EVERY message and is supposed to get an immutable copy.  Meaning:

     

                      <!-- mail-listeners: can match any number of jmx or classpath mail listeners.
                           be sure to prefix with either jmx: or class: -->
                      <property><name>mail-listeners</name>
                                <values>
                                     <value>jboss.mail:type=MailServices,name=MailListJMSListener</value>
                                     <value>jboss.mail:type=MailServices,name=MailListener</value>
                                </values>
                      </property>
    

     

    Both MailListJMSListener would recieve EVERY mail and MailListener would receive every mail.  Thus if both mail listeners sent the mail to a user, he'd get two copies of every mail.  The code looks something like this:

     

    Mail mymail = themail;
    Iterator i = listeners.iterator();
    while(i.hasNext()) {
     Listener l = (MailListener)i.next();
     l.send(mymail.copy());
    }
    

     

    Instead it should look like this:

     

    Mail mymail = themail;
    Iterator i = listeners.iterator();
    while(i.hasNext() && (mymail != null) ) {
     Listener l = (MailListener)i.next();
     mymail = l.send(mymail);
    }
    

     

    Thus the mail listeners work in a chain and might even change the mail.  If the mail could be delivered via the first mail listener (MailListJMSListener) then it would not be delivered via the second (MailListener).

     

    There should however be a special mail listener PeerMailListener which would be configured with a list of mail listeners and work in the old manner.  Meaning if SMTPProtocol was configured like this:

     

     

                      <!-- mail-listeners: can match any number of jmx or classpath mail listeners.
                           be sure to prefix with either jmx: or class: -->
                      <property><name>mail-listeners</name>
                                <values>
                                     <value>jboss.mail:type=MailServices,name=PeerMailListener</value>
                                </values>
                      </property>
    

     

    And the Peer mail listener was configured like this:

     

                      <!-- mail-listeners: can match any number of jmx or classpath mail listeners.
                           be sure to prefix with either jmx: or class: -->
                      <property><name>mail-listeners</name>
                                <values>
                                     <value>jboss.mail:type=MailServices,name=MailListJMSListener</value>
                                     <value>jboss.mail:type=MailServices,name=MailListener</value>
                                </values>
                      </property>
    

     

    Then it would work the way it does presently.  Meaning every maillistener would get every message.