1 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 ; 29 import java.util.Date ; 30 31 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 id = null; 48 49 static private SimpleDateFormat formatter = 50 51 new SimpleDateFormat ("HH:mm:ss.SSS "); 52 53 public ThreadManagerResponseImpl(String id, 54 55 int code, 56 57 String reason, 58 59 Object obj) 60 { 61 62 super(code, reason, obj); 63 64 this.id = id; 65 66 } 67 68 public ThreadManagerResponseImpl(String id, 69 70 int code, 71 72 String reason, 73 74 Object 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 id, 88 89 int code, 90 91 String reason, 92 93 Object 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 toString() 125 { 126 127 return new StringBuffer ("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 (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 getId() 156 { 157 158 return id; 159 160 } 161 162 } 163 164 | Popular Tags |