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.jpa;
018    
019    import java.util.Date;
020    import javax.persistence.Entity;
021    import javax.persistence.GeneratedValue;
022    import javax.persistence.Id;
023    import javax.persistence.Table;
024    import javax.persistence.Transient;
025    
026    import org.apache.camel.Exchange;
027    import org.apache.camel.processor.interceptor.TraceEventMessage;
028    
029    /**
030     * A JPA based {@link org.apache.camel.processor.interceptor.TraceEventMessage} that is capable of persisting
031     * trace event into a database.
032     */
033    @Entity
034    @Table(
035        name = "CAMEL_MESSAGETRACED"
036    )
037    public class JpaTraceEventMessage implements TraceEventMessage {
038    
039        protected Long id;
040        protected Date timestamp;
041        protected String fromEndpointUri;
042        protected String previousNode;
043        protected String toNode;
044        protected String exchangeId;
045        protected String shortExchangeId;
046        protected String exchangePattern;
047        protected String properties;
048        protected String headers;
049        protected String body;
050        protected String bodyType;
051        protected String outHeaders;
052        protected String outBody;
053        protected String outBodyType;
054        protected String causedByException;
055    
056        public JpaTraceEventMessage() {
057        }
058    
059        @Id
060        @GeneratedValue
061        public Long getId() {
062            return id;
063        }
064    
065        public void setId(Long id) {
066            this.id = id;
067        }
068    
069        public Date getTimestamp() {
070            return timestamp;
071        }
072    
073        public void setTimestamp(Date timestamp) {
074            this.timestamp = timestamp;
075        }
076    
077        public String getPreviousNode() {
078            return previousNode;
079        }
080    
081        public void setPreviousNode(String previousNode) {
082            this.previousNode = previousNode;
083        }
084    
085        public String getFromEndpointUri() {
086            return fromEndpointUri;
087        }
088    
089        public void setFromEndpointUri(String fromEndpointUri) {
090            this.fromEndpointUri = fromEndpointUri;
091        }
092    
093        public String getToNode() {
094            return toNode;
095        }
096    
097        public void setToNode(String toNode) {
098            this.toNode = toNode;
099        }
100    
101        public String getExchangeId() {
102            return exchangeId;
103        }
104    
105        public void setExchangeId(String exchangeId) {
106            this.exchangeId = exchangeId;
107        }
108    
109        public String getShortExchangeId() {
110            return shortExchangeId;
111        }
112    
113        public void setShortExchangeId(String shortExchangeId) {
114            this.shortExchangeId = shortExchangeId;
115        }
116    
117        public String getExchangePattern() {
118            return exchangePattern;
119        }
120    
121        public void setExchangePattern(String exchangePattern) {
122            this.exchangePattern = exchangePattern;
123        }
124    
125        public String getProperties() {
126            return properties;
127        }
128    
129        public void setProperties(String properties) {
130            this.properties = properties;
131        }
132    
133        public String getHeaders() {
134            return headers;
135        }
136    
137        public void setHeaders(String headers) {
138            this.headers = headers;
139        }
140    
141        public String getBody() {
142            return body;
143        }
144    
145        public void setBody(String body) {
146            this.body = body;
147        }
148    
149        public String getBodyType() {
150            return bodyType;
151        }
152    
153        public void setBodyType(String bodyType) {
154            this.bodyType = bodyType;
155        }
156    
157        public String getOutBody() {
158            return outBody;
159        }
160    
161        public void setOutBody(String outBody) {
162            this.outBody = outBody;
163        }
164    
165        public String getOutBodyType() {
166            return outBodyType;
167        }
168    
169        public void setOutBodyType(String outBodyType) {
170            this.outBodyType = outBodyType;
171        }
172    
173        public String getOutHeaders() {
174            return outHeaders;
175        }
176    
177        public void setOutHeaders(String outHeaders) {
178            this.outHeaders = outHeaders;
179        }
180    
181        public String getCausedByException() {
182            return causedByException;
183        }
184    
185        public void setCausedByException(String causedByException) {
186            this.causedByException = causedByException;
187        }
188    
189        @Transient
190        public Exchange getTracedExchange() {
191            return null;
192        }
193    
194        @Override
195        public String toString() {
196            return "TraceEventMessage[" + getExchangeId() + "] on node: " + getToNode();   
197        }
198    
199    }