KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > aspects > asynchronous > common > ThreadManagerResponseImpl


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22
23 package org.jboss.aspects.asynchronous.common;
24
25 import org.jboss.aspects.asynchronous.AsynchronousConstants;
26 import org.jboss.aspects.asynchronous.ThreadManagerResponse;
27
28 import java.text.SimpleDateFormat JavaDoc;
29 import java.util.Date JavaDoc;
30
31 /**
32  * @author <a HREF="mailto:chussenet@yahoo.com">{Claude Hussenet Independent Consultant}</a>.
33  * @version <tt>$Revision: 37406 $</tt>
34  */

35
36 public class ThreadManagerResponseImpl
37
38 extends AsynchronousResponseImpl
39
40 implements ThreadManagerResponse, AsynchronousConstants
41 {
42
43    private long _startingTime = -1;
44
45    private long _endingTime = -1;
46
47    private String JavaDoc id = null;
48
49    static private SimpleDateFormat JavaDoc formatter =
50
51    new SimpleDateFormat JavaDoc("HH:mm:ss.SSS ");
52
53    public ThreadManagerResponseImpl(String JavaDoc id,
54
55                                     int code,
56
57                                     String JavaDoc reason,
58
59                                     Object JavaDoc obj)
60    {
61
62       super(code, reason, obj);
63
64       this.id = id;
65
66    }
67
68    public ThreadManagerResponseImpl(String JavaDoc id,
69
70                                     int code,
71
72                                     String JavaDoc reason,
73
74                                     Object JavaDoc obj,
75
76                                     long startTime)
77    {
78
79       super(code, reason, obj);
80
81       _startingTime = startTime;
82
83       this.id = id;
84
85    }
86
87    public ThreadManagerResponseImpl(String JavaDoc id,
88
89                                     int code,
90
91                                     String JavaDoc reason,
92
93                                     Object JavaDoc obj,
94
95                                     long startTime,
96
97                                     long endTime)
98    {
99
100       super(code, reason, obj);
101
102       _startingTime = startTime;
103
104       _endingTime = endTime;
105
106       this.id = id;
107
108    }
109
110    public long getStartingTime()
111    {
112
113       return _startingTime;
114
115    }
116
117    public long getEndingTime()
118    {
119
120       return _endingTime;
121
122    }
123
124    public String JavaDoc toString()
125    {
126
127       return new StringBuffer JavaDoc("Id:")
128
129       .append(getId())
130
131       .append(" Rc:")
132
133       .append(getResponseCode())
134
135       .append(getReason() != null ? " Re:" : "")
136
137       .append(getReason() != null ? getReason() : "")
138
139       .append(" St:")
140
141       .append(formatter.format(new Date JavaDoc(getStartingTime())))
142
143       .append(" Du:")
144
145       .append(getEndingTime() - getStartingTime())
146
147       .append(getResponseCode() != AsynchronousConstants.OK ? " Rs:" : "")
148
149       .append(getResult())
150
151       .toString();
152
153    }
154
155    public String JavaDoc getId()
156    {
157
158       return id;
159
160    }
161
162 }
163
164
Popular Tags