Changeset 57 for trunk/src/main/java/omq/client/proxy
- Timestamp:
- 06/25/13 12:10:16 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/main/java/omq/client/proxy/Proxymq.java
r55 r57 5 5 import java.lang.reflect.Method; 6 6 import java.lang.reflect.Proxy; 7 import java.util.ArrayList; 7 8 import java.util.Collection; 8 9 import java.util.HashMap; 9 10 import java.util.Hashtable; 11 import java.util.List; 10 12 import java.util.Map; 11 13 import java.util.Properties; … … 256 258 } 257 259 260 @SuppressWarnings("unused") 261 private Object getResults(String corrId, int wait, long timeout, Class<?> type) throws Exception { 262 Response resp = null; 263 List<Object> list = new ArrayList<Object>(); 264 265 int i = 0; 266 long localTimeout = timeout; 267 long start = System.currentTimeMillis(); 268 269 while (i < wait) { 270 synchronized (results) { 271 // Due to we are using notifyAll(), we need to control the real 272 // time 273 while (!results.containsKey(corrId) && (timeout - localTimeout) >= 0) { 274 results.wait(localTimeout); 275 localTimeout = System.currentTimeMillis() - start; 276 } 277 if ((timeout - localTimeout) <= 0) { 278 throw new TimeoutException("Timeout exception time: " + timeout); 279 } 280 // Remove the corrId to receive new replies 281 resp = serializer.deserializeResponse(results.remove(corrId), type); 282 list.add(resp.getResult()); 283 284 } 285 i++; 286 } 287 synchronized (results) { 288 results.put(corrId, null); 289 } 290 291 return list; 292 } 293 258 294 /** 259 295 *
Note: See TracChangeset
for help on using the changeset viewer.