1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.kernel.messaging;
16  
17  import com.liferay.portal.kernel.util.StackTraceUtil;
18  import com.liferay.portal.kernel.util.StringBundler;
19  
20  import java.io.Serializable;
21  
22  /**
23   * <a href="MessageStatus.java.html"><b><i>View Source</i></b></a>
24   *
25   * @author Michael C. Han
26   */
27  public class MessageStatus implements Serializable {
28  
29      public long getDuration() {
30          return _endTime - _startTime;
31      }
32  
33      public String getExceptionMessage() {
34          return _exceptionMessage;
35      }
36  
37      public String getExceptionStackTrace() {
38          return _exceptionStackTrace;
39      }
40  
41      public Object getPayload() {
42          return _payload;
43      }
44  
45      public boolean hasException() {
46          if (_exceptionStackTrace != null) {
47              return true;
48          }
49          else {
50              return false;
51          }
52      }
53  
54      public void setException(Exception e) {
55          _exceptionMessage = e.getMessage();
56          _exceptionStackTrace = StackTraceUtil.getStackTrace(e);
57      }
58  
59      public void setPayload(Object payload) {
60          _payload = payload;
61      }
62  
63      public void startTimer() {
64          _startTime = System.currentTimeMillis();
65      }
66  
67      public void stopTimer() {
68          _endTime = System.currentTimeMillis();
69      }
70  
71      public String toString() {
72          StringBundler sb = new StringBundler(11);
73  
74          sb.append("{startTime=");
75          sb.append(_startTime);
76          sb.append(", endTime=");
77          sb.append(_endTime);
78          sb.append(", payload=");
79          sb.append(_payload);
80          sb.append(", errorMessage=");
81          sb.append(_exceptionMessage);
82          sb.append(", errorStackTrace=");
83          sb.append(_exceptionStackTrace);
84          sb.append("}");
85  
86          return sb.toString();
87      }
88  
89      private long _endTime;
90      private String _exceptionMessage;
91      private String _exceptionStackTrace;
92      private Object _payload;
93      private long _startTime;
94  
95  }