001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.camel.processor.interceptor;
018
019 import java.util.Date;
020
021 import org.apache.camel.Exchange;
022 import org.apache.camel.ExchangePattern;
023 import org.apache.camel.impl.DefaultExchange;
024
025 /**
026 * Represents a trace of an {@link org.apache.camel.Exchange}, intercepted at the given node
027 * that occured during routing.
028 * <p/>
029 * The IN body contains {@link DefaultTraceEventMessage} with trace details of the original IN message.
030 */
031 public class TraceEventExchange extends DefaultExchange {
032 private String nodeId;
033 private Date timestamp;
034 private Exchange tracedExchange;
035
036 public TraceEventExchange(Exchange parent) {
037 super(parent);
038 }
039
040 @Override
041 public Exchange newInstance() {
042 TraceEventExchange answer = new TraceEventExchange(this);
043 answer.setNodeId(nodeId);
044 answer.setTimestamp(timestamp);
045 answer.setTracedExchange(tracedExchange);
046 return answer;
047 }
048
049 /**
050 * Get the id of the node of the trace interception
051 */
052 public String getNodeId() {
053 return nodeId;
054 }
055
056 /**
057 * Timestamp of the interception
058 */
059 public Date getTimestamp() {
060 return timestamp;
061 }
062
063 public void setNodeId(String nodeId) {
064 this.nodeId = nodeId;
065 }
066
067 public void setTimestamp(Date timestamp) {
068 this.timestamp = timestamp;
069 }
070
071 public Exchange getTracedExchange() {
072 return tracedExchange;
073 }
074
075 public void setTracedExchange(Exchange tracedExchange) {
076 this.tracedExchange = tracedExchange;
077 }
078
079 @Override
080 public ExchangePattern getPattern() {
081 return ExchangePattern.InOnly;
082 }
083
084 @Override
085 public String toString() {
086 return "TraceEventExchange[" + tracedExchange.getExchangeId() + "] on node id: " + nodeId;
087 }
088 }