1 17 18 package org.apache.mailet; 19 20 import javax.mail.MessagingException ; 21 import java.util.Iterator ; 22 23 34 public abstract class GenericMailet implements Mailet, MailetConfig { 35 private MailetConfig config = null; 36 37 41 public void destroy() { 42 } 44 45 55 public String getInitParameter(String name) { 56 return config.getInitParameter(name); 57 } 58 59 70 public Iterator getInitParameterNames() { 71 return config.getInitParameterNames(); 72 } 73 74 79 public MailetConfig getMailetConfig() { 80 return config; 81 } 82 83 89 public MailetContext getMailetContext() { 90 return getMailetConfig().getMailetContext(); 91 } 92 93 100 public String getMailetInfo() { 101 return ""; 102 } 103 104 109 public String getMailetName() { 110 return config.getMailetName(); 111 } 112 113 114 127 public void init(MailetConfig newConfig) throws MessagingException { 128 config = newConfig; 129 init(); 130 } 131 132 143 public void init() throws MessagingException { 144 } 146 147 153 public void log(String message) { 154 StringBuffer logBuffer = 155 new StringBuffer (256) 156 .append(getMailetName()) 157 .append(": ") 158 .append(message); 159 getMailetContext().log(logBuffer.toString()); 160 } 161 162 169 public void log(String message, Throwable t) { 170 StringBuffer logBuffer = 171 new StringBuffer (256) 172 .append(config.getMailetName()) 173 .append(": ") 174 .append(message); 175 getMailetContext().log(logBuffer.toString(), t); 176 } 177 178 188 public abstract void service(Mail mail) throws javax.mail.MessagingException ; 189 } 190 191 192 | Popular Tags |