| Version 7 (modified by dtea, 6 years ago) |
|---|
WEEK 5 : 11/12/2007 -> 11/23/2007
FROM DENIS TO HIEP : Thread class for multithreading calls to observer (not tested).
public class RequestThread extends Thread {
private Map<String, Observationresponse> mapOfObservationResponse;
private Request aRequest;
public RequestThread (Map<String, Observationresponse> mapOfObservationResponse, Request aRequest, Integer iPassed) {
this.mapOfObservationResponse = mapOfObservationResponse;
this.aRequest = aRequest;
}
public void run () {
try {
Observationresponse aObservationResponse;
aObservationResponse = aRequest.doRequest();
}
catch (final JAXBException e) {
UnicornCall.logger.error("JAXB Exception : "+e.getMessage(), e);
aObservationResponse = (Observationresponse) Request.aUnmarshaller.unmarshal(
new URL("file:" + Property.get("PATH_TO_ERROR_TEMPLATES") + "en_unmarshalling_error.vm"));
}
catch (final NullPointerException e) {
UnicornCall.logger.error("Null Pointer Exception : "+e.getMessage(), e);
aObservationResponse = (Observationresponse) Request.aUnmarshaller.unmarshal(
new URL("file:" + Property.get("PATH_TO_ERROR_TEMPLATES") + "en_io_error.vm"));
}
catch (final IOException e) {
UnicornCall.logger.error("IO Exception : "+e.getMessage(), e);
aObservationResponse = (Observationresponse) Request.aUnmarshaller.unmarshal(
new URL("file:" + Property.get("PATH_TO_ERROR_TEMPLATES") + "en_io_error.vm"));
}
mapOfObservationResponse.put(obsID, aObservationResponse);
if (!aObservationResponse.isPassed() && iPassed == 1)
iPassed = 0;
}
}
private boolean doRequests (final TPriority aTPriority)
throws IOException, JAXBException {
UnicornCall.logger.trace("doRequest");
if (UnicornCall.logger.isDebugEnabled()) {
UnicornCall.logger.debug("Priority : "+aTPriority+".");
}
boolean bPassed = true;
Integer iPassed = new Integer(1);
final Map<String, Observationresponse> mapOfObservationResponse;
switch (aTPriority) {
case HIGH:
mapOfObservationResponse = this.mapOfResponseHigh;
break;
case LOW:
mapOfObservationResponse = this.mapOfResponseLow;
break;
case MEDIUM:
mapOfObservationResponse = this.mapOfResponseMedium;
break;
default :
mapOfObservationResponse = null;
}
final Map<String, Request> requests = this.aRequestList.getRequest(aTPriority);
for (final String obsID : requests.keySet()) {
final Request aRequest = requests.get(obsID);
// send request to observer
if (UnicornCall.logger.isDebugEnabled()) {
UnicornCall.logger.debug("Request : "+aRequest.toString());
}
Thread th = new RequestThread(mapOfObservationResponse, aRequest, iPassed);
th.start();
}
if (iPassed)
return true;
else
return false;
}
- Week 1 (10/15/2007 -> 10/19/2007)
- Week 2 (10/22/2007 -> 10/26/2007)
- Week 3 (10/29/2007 -> 11/02/2007)
- Week 4 (11/05/2007 -> 11/09/2007)
- Week 5 (11/12/2007 -> 11/23/2007)
- Week 6 (11/26/2007 -> 11/30/2007)
