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


Java MessageUtils类代码示例

本文整理汇总了Java中org.apache.cxf.message.MessageUtils的典型用法代码示例。如果您正苦于以下问题:Java MessageUtils类的具体用法?Java MessageUtils怎么用?Java MessageUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MessageUtils类属于org.apache.cxf.message包,在下文中一共展示了MessageUtils类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeToOutputStream

import org.apache.cxf.message.MessageUtils; //导入依赖的package包/类
protected boolean writeToOutputStream(Message m, BindingInfo info, Service s) {
    /**
     * Yes, all this code is EXTREMELY ugly. But it gives about a 60-70% performance
     * boost with the JAXB RI, so its worth it. 
     */
    
    if (s == null) {
        return false;
    }
    
    String enc = (String)m.get(Message.ENCODING);
    return info.getClass().getName().equals("org.apache.cxf.binding.soap.model.SoapBindingInfo") 
        && s.getDataBinding().getClass().getName().equals("org.apache.cxf.jaxb.JAXBDataBinding")
        && !MessageUtils.isDOMPresent(m)
        && (enc == null || "UTF-8".equals(enc));
}
 
开发者ID:Huawei,项目名称:eSDK_EC_SDK_Java,代码行数:17,代码来源:AbstractOutDatabindingInterceptor.java

示例2: getDataWriter

import org.apache.cxf.message.MessageUtils; //导入依赖的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

示例3: setProperty

import org.apache.cxf.message.MessageUtils; //导入依赖的package包/类
public void setProperty(String prop, Object value) {
    if (prop.equals(JAXBDataBinding.UNWRAP_JAXB_ELEMENT)) {
        unwrapJAXBElement = Boolean.TRUE.equals(value);
    } else if (prop.equals(org.apache.cxf.message.Message.class.getName())) {
        org.apache.cxf.message.Message m = (org.apache.cxf.message.Message)value;
        veventHandler = (ValidationEventHandler)m.getContextualProperty("jaxb-validation-event-handler");
        if (veventHandler == null) {
            veventHandler = databinding.getValidationEventHandler();
        }
        setEventHandler = MessageUtils.getContextualBoolean(m, "set-jaxb-validation-event-handler", true);
        
        Object unwrapProperty = m.get(JAXBDataBinding.UNWRAP_JAXB_ELEMENT);
        if (unwrapProperty == null) {
            unwrapProperty = m.getExchange().get(JAXBDataBinding.UNWRAP_JAXB_ELEMENT);
        }
        if (unwrapProperty != null) {
            unwrapJAXBElement = Boolean.TRUE.equals(unwrapProperty);
        }
    }
}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:21,代码来源:DataReaderImpl.java

示例4: transferProtocolHeadersToURLConnection

import org.apache.cxf.message.MessageUtils; //导入依赖的package包/类
/**
 * This procedure sets the URLConnection request properties
 * from the PROTOCOL_HEADERS in the message.
 */
private void transferProtocolHeadersToURLConnection(URLConnection connection) {
    boolean addHeaders = MessageUtils.isTrue(
            message.getContextualProperty(ADD_HEADERS_PROPERTY));
    for (String header : headers.keySet()) {
        List<String> headerList = headers.get(header);
        if (HttpHeaderHelper.CONTENT_TYPE.equalsIgnoreCase(header)) {
            continue;
        }
        if (addHeaders || HttpHeaderHelper.COOKIE.equalsIgnoreCase(header)) {
            for (String s : headerList) {
                connection.addRequestProperty(header, s);
            }
        } else {
            StringBuilder b = new StringBuilder();
            for (int i = 0; i < headerList.size(); i++) {
                b.append(headerList.get(i));
                if (i + 1 < headerList.size()) {
                    b.append(',');
                }
            }
            connection.setRequestProperty(header, b.toString());
        }
    }
    // make sure we don't add more than one User-Agent header
    if (connection.getRequestProperty("User-Agent") == null) {
        connection.addRequestProperty("User-Agent", Version.getCompleteVersionString());
    }
}
 
开发者ID:Huawei,项目名称:eSDK_EC_SDK_Java,代码行数:33,代码来源:Headers.java

示例5: handleMessage

import org.apache.cxf.message.MessageUtils; //导入依赖的package包/类
@Override
public void handleMessage(SoapMessage msg) throws Fault {
    // noinspection ThrowableResultOfMethodCallIgnored
    Fault fault = ((Fault) msg.getContent(Exception.class));
    Throwable faultCause;

    if (((faultCause = fault.getCause()) == null) || !MessageUtils.getContextualBoolean(msg, WsPropertyNames.ERROR_STACK_TRACE, false)) {
        return;
    }

    Element faultDetailElem = fault.getOrCreateDetail();
    Document faultDetailDoc = faultDetailElem.getOwnerDocument();
    // noinspection ThrowableResultOfMethodCallIgnored
    ValidationException faultValidationCause = SdcctExceptionUtils.findCause(faultCause, ValidationException.class);

    if (faultValidationCause != null) {
        try {
            this.xmlCodec.encode(faultValidationCause.getResult(), new DOMResult(faultDetailElem), null);
        } catch (Exception e) {
            LOGGER.error("Unable to build SOAP Fault Detail validation result child element.", e);
        }
    }

    Element faultDetailStacktraceElem =
        faultDetailDoc.createElementNS(SdcctUris.SDCCT_WS_URN_VALUE, SdcctQnameUtils.buildQualifiedName(WsXmlQnames.STACK_TRACE));
    faultDetailStacktraceElem
        .appendChild(faultDetailDoc.createCDATASection((StringUtils.LF + SdcctExceptionUtils.buildRootCauseStackTrace(faultCause) + StringUtils.LF)));
    faultDetailElem.appendChild(faultDetailStacktraceElem);
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:30,代码来源:RfdSoapFaultInterceptor.java

示例6: hasNoResponseContent

import org.apache.cxf.message.MessageUtils; //导入依赖的package包/类
/**
 * Determines if the current message has no response content.
 * The message has no response content if either:
 * - the request is oneway and the current message is no partial
 * response or an empty partial response.
 * - the request is not oneway but the current message is an empty partial
 * response.
 *
 * @param message
 * @return
 */
private boolean hasNoResponseContent(Message message) {
    final boolean ow = isOneWay(message);
    final boolean pr = MessageUtils.isPartialResponse(message);
    final boolean epr = MessageUtils.isEmptyPartialResponse(message);

    //REVISIT may need to provide an option to choose other behavior?
    // old behavior not suppressing any responses  => ow && !pr
    // suppress empty responses for oneway calls   => ow && (!pr || epr)
    // suppress additionally empty responses for decoupled twoway calls =>
    return (ow && (!pr || epr)) || (!ow && epr);
}
 
开发者ID:claudemamo,项目名称:cxf-rt-transports-zeromq,代码行数:23,代码来源:ZMQDestination.java

示例7: doProcessResponse

import org.apache.cxf.message.MessageUtils; //导入依赖的package包/类
private boolean doProcessResponse(Message message) {
    // 1. Not oneWay
    if (!isOneway(message.getExchange())) {
        return true;
    }
    // 2. Context property
    return MessageUtils.getContextualBoolean(message, Message.PROCESS_ONEWAY_RESPONSE, false);
}
 
开发者ID:claudemamo,项目名称:cxf-rt-transports-zeromq,代码行数:9,代码来源:ZMQConduit.java

示例8: isRequestor

import org.apache.cxf.message.MessageUtils; //导入依赖的package包/类
@Deprecated
protected boolean isRequestor(Message message) {
    return MessageUtils.isRequestor(message);
}
 
开发者ID:Huawei,项目名称:eSDK_EC_SDK_Java,代码行数:5,代码来源:AbstractOutDatabindingInterceptor.java

示例9: setupConnection

import org.apache.cxf.message.MessageUtils; //导入依赖的package包/类
protected void setupConnection(Message message, Address address, HTTPClientPolicy csPolicy) throws IOException {
    HttpURLConnection connection = createConnection(message, address, csPolicy);
    // --add by jirunfang start
    CookieHandler.setDefault(null);
    // --add by jirunfang end
    connection.setDoOutput(true);       
    
    int ctimeout = determineConnectionTimeout(message, csPolicy);
    connection.setConnectTimeout(ctimeout);
    
    int rtimeout = determineReceiveTimeout(message, csPolicy);
    connection.setReadTimeout(rtimeout);
    
    connection.setUseCaches(false);
    // We implement redirects in this conduit. We do not
    // rely on the underlying URLConnection implementation
    // because of trust issues.
    connection.setInstanceFollowRedirects(false);

    // If the HTTP_REQUEST_METHOD is not set, the default is "POST".
    String httpRequestMethod = 
        (String)message.get(Message.HTTP_REQUEST_METHOD);
    if (httpRequestMethod == null) {
        httpRequestMethod = "POST";
        message.put(Message.HTTP_REQUEST_METHOD, "POST");
    }
    try {
        connection.setRequestMethod(httpRequestMethod);
    } catch (java.net.ProtocolException ex) {
        Object o = message.getContextualProperty(HTTPURL_CONNECTION_METHOD_REFLECTION);
        boolean b = DEFAULT_USE_REFLECTION;
        if (o != null) {
            b = MessageUtils.isTrue(o);
        }
        if (b) {
            try {
                java.lang.reflect.Field f = ReflectionUtil.getDeclaredField(HttpURLConnection.class, "method");
                ReflectionUtil.setAccessible(f).set(connection, httpRequestMethod);
                message.put(HTTPURL_CONNECTION_METHOD_REFLECTION, true);
            } catch (Throwable t) {
                t.printStackTrace();
                throw ex;
            }
        } else {
            throw ex;
        }
    }
    
    // We place the connection on the message to pick it up
    // in the WrappedOutputStream.
    message.put(KEY_HTTP_CONNECTION, connection);
    message.put(KEY_HTTP_CONNECTION_ADDRESS, address);
}
 
开发者ID:Huawei,项目名称:eSDK_EC_SDK_Java,代码行数:54,代码来源:URLConnectionHTTPConduit.java

示例10: toResponse

import org.apache.cxf.message.MessageUtils; //导入依赖的package包/类
@Override
public Response toResponse(Throwable exception) {
    SdcctHttpStatus respStatus = SdcctHttpStatus.INTERNAL_SERVER_ERROR;
    OperationOutcome opOutcome = null;

    if (exception instanceof FhirWsException) {
        FhirWsException wsException = ((FhirWsException) exception);

        respStatus = wsException.getResponseStatus();

        if (wsException.hasOperationOutcome()) {
            opOutcome = wsException.getOperationOutcome();
        }
    }

    if (opOutcome == null) {
        opOutcome = new OperationOutcomeBuilder().build();
    }

    // noinspection ThrowableResultOfMethodCallIgnored
    ValidationException validationCause = SdcctExceptionUtils.findCause(exception, ValidationException.class);

    if (validationCause != null) {
        for (ValidationIssue validationIssue : validationCause.getResult().getIssues().getIssues()) {
            opOutcome.addIssues(buildValidationIssueSource(buildValidationIssueDetails(new OperationOutcomeIssueBuilder()
                .setType(buildValidationIssueType(validationIssue.getType())).setSeverity(IssueSeverity.valueOf(validationIssue.getSeverity().name()))
                .setLocation(buildValidationLocation(validationIssue.getLocation()))
                .setDetails(OperationOutcomeType.MSG_ERROR_PARSING, validationIssue.getMessage()), validationIssue), validationIssue).build());
        }
    }

    if (!opOutcome.hasIssues()) {
        opOutcome.addIssues(new OperationOutcomeIssueBuilder().build());
    }

    if (MessageUtils.getContextualBoolean(JAXRSUtils.getCurrentMessage(), WsPropertyNames.ERROR_STACK_TRACE, false)) {
        try {
            opOutcome.setText(new NarrativeImpl()
                .setDiv(new DivImpl().addContent(new String(
                    this.xmlCodec.encode(new PreImpl().addContent(SdcctExceptionUtils.buildRootCauseStackTrace(exception)), null), StandardCharsets.UTF_8)))
                .setStatus(new NarrativeStatusComponentImpl().setValue(NarrativeStatus.ADDITIONAL)));
        } catch (Exception e) {
            LOGGER.error("Unable to encode FHIR operation outcome narrative.", e);
        }
    }

    return Response.status(respStatus).entity(opOutcome).build();
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:49,代码来源:FhirExceptionMapper.java

示例11: handle

import org.apache.cxf.message.MessageUtils; //导入依赖的package包/类
/** 
     * Determines the effective policy, and checks if one of its alternatives  
     * is supported.
     *  
     * @param message
     * @throws PolicyException if none of the alternatives is supported
     */
    protected void handle(Message message) {
        
        AssertionInfoMap aim = message.get(AssertionInfoMap.class);
        if (null == aim) {
            return;
        }

        Exchange exchange = message.getExchange();
        BindingOperationInfo boi = exchange.get(BindingOperationInfo.class);
        if (null == boi) {
            LOG.fine("No binding operation info.");
            return;
        }
        
        Endpoint e = exchange.get(Endpoint.class);
        if (null == e) {
            LOG.fine("No endpoint.");
            return;
        } 
        EndpointInfo ei = e.getEndpointInfo();

        Bus bus = exchange.get(Bus.class);
        PolicyEngine pe = bus.getExtension(PolicyEngine.class);
        if (null == pe) {
            return;
        }
        
        if (MessageUtils.isPartialResponse(message)) {
            LOG.fine("Not verifying policies on inbound partial response.");
            return;
        }
        
        getTransportAssertions(message);  
        
        EffectivePolicy effectivePolicy = message.get(EffectivePolicy.class);
        if (effectivePolicy == null) {
            if (MessageUtils.isRequestor(message)) {
                effectivePolicy = pe.getEffectiveClientResponsePolicy(ei, boi);
            } else {
                effectivePolicy = pe.getEffectiveServerRequestPolicy(ei, boi);
            }
        }
        try {
//            List<List<Assertion>> usedAlternatives = aim.checkEffectivePolicy(effectivePolicy.getPolicy());
//            if (usedAlternatives != null && !usedAlternatives.isEmpty() && message.getExchange() != null) {
//                message.getExchange().put("ws-policy.validated.alternatives", usedAlternatives);
//            }
        } catch (PolicyException ex) {
            //To check if there is ws addressing policy violation and throw WSA specific 
            //exception to pass jaxws2.2 tests
            if (ex.getMessage().indexOf("Addressing") > -1) {
                throw new Fault("A required header representing a Message Addressing Property " 
                                    + "is not present", LOG)
                    .setFaultCode(new QName("http://www.w3.org/2005/08/addressing", 
                                              "MessageAddressingHeaderRequired"));
            }
            throw ex;
        }
        LOG.fine("Verified policies for inbound message.");
    }
 
开发者ID:beemsoft,项目名称:techytax-zk,代码行数:68,代码来源:PolicyVerificationInInterceptor.java

示例12: shouldHandleMessage

import org.apache.cxf.message.MessageUtils; //导入依赖的package包/类
@Override
protected boolean shouldHandleMessage(Message message) {
	return MessageUtils.isRequestor(message);
}
 
开发者ID:tracee,项目名称:tracee,代码行数:5,代码来源:TraceeResponseInInterceptor.java

示例13: shouldHandleMessage

import org.apache.cxf.message.MessageUtils; //导入依赖的package包/类
@Override
protected boolean shouldHandleMessage(Message message) {
	return !MessageUtils.isRequestor(message);
}
 
开发者ID:tracee,项目名称:tracee,代码行数:5,代码来源:TraceeResponseOutInterceptor.java

示例14: complete

import org.apache.cxf.message.MessageUtils; //导入依赖的package包/类
/**
 * Called on completion of the MEP for which the Conduit was required.
 * 
 * @param exchange
 *            represents the completed MEP
 */
public void complete(Exchange exchange) {
	InvocationKey key = new InvocationKey(exchange);
	InvocationContext invocation = getInvocation(key);
	boolean failover = false;
	Conduit old = (Conduit) exchange.getOutMessage().remove(Conduit.class.getName());
	if (requiresFailover(exchange)) {
		onFailure(invocation.getContext());
		LOG.debug("Failover {}", invocation.getContext());
		Endpoint failoverTarget = getFailoverTarget(exchange, invocation);
		if (failoverTarget != null) {
			setEndpoint(failoverTarget);
			if (old != null) {
				old.close();
				conduits.remove(old);
			}
			failover = performFailover(exchange, invocation);
		}
	} else {
		if (invocation != null) {
			onSuccess(invocation.getContext());
		}
	}
	if (!failover) {
		LOG.debug("Failover not required");
		synchronized (this) {
			inProgress.remove(key);
		}
		if (MessageUtils.isTrue(exchange.get("KeepConduitAlive"))) {
			return;
		}

		try {
			if (exchange.getInMessage() != null) {
				Conduit c = (Conduit) exchange.getOutMessage().get(Conduit.class);
				if (c == null) {
					getSelectedConduit(exchange.getInMessage()).close(exchange.getInMessage());
				} else {
					c.close(exchange.getInMessage());
				}
			}
		} catch (IOException e) {
		}
	}
}
 
开发者ID:jaceko,项目名称:cxf-circuit-switcher,代码行数:51,代码来源:CircuitSwitcherTargetSelector.java


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