[jboss-dev-forums] [Design of JBoss Collaboration Server] - MailListener api

Rudi Vankeirsbilck do-not-reply at jboss.com
Wed Oct 4 09:09:23 EDT 2006


I was looking into creating my own MailListener like:


  | public class BlueSpaceJBossMailListener extends BlueSpaceMessageDriveBean implements MailListener {
  | /* Methods for constructing new instances. */
  | 	public BlueSpaceJBossMailListener () {
  | 		super();
  | 	}
  | 
  | /* Methods that satisfy the MailListener interface. */
  | 	public Message send (Message message) throws MailException {
  | 		Logger.SMAIL.debug("Message received from JBoss Mail Server.");
  | 		Mail mail = (Mail) message;
  | 		Logger.SMAIL.debug("Subject:" + this.getSubject(mail));
  | 		Logger.SMAIL.debug("From:" + mail.getFrom().getRawAddress());
  | 		Logger.SMAIL.debug("Recipients:");
  | 		List<EnvelopedAddress> recipients = mail.getRecipients();
  | 		for (EnvelopedAddress address : recipients) {
  | 			Logger.SMAIL.debug (address.getType().toString() + ':' + address.getRawAddress());
  | 		  }
  | 		return message;
  | 	}
  | 
  | /* Keep out! */
  | /* Constants */
  | 	/* None at this time. */
  | 
  | 	protected String getSubject (Mail mail) {
  | 		String[] subjects = mail.getHeader("Subject");
  | 		if (subjects == null || subjects.length == 0) {
  | 			return null;
  | 		  }
  | 		else {
  | 			return subjects[0];
  | 		  }
  | 	}
  | 
  | /* Class variables */
  | 	/* None at this time. */
  | /* Instance variables */
  | 	/* None at this time. */
  | }
  | 

It's not doing anything usefull yet but anyways...

I was wondering why a org.jboss.mail.message.Message is being passed in instead of a org.jboss.mail.message.Mail.
Afterall, the interface is MailListener and not MessageListener and also the Message interface does not have any method so the Listener class has no other option then to cast it to something else.

This may be splitting hairs but this does not seem like a good API to me.

Any comments anybody?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3976015#3976015

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3976015



More information about the jboss-dev-forums mailing list