下面列出了怎么用org.springframework.core.AttributeAccessor的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* 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);
}
}
}
}
public void setAttributesProvider(
BiConsumer<AttributeAccessor, Message<?>> attributesProvider) {
this.attributesProvider = attributesProvider;
}