1 17 18 package org.apache.james.transport.mailets; 19 20 import org.apache.mailet.GenericMailet; 21 import org.apache.mailet.Mail; 22 import org.apache.mailet.MailetException; 23 import java.io.Serializable ; 24 import java.util.Iterator ; 25 import java.util.HashMap ; 26 import java.util.Map ; 27 import java.util.Set ; 28 import javax.mail.MessagingException ; 29 30 42 public class SetMailAttribute extends GenericMailet { 43 44 private HashMap attributesToSet = new HashMap (2); 45 46 private Set entries; 47 48 53 public String getMailetInfo() { 54 return "Set Mail Attribute Mailet"; 55 } 56 57 62 public void init() throws MailetException 63 { 64 Iterator iter = getInitParameterNames(); 65 while (iter.hasNext()) { 66 String name = iter.next().toString(); 67 String value = getInitParameter (name); 68 attributesToSet.put (name,value); 69 } 70 entries = attributesToSet.entrySet(); 71 } 72 73 80 public void service(Mail mail) throws MessagingException { 81 if (entries != null) { 82 Iterator iter = entries.iterator(); 83 while (iter.hasNext()) { 84 Map.Entry entry = (Map.Entry )iter.next(); 85 mail.setAttribute ((String )entry.getKey(),(Serializable )entry.getValue()); 86 } 87 } 88 } 89 90 91 } 92 | Popular Tags |