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