org.apache.mailet.Mail.removeAttribute()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(94)

本文整理了Java中org.apache.mailet.Mail.removeAttribute()方法的一些代码示例,展示了Mail.removeAttribute()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mail.removeAttribute()方法的具体详情如下:
包路径:org.apache.mailet.Mail
类名称:Mail
方法名:removeAttribute

Mail.removeAttribute介绍

[英]Removes the attribute with the given name from this Mail instance.
[中]从此邮件实例中删除具有给定名称的属性。

代码示例

代码示例来源:origin: org.apache.james/james-server-mailetcontainer-camel

@Override
  public boolean matches(Exchange arg0) {
    Mail m = arg0.getIn().getBody(Mail.class);
    return m.removeAttribute(MatcherSplitter.MATCHER_MATCHED_ATTRIBUTE) != null;
  }
}

代码示例来源:origin: org.apache.james/apache-standard-mailets

/**
 * Remove the configured attributes
 *
 * @param mail the mail to process
 *
 * @throws MessagingException in all cases
 */
public void service(Mail mail) throws MessagingException {
  Iterator<String> iter = attributesToRemove.iterator();
  while (iter.hasNext()) {
    String attribute_name = iter.next().toString();
    mail.removeAttribute (attribute_name);
  }
}

代码示例来源:origin: org.apache.james/james-server-mailetcontainer-camel

private void handleMailet(Exchange exchange, CamelMailetProcessor container, CamelProcessor mailetProccessor) throws Exception {
  Mail mail = exchange.getIn().getBody(Mail.class);
  boolean isMatched = mail.removeAttribute(MatcherSplitter.MATCHER_MATCHED_ATTRIBUTE) != null;
  if (isMatched) {
    mailetProccessor.process(mail);
  }
  if (mail.getState().equals(Mail.GHOST)) {
    dispose(exchange, mail);
    return;
  }
  if (!mail.getState().equals(container.getState())) {
    container.toProcessor(mail);
    complete(exchange, container);
  }
}

代码示例来源:origin: apache/james-project

@Test
void removeAttributeShouldReturnPreviousValue() {
  Mail mail = newMail();
  mail.setAttribute(KEY, VALUE);
  Serializable previous = mail.removeAttribute(KEY);
  assertThat(previous).isEqualTo(VALUE);
}

代码示例来源:origin: apache/james-project

@Test
void removeAttributeShouldReturnNullWhenNoPreviousValue() {
  Mail mail = newMail();
  Serializable previous = mail.removeAttribute(KEY);
  assertThat(previous).isNull();
}

代码示例来源:origin: org.apache.james/james-server-queue-activemq

@Override
public void done(boolean success) throws MailQueueException {
  super.done(success);
  if (success) {
    if (message instanceof ActiveMQBlobMessage && getMail().getAttribute(JAMES_REUSE_BLOB_URL) == null) {
      // This should get removed once this jira issue was fixed
      // https://issues.apache.org/activemq/browse/AMQ-1529
      try {
        ((ActiveMQBlobMessage) message).deleteFile();
      } catch (IOException | JMSException e) {
        LOGGER.warn("Unable to delete blob message file for mail {}", getMail().getName());
      }
    }
    getMail().removeAttribute(JAMES_REUSE_BLOB_URL);
  }
}

代码示例来源:origin: org.apache.james/james-server-mailets

public void service(Mail mail) throws MessagingException {
  if (mail.getAttribute(MARKER) != null) {
    mail.removeAttribute(MARKER);
    return;

代码示例来源:origin: apache/james-project

@Test
void getAttributeShouldNotReturnedNotStoreRemovedItems() {
  Mail mail = newMail();
  mail.removeAttribute(KEY);
  assertThat(mail.getAttribute(KEY)).isNull();
}

代码示例来源:origin: apache/james-project

@Test
void getAttributeShouldNotReturnDeletedElements() {
  Mail mail = newMail();
  mail.setAttribute(KEY, VALUE);
  mail.removeAttribute(KEY);
  assertThat(mail.getAttribute(KEY)).isNull();
}

代码示例来源:origin: apache/james-project

@Test
void shouldBeRemovable() {
  SoftAssertions.assertSoftly(
    softly -> {
      softly.assertThat(mail.removeAttribute(ATTRIBUTE_NAME_1)).contains(ATTRIBUTE_1);
      softly.assertThat(mail.getAttribute(ATTRIBUTE_NAME_1)).isEmpty();
    }
  );
}

相关文章