本文整理汇总了Java中org.apache.cxf.message.Message.setAttachments方法的典型用法代码示例。如果您正苦于以下问题:Java Message.setAttachments方法的具体用法?Java Message.setAttachments怎么用?Java Message.setAttachments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cxf.message.Message
的用法示例。
在下文中一共展示了Message.setAttachments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDataWriter
import org.apache.cxf.message.Message; //导入方法依赖的package包/类
protected <T> DataWriter<T> getDataWriter(Message message, Service service, Class<T> output) {
DataWriter<T> writer = service.getDataBinding().createWriter(output);
Collection<Attachment> atts = message.getAttachments();
if (MessageUtils.isTrue(message.getContextualProperty(Message.MTOM_ENABLED))
&& atts == null) {
atts = new ArrayList<Attachment>();
message.setAttachments(atts);
}
writer.setAttachments(atts);
writer.setProperty(DataWriter.ENDPOINT, message.getExchange().getEndpoint());
writer.setProperty(Message.class.getName(), message);
setDataWriterValidation(service, message, writer);
return writer;
}
示例2: setParameters
import org.apache.cxf.message.Message; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void setParameters(Object[] params, Message message) {
Object attachments = message.get(CxfConstants.CAMEL_CXF_ATTACHMENTS);
if (attachments != null) {
message.setAttachments((Collection<Attachment>) attachments);
message.remove(CxfConstants.CAMEL_CXF_ATTACHMENTS);
}
// Don't try to reset the parameters if the parameter is not CxfPayload instance
// as the setParameter will be called more than once when using the fail over feature
if (DataFormat.PAYLOAD == message.get(DataFormat.class) && params[0] instanceof CxfPayload) {
CxfPayload<?> payload = (CxfPayload<?>) params[0];
List<Source> elements = payload.getBodySources();
BindingOperationInfo boi = message.get(BindingOperationInfo.class);
MessageContentsList content = new MessageContentsList();
int i = 0;
for (MessagePartInfo partInfo : boi.getInput().getMessageParts()) {
if (elements.size() > i) {
if (isSkipPayloadMessagePartCheck()) {
content.put(partInfo, elements.get(i++));
} else {
String name = findName(elements, i);
if (partInfo.getConcreteName().getLocalPart().equals(name)) {
content.put(partInfo, elements.get(i++));
}
}
}
}
if (elements != null && content.size() < elements.size()) {
throw new IllegalArgumentException("The PayLoad elements cannot fit with the message parts of the BindingOperation. Please check the BindingOperation and PayLoadMessage.");
}
message.setContent(List.class, content);
// merge header list from request context with header list from CXF payload
List<Object> headerListOfRequestContxt = (List<Object>)message.get(Header.HEADER_LIST);
List<Object> headerListOfPayload = CastUtils.cast(payload.getHeaders());
if (headerListOfRequestContxt == headerListOfPayload) {
// == is correct, we want to compare the object instances
// nothing to do, this can happen when the CXF payload is already created in the from-cxf-endpoint and then forwarded to a to-cxf-endpoint
} else {
if (headerListOfRequestContxt == null) {
message.put(Header.HEADER_LIST, payload.getHeaders());
} else {
headerListOfRequestContxt.addAll(headerListOfPayload);
}
}
} else {
super.setParameters(params, message);
}
message.remove(DataFormat.class);
}