| MessageStatus.java |
1 /**
2 * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 package com.liferay.portal.kernel.messaging;
24
25 import com.liferay.portal.kernel.util.StackTraceUtil;
26
27 import java.io.Serializable;
28
29 /**
30 * <a href="MessageStatus.java.html"><b><i>View Source</i></b></a>
31 *
32 * @author Michael C. Han
33 *
34 */
35 public class MessageStatus implements Serializable {
36
37 public long getDuration() {
38 return _endTime - _startTime;
39 }
40
41 public String getExceptionMessage() {
42 return _exceptionMessage;
43 }
44
45 public String getExceptionStackTrace() {
46 return _exceptionStackTrace;
47 }
48
49 public Object getPayload() {
50 return _payload;
51 }
52
53 public boolean hasException() {
54 if (_exceptionStackTrace != null) {
55 return true;
56 }
57 else {
58 return false;
59 }
60 }
61
62 public void setException(Exception e) {
63 _exceptionMessage = e.getMessage();
64 _exceptionStackTrace = StackTraceUtil.getStackTrace(e);
65 }
66
67 public void setPayload(Object payload) {
68 _payload = payload;
69 }
70
71 public void startTimer() {
72 _startTime = System.currentTimeMillis();
73 }
74
75 public void stopTimer() {
76 _endTime = System.currentTimeMillis();
77 }
78
79 public String toString() {
80 StringBuilder sb = new StringBuilder();
81
82 sb.append("{startTime=");
83 sb.append(_startTime);
84 sb.append(", endTime=");
85 sb.append(_endTime);
86 sb.append(", payload=");
87 sb.append(_payload);
88 sb.append(", errorMessage=");
89 sb.append(_exceptionMessage);
90 sb.append(", errorStackTrace=");
91 sb.append(_exceptionStackTrace);
92 sb.append("}");
93
94 return sb.toString();
95 }
96
97 private long _endTime;
98 private String _exceptionMessage;
99 private String _exceptionStackTrace;
100 private Object _payload;
101 private long _startTime;
102
103 }