当前位置: 首页>>代码示例>>Java>>正文


Java Message.setAttachments方法代码示例

本文整理汇总了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;
}
 
开发者ID:Huawei,项目名称:eSDK_EC_SDK_Java,代码行数:18,代码来源:AbstractOutDatabindingInterceptor.java

示例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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:59,代码来源:CxfEndpoint.java


注:本文中的org.apache.cxf.message.Message.setAttachments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。