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


Java Message.put方法代码示例

本文整理汇总了Java中org.apache.cxf.message.Message.put方法的典型用法代码示例。如果您正苦于以下问题:Java Message.put方法的具体用法?Java Message.put怎么用?Java Message.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cxf.message.Message的用法示例。


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

示例1: sendErrorResponse

import org.apache.cxf.message.Message; //导入方法依赖的package包/类
private void sendErrorResponse(Message message, int responseCode) {
    Message outMessage = getOutMessage(message);
    outMessage.put(Message.RESPONSE_CODE, responseCode);
    
    // Set the response headers
    Map<String, List<String>> responseHeaders =
        (Map<String, List<String>>)message.get(Message.PROTOCOL_HEADERS);
    if (responseHeaders != null) {
        responseHeaders.put("WWW-Authenticate", Arrays.asList(new String[]{"Basic realm=realm"}));
        responseHeaders.put("Content-length", Arrays.asList(new String[]{"0"}));
    }
    message.getInterceptorChain().abort();
    try {
        getConduit(message).prepare(outMessage);
        close(outMessage);
    } catch (IOException e) {
    	log.error(e.getMessage()+"  "+ e.getCause());
    }
}
 
开发者ID:GovernIB,项目名称:sistra,代码行数:20,代码来源:BasicAuthAuthorizationInterceptor.java

示例2: handleValidation

import org.apache.cxf.message.Message; //导入方法依赖的package包/类
@Override
protected void handleValidation(final Message message, final Object resourceInstance, final Method method,
		final List<Object> arguments) {
	super.handleValidation(message, resourceInstance, method, arguments);

	// Check each parameter
	final Set<ConstraintViolation<?>> validationErrors = new HashSet<>();
	for (int index = 0; index < arguments.size(); index++) {
		final Parameter parameter = method.getParameters()[index];
		if (hasToBeValidated(parameter)) {
			// This parameter is a not context, path or query parameter
			validate(arguments.get(index), method, parameter, index, validationErrors);
		}
	}

	// Check the veto
	if (!validationErrors.isEmpty()) {
		message.put(FaultListener.class.getName(), new NoOpFaultListener());
		throw new ConstraintViolationException(validationErrors);
	}
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:22,代码来源:JAXRSBeanValidationImplicitInInterceptor.java

示例3: handleMessage

import org.apache.cxf.message.Message; //导入方法依赖的package包/类
@Override
public void handleMessage(Message message) throws Fault
{
    final OutputStream os = message.getContent(OutputStream.class);
    if (os == null)
    {
        return;
    }
    Logger logger = getMessageLogger(message);

    if (logger.isLoggable(Level.INFO) || writer != null)
    {
        // Write the output while caching it for the log message
        boolean hasLogged = message.containsKey(LOG_SETUP);
        if (!hasLogged)
        {
            message.put(LOG_SETUP, Boolean.TRUE);
            final CacheAndWriteOutputStream newOut = new CacheAndWriteOutputStream(
                    os);
            message.setContent(OutputStream.class, newOut);
            newOut.registerCallback(new LoggingCallback(logger, message, os));
        }
    }
}
 
开发者ID:Huawei,项目名称:eSDK_EC_SDK_Java,代码行数:25,代码来源:UCLoggingOutInterceptor.java

示例4: handleMessage

import org.apache.cxf.message.Message; //导入方法依赖的package包/类
@Override
public void handleMessage(final Message message) {
    Map<String, List<String>> headers = Maps.newHashMap();
    headers.put("oin-ondertekenaar", Collections.singletonList(oinBeheer));
    headers.put("oin-transporteur", Collections.singletonList(oinBeheer));
    message.put(Message.PROTOCOL_HEADERS, headers);
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:8,代码来源:OinHandler.java

示例5: propagateCamelToCxf

import org.apache.cxf.message.Message; //导入方法依赖的package包/类
/**
 * Propagates Camel headers to CXF message.
 *
 * @param strategy header filter strategy
 * @param headers Camel header
 * @param message CXF message
 * @param exchange provides context for filtering
 */
public static void propagateCamelToCxf(HeaderFilterStrategy strategy,
        Map<String, Object> headers, Message message, Exchange exchange) {

    Map<String, List<String>> cxfHeaders =
        CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS));

    if (cxfHeaders == null) {
        // use a treemap to keep ordering and ignore key case
        cxfHeaders = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
        message.put(Message.PROTOCOL_HEADERS, cxfHeaders);
    }

    for (Map.Entry<String, Object> entry : headers.entrySet()) {
        if (strategy != null
                && !strategy.applyFilterToCamelHeaders(entry.getKey(), entry.getValue(), exchange)) {

            if (Exchange.CONTENT_TYPE.equals(entry.getKey())) {
                message.put(Message.CONTENT_TYPE, entry.getValue());
            }
            if (Client.REQUEST_CONTEXT.equals(entry.getKey())
                || Client.RESPONSE_CONTEXT.equals(entry.getKey())
                || Message.RESPONSE_CODE.equals(entry.getKey())) {
                message.put(entry.getKey(), entry.getValue());
            } else {
                Object values = entry.getValue();
                if (values instanceof List<?>) {
                    cxfHeaders.put(entry.getKey(), CastUtils.cast((List<?>)values, String.class));
                } else {
                    List<String> listValue = new ArrayList<String>();
                    listValue.add(entry.getValue().toString());
                    cxfHeaders.put(entry.getKey(), listValue);
                }
            }
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:45,代码来源:CxfHeaderHelper.java

示例6: getSetProtocolHeaders

import org.apache.cxf.message.Message; //导入方法依赖的package包/类
/**
 * While extracting the Message.PROTOCOL_HEADERS property from the Message,
 * this call ensures that the Message.PROTOCOL_HEADERS property is
 * set on the Message. If it is not set, an empty map is placed there, and
 * then returned.
 * 
 * @param message The outbound message
 * @return The PROTOCOL_HEADERS map
 */
public static Map<String, List<String>> getSetProtocolHeaders(final Message message) {
    Map<String, List<String>> headers =
        CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS));        
    if (null == headers) {
        headers = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
    } else if (headers instanceof HashMap) {
        Map<String, List<String>> headers2 
            = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
        headers2.putAll(headers);
        headers = headers2;
    }
    message.put(Message.PROTOCOL_HEADERS, headers);
    return headers;
}
 
开发者ID:Huawei,项目名称:eSDK_EC_SDK_Java,代码行数:24,代码来源:Headers.java

示例7: createConnection

import org.apache.cxf.message.Message; //导入方法依赖的package包/类
private HttpURLConnection createConnection(Message message, Address address, HTTPClientPolicy csPolicy)
    throws IOException {
    URL url = address.getURL();
    URI uri = address.getURI();
    Proxy proxy = proxyFactory.createProxy(csPolicy , uri);
    message.put("http.scheme", uri.getScheme());
    // check tlsClientParameters from message header
    TLSClientParameters clientParameters = message.get(TLSClientParameters.class);
    if (clientParameters == null) {
        clientParameters = tlsClientParameters;
    }
    return connectionFactory.createConnection(clientParameters,
                                              proxy != null ? proxy : address.getDefaultProxy(), url);
}
 
开发者ID:Huawei,项目名称:eSDK_EC_SDK_Java,代码行数:15,代码来源:URLConnectionHTTPConduit.java

示例8: handleMessage

import org.apache.cxf.message.Message; //导入方法依赖的package包/类
public void handleMessage(Message message) throws Fault
{
    @SuppressWarnings("unchecked")
    Map<String, List<String>> headers = (Map<String, List<String>>) message
            .get(Message.PROTOCOL_HEADERS);
    if (headers == null)
    {
        headers = new HashMap<String, List<String>>();
    }

    try
    {
        if (null != ThreadLocalHolder.get() 
            && (null != ThreadLocalHolder.get().getEntities().get(InfoKeys.SDK_SESSION_ID.toString())))
        {
            headers.put(
                    "Set-Cookie",
                    Collections.singletonList("JSESSIONID="
                            + ThreadLocalHolder
                                    .get()
                                    .getEntities()
                                    .get(InfoKeys.SDK_SESSION_ID.toString())));
            message.put(Message.PROTOCOL_HEADERS, headers);
            
            ThreadLocalHolder.unset();
        }

    }
    catch (Exception e)
    {
        logger.error("", e);
        throw new Fault(e);
    }

}
 
开发者ID:Huawei,项目名称:eSDK_IVS_Java,代码行数:36,代码来源:IVSOutInterceptor.java

示例9: setSecurityContext

import org.apache.cxf.message.Message; //导入方法依赖的package包/类
protected void setSecurityContext(Message cxfMessage, final HttpServletRequest request) {
    cxfMessage.put(SecurityContext.class, new SecurityContext() {

        public Principal getUserPrincipal() {
            return request.getUserPrincipal();
        }

        @Override
        public boolean isUserInRole(String role) {
            return request.isUserInRole(role);
        }

    });
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:15,代码来源:DefaultCxfMessageMapper.java

示例10: handleMessage

import org.apache.cxf.message.Message; //导入方法依赖的package包/类
@Override
public void handleMessage(Message message) {
    final List<Object> arguments = MessageContentsList.getContentsList(message);
    if (!arguments.isEmpty()) {
        final Object instance = message.getExchange().get(Message.SERVICE_OBJECT);
        final Method method = (Method) message.get(METHOD_KEY);
        final ExecutableValidator methodValidator = validator.forExecutables();
        final Class<?>[] groups = Optional.ofNullable(method.getAnnotation(Groups.class)).map(Groups::value).orElse(DEFAULT_GROUPS);
        final Set<ConstraintViolation<Object>> violations = methodValidator.validateParameters(instance, method, arguments.toArray(), groups);
        if (!violations.isEmpty()) {
            message.put(FaultListener.class.getName(), new NoOpFaultListener());
            throw new JaxrsServerValidationException(violations);
        }
    }
}
 
开发者ID:Microbule,项目名称:microbule,代码行数:16,代码来源:ValidationInterceptor.java

示例11: filter

import org.apache.cxf.message.Message; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
    final Message message = JAXRSUtils.getCurrentMessage();
    final Exchange exchange = message.getExchange();
    final String methodName = String.valueOf(exchange.get(OPERATION_NAME_PROP));
    message.put(HTTPClientPolicy.class, policyMap.get(methodName));
}
 
开发者ID:Microbule,项目名称:microbule,代码行数:8,代码来源:TimeoutFilter.java

示例12: handleMessage

import org.apache.cxf.message.Message; //导入方法依赖的package包/类
@Override
public void handleMessage(final Message message) {
	message.put("enum.conversion.case.sensitive", Boolean.TRUE);
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:5,代码来源:CaseInsensitiveEnumInterceptor.java

示例13: handleMessage

import org.apache.cxf.message.Message; //导入方法依赖的package包/类
public void handleMessage(Message message)
    throws Fault
{
    @SuppressWarnings("unchecked")
    Map<String, List<String>> headers = (Map<String, List<String>>)message.get(Message.PROTOCOL_HEADERS);
    if (headers == null)
    {
        headers = new HashMap<String, List<String>>();
    }
    
    doInterfaceLog(message);
    
    String sessionId;
    try
    {
        if (null != ThreadLocalHolder.get())
        {
            sessionId = (String)ThreadLocalHolder.get().getEntities().get(InfoKeys.SDK_SESSION_ID.toString());
            
            headers.put("Set-Cookie", Collections.singletonList("JSESSIONID=" + sessionId));
            message.put(Message.PROTOCOL_HEADERS, headers);
            
            //将sessionId添加到soapHeader中
            String soapMethod = (String)ThreadLocalHolder.get().getEntities().get(InfoKeys.SDK_METHOD.toString());
            if (!StringUtils.isEmpty(soapMethod) && soapMethod.contains("getPublicKey"))
            {
                QName qname = new QName("sessionID");
                Document doc = DOMUtils.createDocument();
                Element root = doc.createElementNS("", "tns:sessionID");
                root.setTextContent(sessionId);
                SoapHeader head = new SoapHeader(qname, root);
                List<Header> headerss = ((SoapMessage)message).getHeaders();
                headerss.add(head);
            }
            ThreadLocalHolder.unset();
        }
    }
    catch (Exception e)
    {
        logger.error("", e);
        throw new Fault(e);
    }
}
 
开发者ID:Huawei,项目名称:eSDK_EC_SDK_Java,代码行数:44,代码来源:PlatformOutInterceptor.java

示例14: setupConnection

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

示例15: updateResponseHeaders

import org.apache.cxf.message.Message; //导入方法依赖的package包/类
protected void updateResponseHeaders(Message inMessage) {
    Headers h = new Headers(inMessage);
    h.readFromConnection(connection);
    inMessage.put(Message.CONTENT_TYPE, connection.getContentType());
    cookies.readFromHeaders(h);
}
 
开发者ID:Huawei,项目名称:eSDK_EC_SDK_Java,代码行数:7,代码来源:URLConnectionHTTPConduit.java


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