Java 类org.springframework.core.AttributeAccessor 实例源码

项目:spring-cloud-stream    文件:DefaultPollableMessageSource.java   
/**
 * If there's a retry template, it will set the attributes holder via the listener. If
 * there's no retry template, but there's an error channel, we create a new attributes
 * holder here. If an attributes holder exists (by either method), we set the
 * attributes for use by the {@link ErrorMessageStrategy}.
 * @param message the Spring Messaging message to use.
 */
private void setAttributesIfNecessary(Message<?> message) {
    boolean needHolder = this.errorChannel != null && this.retryTemplate == null;
    boolean needAttributes = needHolder || this.retryTemplate != null;
    if (needHolder) {
        attributesHolder.set(ErrorMessageUtils.getAttributeAccessor(null, null));
    }
    if (needAttributes) {
        AttributeAccessor attributes = attributesHolder.get();
        if (attributes != null) {
            attributes.setAttribute(ErrorMessageUtils.INPUT_MESSAGE_CONTEXT_KEY, message);
            if (this.attributesProvider != null) {
                this.attributesProvider.accept(attributes, message);
            }
        }
    }
}
项目:spring-cloud-stream    文件:DefaultPollableMessageSource.java   
public void setAttributesProvider(BiConsumer<AttributeAccessor, Message<?>> attributesProvider) {
    this.attributesProvider = attributesProvider;
}