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


Java CachedOutputStream.writeCacheTo方法代码示例

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


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

示例1: handleMessage

import org.apache.cxf.io.CachedOutputStream; //导入方法依赖的package包/类
@Override
public void handleMessage(final SoapMessage message) throws Fault
{
	try
	{
		CachedOutputStream os = (CachedOutputStream)message.getContent(OutputStream.class);
		StringBuilder sb = new StringBuilder();
		os.writeCacheTo(sb);
		
		OutputStream originalOs = (OutputStream)message.get(OUTPUT_STREAM_HOLDER);
		Transformer transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(this.getClass().getResourceAsStream("/nl/clockwork/mule/ebms/xsl/EbMSNullTransformation.xml")));
		transformer.transform(new StreamSource(new StringReader(sb.toString())),new StreamResult(originalOs));

		message.setContent(OutputStream.class,originalOs);
	}
	catch (Exception e)
	{
		throw new Fault(e);
	}
}
 
开发者ID:mprins,项目名称:muleebmsadapter,代码行数:21,代码来源:OracleEbMSXMLPrefixFixingOutInterceptor.java

示例2: toString

import org.apache.cxf.io.CachedOutputStream; //导入方法依赖的package包/类
private String toString(InputStream is) throws IOException {
    StringBuilder out = new StringBuilder();
    CachedOutputStream os = new CachedOutputStream();
    IOHelper.copy(is, os);
    is.close();
    os.writeCacheTo(out);
    return out.toString();

}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:CxfMessageHelperTest.java

示例3: handleMessage

import org.apache.cxf.io.CachedOutputStream; //导入方法依赖的package包/类
public void handleMessage(Message message) throws Fault
{
   String method = (String)message.get(Message.HTTP_REQUEST_METHOD);
   if (!method.equals("POST"))
   {
      return;
   }
   StringBuilder sb = new StringBuilder();
   InputStream is = message.getContent(InputStream.class);
   if (is != null)
   {
      CachedOutputStream bos = new CachedOutputStream();
      try
      {
         copy(is, bos, 4096);
         bos.flush();
         is.close();
         message.setContent(InputStream.class, bos.getInputStream());
         bos.writeCacheTo(sb);
         bos.close();
      }
      catch (IOException e)
      {
         throw new Fault(e);
      }
   }
   if (!sb.toString().contains("http://www.w3.org/2005/08/addressing"))
   {
      throw new Fault("Could not find any reference to namespace 'http://www.w3.org/2005/08/addressing' in handled message.",
            java.util.logging.Logger.getLogger(CheckInterceptor.class.getName()));
   }
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:33,代码来源:CheckInterceptor.java

示例4: handleMessage

import org.apache.cxf.io.CachedOutputStream; //导入方法依赖的package包/类
public void handleMessage(Message message) throws Fault
{
   String method = (String)message.get(Message.HTTP_REQUEST_METHOD);
   if (!method.equals("POST"))
   {
      return;
   }
   StringBuilder sb = new StringBuilder();
   InputStream is = message.getContent(InputStream.class);
   if (is != null)
   {
      CachedOutputStream bos = new CachedOutputStream();
      try
      {
         copy(is, bos, 4096);
         bos.flush();
         is.close();
         message.setContent(InputStream.class, bos.getInputStream());
         bos.writeCacheTo(sb);
         bos.close();
      }
      catch (IOException e)
      {
         throw new Fault(e);
      }
   }
   if (!sb.toString().contains(RM_NS))
   {
      throw new Fault("Could not find any reference to namespace '" + RM_NS + "' in handled message.",
            java.util.logging.Logger.getLogger(RMCheckInterceptor.class.getName()));
   }
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:33,代码来源:RMCheckInterceptor.java

示例5: handleMessage

import org.apache.cxf.io.CachedOutputStream; //导入方法依赖的package包/类
@Override
public void handleMessage(final SoapMessage message) throws Fault
{
	try
	{
		KeyStore keyStore = SecurityUtils.loadKeyStore(keyStorePath,keyStorePassword);
		KeyPair keyPair = SecurityUtils.getKeyPair(keyStore,keyAlias,keyPassword);
	
		CachedOutputStream os = (CachedOutputStream)message.getContent(OutputStream.class);
		StringBuilder sb = new StringBuilder();
		os.writeCacheTo(sb);
		
		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
		dbf.setNamespaceAware(true);
		Document document = dbf.newDocumentBuilder().parse(new ByteArrayInputStream(sb.toString().getBytes()));
		
		List<EbMSDataSource> dataSources = new ArrayList<EbMSDataSource>();
		if (message.getAttachments() != null)
			for (Attachment attachment : message.getAttachments())
			{
				DataSource ds = attachment.getDataHandler().getDataSource();
				dataSources.add(new EbMSDataSource(ds,attachment.getId(),attachment.getDataHandler().getName()));
			}
	
		sign(keyStore,keyPair,keyAlias,document,dataSources);
	
		OutputStream originalOs = (OutputStream)message.get(OUTPUT_STREAM_HOLDER);
		Transformer transformer = TransformerFactory.newInstance().newTransformer();
		transformer.transform(new DOMSource(document),new StreamResult(originalOs));

		message.setContent(OutputStream.class,originalOs);
	}
	catch (Exception e)
	{
		throw new Fault(e);
	}
}
 
开发者ID:mprins,项目名称:muleebmsadapter,代码行数:38,代码来源:XMLSecSignatureOutInterceptor.java

示例6: handleMessage

import org.apache.cxf.io.CachedOutputStream; //导入方法依赖的package包/类
@Override
public void handleMessage(final SoapMessage message) throws Fault
{
	try
	{
		KeyStore keyStore = SecurityUtils.loadKeyStore(keyStorePath,keyStorePassword);
		KeyPair keyPair = SecurityUtils.getKeyPair(keyStore,keyAlias,keyPassword);
	
		CachedOutputStream os = (CachedOutputStream)message.getContent(OutputStream.class);
		StringBuilder sb = new StringBuilder();
		os.writeCacheTo(sb);
		
		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
		dbf.setNamespaceAware(true);
		Document document = dbf.newDocumentBuilder().parse(new ByteArrayInputStream(sb.toString().getBytes()));
		
		if (isSigned(document))
		{
			List<EbMSDataSource> dataSources = new ArrayList<EbMSDataSource>();
			if (message.getAttachments() != null)
				for (Attachment attachment : message.getAttachments())
				{
					DataSource ds = attachment.getDataHandler().getDataSource();
					dataSources.add(new EbMSDataSource(ds,attachment.getId(),attachment.getDataHandler().getName()));
				}

			sign(keyStore,keyPair,keyAlias,document,dataSources);
		}
	
		OutputStream originalOs = (OutputStream)message.get(OUTPUT_STREAM_HOLDER);
		Transformer transformer = TransformerFactory.newInstance().newTransformer();
		transformer.transform(new DOMSource(document),new StreamResult(originalOs));

		message.setContent(OutputStream.class,originalOs);
	}
	catch (Exception e)
	{
		throw new Fault(e);
	}
}
 
开发者ID:mprins,项目名称:muleebmsadapter,代码行数:41,代码来源:EbMSSecSignatureOutInterceptor.java

示例7: handleMessage

import org.apache.cxf.io.CachedOutputStream; //导入方法依赖的package包/类
@Override
public void handleMessage(SoapMessage message) throws Fault
{
	try
	{
		KeyStore keyStore = SecurityUtils.loadKeyStore(keyStorePath,keyStorePassword);
		KeyPair keyPair = SecurityUtils.getKeyPair(keyStore,keyAlias,keyPassword);
	
		CachedOutputStream os = (CachedOutputStream)message.getContent(OutputStream.class);
		StringBuilder sb = new StringBuilder();
		os.writeCacheTo(sb);
		
		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
		dbf.setNamespaceAware(true);
		Document document = dbf.newDocumentBuilder().parse(new ByteArrayInputStream(sb.toString().getBytes()));
		
		List<EbMSDataSource> dataSources = new ArrayList<EbMSDataSource>();
		if (message.getAttachments() != null)
			for (Attachment attachment : message.getAttachments())
			{
				DataSource ds = attachment.getDataHandler().getDataSource();
				dataSources.add(new EbMSDataSource(ds,attachment.getId(),attachment.getDataHandler().getName()));
			}
	
		sign(keyStore,keyPair,keyAlias,document,dataSources);
	
		OutputStream originalOs = (OutputStream)message.get(OUTPUT_STREAM_HOLDER);
		Transformer transformer = TransformerFactory.newInstance().newTransformer();
		transformer.transform(new DOMSource(document),new StreamResult(originalOs));

		message.setContent(OutputStream.class,originalOs);
	}
	catch (Exception e)
	{
		throw new Fault(e);
	}
}
 
开发者ID:mprins,项目名称:muleebmsadapter,代码行数:38,代码来源:XMLDSignatureOutInterceptor.java

示例8: handleMessage

import org.apache.cxf.io.CachedOutputStream; //导入方法依赖的package包/类
@Override
public void handleMessage(SoapMessage message) throws Fault
{
	try
	{
		final LoggingMessage buffer = new LoggingMessage("Outbound Message\n---------------------------");
		buffer.getHeader().append(Message.CONTENT_TYPE).append(":").append(message.get(Message.CONTENT_TYPE));
		String encoding = (String)message.get(Message.ENCODING);
		if (encoding != null)
			buffer.getEncoding().append(encoding);
		Object headers = message.get(Message.PROTOCOL_HEADERS);
		if (headers != null)
			buffer.getHeader().append(headers);

		CachedOutputStream cos = (CachedOutputStream)message.getContent(OutputStream.class);
		OutputStream originalOs = (OutputStream)message.get(OUTPUT_STREAM_HOLDER);
		cos.writeCacheTo(buffer.getPayload(),limit);
		cos.writeCacheTo(originalOs);
		message.setContent(OutputStream.class,originalOs);
		
		if (logger.isInfoEnabled())
			logger.info(buffer.toString());
	}
	catch (IOException e)
	{
		new Fault(e);
	}
}
 
开发者ID:mprins,项目名称:muleebmsadapter,代码行数:29,代码来源:LoggingOutInterceptor.java

示例9: onClose

import org.apache.cxf.io.CachedOutputStream; //导入方法依赖的package包/类
public void onClose(CachedOutputStream cos) {
    try {
        StringBuilder builder = new StringBuilder();
        cos.writeCacheTo(builder, "utf-8");
        // here comes my xml:
        String postContent = builder.toString();
        stringToSign = new StringBuilder(stringToSign).append("\n").append(postContent).toString();

        String signature = calculateSignature(stringToSign, secret);
        String authToken = generateAuth(apiKey, signature);
        addHeader(message, HttpHeaders.AUTHORIZATION, authToken);
    } catch (Exception e) {
    }
}
 
开发者ID:antoniomaria,项目名称:gazpachoquest,代码行数:15,代码来源:HmacAuthInterceptor.java

示例10: logging

import org.apache.cxf.io.CachedOutputStream; //导入方法依赖的package包/类
private void logging(Message message) throws Fault {
    String id = (String) message.getExchange().get(LoggingMessageSecure.ID_KEY);
    if (id == null) {
        id = LoggingMessageSecure.nextId();
        message.getExchange().put(LoggingMessageSecure.ID_KEY, id);
    }
    final LoggingMessageSecure buffer = createNewLoggingMessage(id);

    String encoding = (String) message.get(Message.ENCODING);

    if (encoding != null) {
        buffer.getEncoding().append(encoding);
    }
    String ct = (String) message.get(Message.CONTENT_TYPE);
    if (ct != null) {
        buffer.getContentType().append(ct);
    }
    Object headers = message.get(Message.PROTOCOL_HEADERS);

    if (headers != null) {
        buffer.getHeader().append(headers);
    }
    String uri = (String) message.get(Message.ENDPOINT_ADDRESS);
    if (uri != null) {
        buffer.getAddress().append(uri);
    }

    InputStream is = message.getContent(InputStream.class);
    if (is != null) {
        CachedOutputStream bos = new CachedOutputStream();
        try {
            IOUtils.copy(is, bos);

            bos.flush();
            is.close();

            message.setContent(InputStream.class, bos.getInputStream());
            if (bos.getTempFile() != null) {
                // large thing on disk...
                buffer.getMessage().append("\nMessage (saved to tmp file):\n");
                buffer.getMessage().append("Filename: " + bos.getTempFile().getAbsolutePath() + "\n");
            }
            if (bos.size() > limit) {
                buffer.getMessage().append("(message truncated to " + limit + " bytes)\n");
            }
            bos.writeCacheTo(buffer.getPayload(), limit);

            bos.close();
        } catch (IOException e) {
            throw new Fault(e);
        }
    }

    if (writer != null) {
        writer.println(buffer.toString());
    } else if (getLogger().isLoggable(Level.INFO)) {
        getLogger().info(buffer.toString());
    }
}
 
开发者ID:blackducksoftware,项目名称:blackduck-cxf-utilities,代码行数:60,代码来源:AbstractPayloadFilteredLoggingInInterceptor.java


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