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


Java CachedOutputStream.flush方法代码示例

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


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

示例1: decryptContent

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

示例2: doInterfaceLog

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

示例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包/类
public void handleMessage(Message message) {
	InputStream is = message.getContent(InputStream.class);
	if (is != null) {
		CachedOutputStream bos = new CachedOutputStream();
		try {
			Scanner scanner = new Scanner(is, "UTF-8");
			if (scanner != null && scanner.hasNext()) {
				String inputStreamString = scanner.useDelimiter("\\A").next();
				inputStreamString = inputStreamString
						.replaceAll("<record>",
								"<record xmlns=\"http://www.loc.gov/MARC21/slim\">");
				inputStreamString = inputStreamString
						.replaceAll("<collection>",
								"<collection xmlns=\"http://www.loc.gov/MARC21/slim\">");

				is = new ByteArrayInputStream(
						inputStreamString.getBytes("UTF-8"));
				scanner.close();
			} else {
				IOUtils.copy(is, bos);
				bos.flush();
				is = bos.getInputStream();
			}
			message.setContent(InputStream.class, is);
			is.close();
			bos.close();

		} catch (Exception e) {
			throw new Fault(e);
		}
	}
}
 
开发者ID:petkivim,项目名称:finto-subject-headings,代码行数:33,代码来源:RecordInterceptor.java

示例6: encryptContent

import org.apache.cxf.io.CachedOutputStream; //导入方法依赖的package包/类
public static void encryptContent( SecurityManager securityManager, String hostIdSource, String hostIdTarget,
                                   Message message )
{
    OutputStream os = message.getContent( OutputStream.class );

    CachedStream cs = new CachedStream();
    message.setContent( OutputStream.class, cs );

    message.getInterceptorChain().doIntercept( message );
    LOG.debug( String.format( "Encrypting IDs: %s -> %s", hostIdSource, hostIdTarget ) );

    try
    {
        cs.flush();
        CachedOutputStream csnew = ( CachedOutputStream ) message.getContent( OutputStream.class );

        byte[] originalMessage = org.apache.commons.io.IOUtils.toByteArray( csnew.getInputStream() );
        LOG.debug( String.format( "Original payload: \"%s\"", new String( originalMessage ) ) );

        csnew.flush();
        org.apache.commons.io.IOUtils.closeQuietly( cs );
        org.apache.commons.io.IOUtils.closeQuietly( csnew );

        //do something with original message to produce finalMessage
        byte[] finalMessage =
                originalMessage.length > 0 ? encryptData( securityManager, hostIdTarget, originalMessage ) : null;

        if ( !ArrayUtils.isEmpty( finalMessage ) )
        {

            InputStream replaceInStream = new ByteArrayInputStream( finalMessage );

            org.apache.commons.io.IOUtils.copy( replaceInStream, os );
            replaceInStream.close();
            org.apache.commons.io.IOUtils.closeQuietly( replaceInStream );

            os.flush();
            message.setContent( OutputStream.class, os );
        }


        org.apache.commons.io.IOUtils.closeQuietly( os );
    }
    catch ( Exception ioe )
    {
        throw new ActionFailedException( "Error encrypting content", ioe );
    }
}
 
开发者ID:subutai-io,项目名称:base,代码行数:49,代码来源:MessageContentUtil.java

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