当前位置: 首页>>代码示例>>Java>>正文


Java Mail.ERROR属性代码示例

本文整理汇总了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);
    }
}
 
开发者ID:twachan,项目名称:James,代码行数:28,代码来源:AbstractStateCompositeProcessor.java

示例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);
        }
    }
}
 
开发者ID:twachan,项目名称:James,代码行数:41,代码来源:CamelProcessor.java


注:本文中的org.apache.mailet.Mail.ERROR属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。