Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * #%L
  * Service Activity Monitoring :: Agent
  * %%
  * Copyright (C) 2011 Talend Inc.
  * %%
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
package org.talend.esb.sam.agent.wiretap;
Creates a CachedOutPutStream in the message that can be used to wiretap the content The interceptor does not yet work streaming so it first copies all the content to the CachedOutputStream and only then lets CXF continue on the message
public class WireTapIn extends AbstractPhaseInterceptor<Message> {
    private boolean logMessage;
    public WireTapIn(boolean logMessage) {
        super(.);
        this. = logMessage;
    }
    @Override
    public void handleMessage(final Message messagethrows Fault {
        InputStream is = message.getContent(InputStream.class);
        if (is != null || !) {
            try {
                CachedOutputStream cos = new CachedOutputStream();
                // TODO: We should try to make this streaming
                //WireTapInputStream wtis = new WireTapInputStream(is, cos);
                //message.setContent(InputStream.class, wtis);
                IOUtils.copy(iscos);
                message.setContent(InputStream.classcos.getInputStream());
                message.setContent(CachedOutputStream.classcos);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
New to GrepCode? Check out our FAQ X