本文整理匯總了Java中org.apache.cxf.message.Message.getAttachments方法的典型用法代碼示例。如果您正苦於以下問題:Java Message.getAttachments方法的具體用法?Java Message.getAttachments怎麽用?Java Message.getAttachments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.cxf.message.Message
的用法示例。
在下文中一共展示了Message.getAttachments方法的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: populateExchangeFromCxfResponse
import org.apache.cxf.message.Message; //導入方法依賴的package包/類
/**
* This method is called by {@link CxfProducer#process(Exchange)}. It propagates
* information from CXF Exchange to Camel Exchange. The CXF Exchange contains a
* request from a CXF server.
*/
public void populateExchangeFromCxfResponse(Exchange camelExchange,
org.apache.cxf.message.Exchange cxfExchange,
Map<String, Object> responseContext) {
Message cxfMessage = cxfExchange.getInMessage();
// Need to check if the inMessage is set
if (cxfMessage == null) {
return;
}
LOG.trace("Populate exchange from CXF response message: {}", cxfMessage);
// copy the InMessage header to OutMessage header
camelExchange.getOut().getHeaders().putAll(camelExchange.getIn().getHeaders());
// propagate body
String encoding = (String)camelExchange.getProperty(Exchange.CHARSET_NAME);
camelExchange.getOut().setBody(DefaultCxfBinding.getContentFromCxf(cxfMessage,
camelExchange.getProperty(CxfConstants.DATA_FORMAT_PROPERTY, DataFormat.class), encoding));
// propagate response context
if (responseContext != null && responseContext.size() > 0) {
if (!headerFilterStrategy.applyFilterToExternalHeaders(Client.RESPONSE_CONTEXT,
responseContext, camelExchange)) {
camelExchange.getOut().setHeader(Client.RESPONSE_CONTEXT, responseContext);
LOG.trace("Set header = {} value = {}", Client.RESPONSE_CONTEXT, responseContext);
}
}
// propagate protocol headers
propagateHeadersFromCxfToCamel(cxfMessage, camelExchange.getOut(), camelExchange);
DataFormat dataFormat = camelExchange.getProperty(CxfConstants.DATA_FORMAT_PROPERTY,
DataFormat.class);
boolean isXop = Boolean.valueOf(camelExchange.getProperty(Message.MTOM_ENABLED, String.class));
// propagate attachments
if (cxfMessage.getAttachments() != null) {
// propagate attachments
for (Attachment attachment : cxfMessage.getAttachments()) {
camelExchange.getOut().addAttachment(attachment.getId(), attachment.getDataHandler());
}
}
}