本文整理汇总了Java中org.apache.mailet.Mail.ERROR属性的典型用法代码示例。如果您正苦于以下问题:Java Mail.ERROR属性的具体用法?Java Mail.ERROR怎么用?Java Mail.ERROR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.mailet.Mail
的用法示例。
在下文中一共展示了Mail.ERROR属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkProcessors
/**
* Check if all needed Processors are configured and if not throw a
* {@link ConfigurationException}
*
* @throws ConfigurationException
*/
private void checkProcessors() throws ConfigurationException {
boolean errorProcessorFound = false;
boolean rootProcessorFound = false;
Iterator<String> names = processors.keySet().iterator();
while (names.hasNext()) {
String name = names.next();
if (name.equals(Mail.DEFAULT)) {
rootProcessorFound = true;
} else if (name.equals(Mail.ERROR)) {
errorProcessorFound = true;
}
if (errorProcessorFound && rootProcessorFound) {
return;
}
}
if (errorProcessorFound == false) {
throw new ConfigurationException("You need to configure a Processor with name " + Mail.ERROR);
} else if (rootProcessorFound == false) {
throw new ConfigurationException("You need to configure a Processor with name " + Mail.DEFAULT);
}
}
示例2: process
/**
* Call the wrapped mailet for the exchange
*/
@SuppressWarnings("unchecked")
public void process(Exchange exchange) throws Exception {
Mail mail = exchange.getIn().getBody(Mail.class);
long start = System.currentTimeMillis();
MessagingException ex = null;
try {
mailet.service(mail);
} catch (MessagingException me) {
ex = me;
String onMailetException = null;
MailetConfig mailetConfig = mailet.getMailetConfig();
if (mailetConfig instanceof MailetConfigImpl) {
onMailetException = ((MailetConfigImpl) mailetConfig).getInitAttribute("onMailetException");
}
if (onMailetException == null) {
onMailetException = Mail.ERROR;
} else {
onMailetException = onMailetException.trim().toLowerCase(Locale.US);
}
if (onMailetException.compareTo("ignore") == 0) {
// ignore the exception and continue
// this option should not be used if the mail object can be
// changed by the mailet
ProcessorUtil.verifyMailAddresses(mail.getRecipients());
} else {
ProcessorUtil.handleException(me, mail, mailet.getMailetConfig().getMailetName(), onMailetException, logger);
}
} finally {
List<MailetProcessorListener> listeners = processor.getListeners();
long complete = System.currentTimeMillis() - start;
for (int i = 0; i < listeners.size(); i++) {
MailetProcessorListener listener = listeners.get(i);
listener.afterMailet(mailet, mail.getName(), mail.getState(), complete, ex);
}
}
}