Package org.apache.cxf.interceptor

Examples of org.apache.cxf.interceptor.LoggingMessage


    super(phase);
  }

  public void handleMessage(Message message) throws Fault
  {
    final LoggingMessage buffer = new LoggingMessage("Inbound 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);

    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());
        bos.writeCacheTo(buffer.getPayload(),limit);
        bos.close();
      }
      catch (IOException e)
      {
        throw new Fault(e);
      }
    }
    try
    {
      if (logMessage)
      MessageManager.set(Utils.zip(buffer.toString()));
    }
    catch (IOException e)
    {
      if (logger.isInfoEnabled())
        logger.error("",e);
      else
        logger.error(buffer.toString(),e);
    }
    if (logger.isInfoEnabled())
      logger.info(buffer.toString());
  }
View Full Code Here


    @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);
      }
View Full Code Here

TOP

Related Classes of org.apache.cxf.interceptor.LoggingMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.