當前位置: 首頁>>代碼示例>>Java>>正文


Java Message.getContent方法代碼示例

本文整理匯總了Java中org.apache.cxf.message.Message.getContent方法的典型用法代碼示例。如果您正苦於以下問題:Java Message.getContent方法的具體用法?Java Message.getContent怎麽用?Java Message.getContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.cxf.message.Message的用法示例。


在下文中一共展示了Message.getContent方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: decryptContent

import org.apache.cxf.message.Message; //導入方法依賴的package包/類
public static void decryptContent( SecurityManager securityManager, Message message, String hostIdSource,
                                   String hostIdTarget )
{

    InputStream is = message.getContent( InputStream.class );

    CachedOutputStream os = new CachedOutputStream();

    LOG.debug( String.format( "Decrypting IDs: %s -> %s", hostIdSource, hostIdTarget ) );
    try
    {
        int copied = IOUtils.copyAndCloseInput( is, os );
        os.flush();

        byte[] data = copied > 0 ? decryptData( securityManager, hostIdSource, os.getBytes() ) : null;
        org.apache.commons.io.IOUtils.closeQuietly( os );

        if ( !ArrayUtils.isEmpty( data ) )
        {
            LOG.debug( String.format( "Decrypted payload: \"%s\"", new String( data ) ) );
            message.setContent( InputStream.class, new ByteArrayInputStream( data ) );
        }
        else
        {
            LOG.debug( "Decrypted data is NULL!!!" );
        }
    }
    catch ( Exception e )
    {
        LOG.error( "Error decrypting content", e );
    }
}
 
開發者ID:subutai-io,項目名稱:base,代碼行數:33,代碼來源:MessageContentUtil.java

示例3: handleMessage

import org.apache.cxf.message.Message; //導入方法依賴的package包/類
@Override
public void handleMessage(Message message) throws Fault
{
    String messageId = (String) message.getExchange().get(
            LoggingMessage.ID_KEY);
    LogBean bean = new LogBean();
    bean.setResponseTime(new Date());

    OutputStream stream = message.getContent(OutputStream.class);
    final CacheAndWriteOutputStream newOut = new CacheAndWriteOutputStream(
            stream);
    message.setContent(OutputStream.class, newOut);
    newOut.registerCallback(new LoggingCallback(messageId, bean));

}
 
開發者ID:Huawei,項目名稱:eSDK_EC_SDK_Java,代碼行數:16,代碼來源:UCOutLogInterceptor.java

示例4: doInterfaceLog

import org.apache.cxf.message.Message; //導入方法依賴的package包/類
private void doInterfaceLog(Message message)
{
    String messageId = (String)message.getExchange().get(LoggingMessage.ID_KEY);
    String currentEnvelopeMessage = "";
    /*****/
    OutputStream os = message.getContent(OutputStream.class);        
    CachedStream cs = new CachedStream();
    message.setContent(OutputStream.class, cs);
    
    message.getInterceptorChain().doIntercept(message);
    
    try
    {
        cs.flush();
        IOUtils.closeQuietly(cs);
        CachedOutputStream csnew = (CachedOutputStream)message.getContent(OutputStream.class);
        
        currentEnvelopeMessage = IOUtils.toString(csnew.getInputStream(), "UTF-8");
        csnew.flush();
        IOUtils.closeQuietly(csnew);
        
        InputStream replaceInStream = IOUtils.toInputStream(currentEnvelopeMessage, "UTF-8");
        
        IOUtils.copy(replaceInStream, os);
        replaceInStream.close();
        IOUtils.closeQuietly(replaceInStream);
        
        os.flush();
        message.setContent(OutputStream.class, os);
        IOUtils.closeQuietly(os);
    }
    catch (IOException ioe)
    {
        throw new RuntimeException(ioe);
    }
    /*****/
    
    InterfaceLogBean bean = new InterfaceLogBean();
    bean.setTransactionId(messageId);
    bean.setReq(false);
    bean.setRespTime(new Date());
    bean.setResultCode(getResultCode(currentEnvelopeMessage));
    
    IInterfaceLog logger = ApplicationContextUtil.getBean("interfaceLogger");
    logger.info(bean);
}
 
開發者ID:Huawei,項目名稱:eSDK_EC_SDK_Java,代碼行數:47,代碼來源:PlatformOutInterceptor.java

示例5: handleMessage

import org.apache.cxf.message.Message; //導入方法依賴的package包/類
@Override
public void handleMessage(Message message) throws Fault
{
    String messageId = (String) message.getExchange().get(
            LoggingMessage.ID_KEY);
    LogBean bean = new LogBean();
    bean.setResponseTime(new Date());

    OutputStream stream = message.getContent(OutputStream.class);
    final CacheAndWriteOutputStream newOut = new CacheAndWriteOutputStream(
            stream);
    message.setContent(OutputStream.class, newOut);
    newOut.registerCallback(new LoggingCallback(messageId,bean));

}
 
開發者ID:Huawei,項目名稱:eSDK_IVS_Java,代碼行數:16,代碼來源:IVSOutLogInterceptor.java

示例6: handleMessage

import org.apache.cxf.message.Message; //導入方法依賴的package包/類
public void handleMessage(Message message) throws Fault {

        Document doc = (Document)message.get(RawMessageWSDLGetInterceptor.DOCUMENT_HOLDER);
        if (doc == null) {
            return;
        }
        message.remove(RawMessageWSDLGetInterceptor.DOCUMENT_HOLDER);

        OutputStream out = message.getContent(OutputStream.class);

        String enc = null;
        try {
            enc = doc.getXmlEncoding();
        } catch (Exception ex) {
            //ignore - not dom level 3
        }
        if (enc == null) {
            enc = "utf-8";
        }

        XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(out, enc);
        try {
            StaxUtils.writeNode(doc, writer, true);
            writer.flush();
        } catch (XMLStreamException e) {
            throw new Fault(e);
        }

    }
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:30,代碼來源:RawMessageWSDLGetOutInterceptor.java

示例7: closeInput

import org.apache.cxf.message.Message; //導入方法依賴的package包/類
private void closeInput(Message message) {
    InputStream is = message.getContent(InputStream.class);
    if (is != null) {
        try {
            is.close();
            message.removeContent(InputStream.class);
        } catch (IOException ioex) {
            //ignore
        }
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:12,代碼來源:OneWayOutgoingChainInterceptor.java

示例8: handleMessage

import org.apache.cxf.message.Message; //導入方法依賴的package包/類
public void handleMessage(Message message) throws Fault {
    // check the fault from the message
    Throwable ex = message.getContent(Throwable.class);
    if (ex != null) {
        if (ex instanceof Fault) {
            throw (Fault)ex;
        } else {
            throw new Fault(ex);
        }
    }

    List<?> params = message.getContent(List.class);
    if (null != params) {
        InputStream is = (InputStream)params.get(0);
        OutputStream os = message.getContent(OutputStream.class);
        if (os == null) {
            //InOny
            return;
        }

        try {
            if (is instanceof StreamCache) {
                ((StreamCache)is).writeTo(os);
            } else {
                IOUtils.copy(is, os);
            }
        } catch (Exception e) {
            throw new Fault(e);
        } finally {
            IOHelper.close(is, "input stream", null);
            // Should not close the output stream as the interceptor chain will close it
        }
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:35,代碼來源:RawMessageContentRedirectInterceptor.java

示例9: handleMessage

import org.apache.cxf.message.Message; //導入方法依賴的package包/類
public void handleMessage(Message message) throws Fault {
    XMLStreamWriter xmlWriter = getXMLStreamWriter(message);
    try {
        // put the payload source as a document
        Source source = message.getContent(Source.class);
        if (source != null) {
            XMLStreamReader xmlReader = StaxUtils.createXMLStreamReader(source);
            StaxUtils.copy(xmlReader, xmlWriter);
        }
    } catch (XMLStreamException e) {
        throw new Fault(new org.apache.cxf.common.i18n.Message("XMLSTREAM_EXCEPTION", JUL_LOG, e), e);
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:14,代碼來源:DataOutInterceptor.java

示例10: verifyReceivedMessage

import org.apache.cxf.message.Message; //導入方法依賴的package包/類
private void verifyReceivedMessage(Message inMessage, String content) throws IOException {
    ByteArrayInputStream bis = (ByteArrayInputStream)inMessage.getContent(InputStream.class);
    byte bytes[] = new byte[bis.available()];
    bis.read(bytes);
    String reponse = new String(bytes);
    assertEquals("The reponse date should be equals", content, reponse);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:8,代碼來源:CamelDestinationTest.java

示例11: verifyMessageContent

import org.apache.cxf.message.Message; //導入方法依賴的package包/類
public void verifyMessageContent(Message message) {
    OutputStream os = message.getContent(OutputStream.class);
    assertTrue("OutputStream should not be null", os != null);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:5,代碼來源:CamelConduitTest.java

示例12: getXMLStreamWriter

import org.apache.cxf.message.Message; //導入方法依賴的package包/類
protected XMLStreamWriter getXMLStreamWriter(Message message) {
    return message.getContent(XMLStreamWriter.class);
}
 
開發者ID:Huawei,項目名稱:eSDK_EC_SDK_Java,代碼行數:4,代碼來源:AbstractOutDatabindingInterceptor.java

示例13: getOAuthContext

import org.apache.cxf.message.Message; //導入方法依賴的package包/類
protected OAuthContext getOAuthContext() {
	Message m = PhaseInterceptorChain.getCurrentMessage();
	OAuthContext oac = m.getContent(OAuthContext.class);
   	return oac;
}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:6,代碼來源:AbstractServiceImpl.java

示例14: handleMessage

import org.apache.cxf.message.Message; //導入方法依賴的package包/類
@Override
public void handleMessage(Message message) throws Fault {

       /* 
        * Setup a LoggedInInfo and throw it onto the Request for use elsewhere. 
        * All we have is a providerNo so we access the ProviderDao directly.
        * There (likely) may be a better way to do this.
        *
        */

       // Create a new LoggedInInfo
       LoggedInInfo loggedInInfo = new LoggedInInfo();

       // Obtain the OAuthContext and the login (which in OSCAR is the providerNo)
	OAuthContext oc = message.getContent(OAuthContext.class);
	if(oc == null) {
		//not authorized yet
		return;
	}
       String providerNo = oc.getSubject().getLogin();

       // Create a new provider directly from the Dao with the providerNo.
       // We can trust this number as it was authenticated from OAuth.
       Provider provider = providerDao.getProvider(providerNo);
       loggedInInfo.setLoggedInProvider(provider);

       /* NOTE:
        * A LoggedInInfo object from OAuth will NOT have the following:
        * - session (no active session -- OAuth requests are stateless)
        * - loggedInSecurity (the logged in user is OAuth, so no actual username/password security)
        * - currentFacility (this could change, I'm not sure what it's for)
        * - initiatingCode (this could change, I'm not sure what it's for)
        * - locale (this could change, I'm not sure what it's for)
        */

       // Throw our new loggedInInfo onto the request for future use.
    HttpServletRequest request = (HttpServletRequest)message.get(AbstractHTTPDestination.HTTP_REQUEST);
       request.setAttribute(new LoggedInInfo().LOGGED_IN_INFO_KEY, loggedInInfo);


       return;
   }
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:43,代碼來源:OAuthInterceptor.java

示例15: getSecurityContext

import org.apache.cxf.message.Message; //導入方法依賴的package包/類
protected SecurityContext getSecurityContext() {
	Message m = PhaseInterceptorChain.getCurrentMessage();
   	org.apache.cxf.security.SecurityContext sc = m.getContent(org.apache.cxf.security.SecurityContext.class);
   	return sc;
}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:6,代碼來源:ProviderService.java


注:本文中的org.apache.cxf.message.Message.getContent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。