* @throws WSIException is there is a problem adding log entries.
*/
public synchronized void writeFromQueue() throws WSIException
{
MessageEntry requestMessageEntry = null;
MessageEntry responseMessageEntry = null;
boolean responseFound = false;
// Create array that will contain list of index to remove from request list
int[] requestIndexList = new int[requestList.size()];
int reqIndexCount = 0;
synchronized (listLock)
{
// If there are entries in the request queue,
// then try to match them with entries in the response queue
for (int reqIndex = 0; reqIndex < requestList.size(); reqIndex++)
{
// Get request log entry
requestMessageEntry = (MessageEntry) requestList.elementAt(reqIndex);
// Check each response log entry to see if the conversationId matches
responseFound = false;
for (int respIndex = 0;
respIndex < responseList.size() && !responseFound;
respIndex++)
{
// Get response log entry
responseMessageEntry =
(MessageEntry) responseList.elementAt(respIndex);
// If the request and response have the same conversationId,
// then write them out to the log file
if (requestMessageEntry
.getConversationId()
.equals(responseMessageEntry.getConversationId()))
{
responseFound = true;
// Set the id for the log entries
requestMessageEntry.setId(getNextMessageId());
responseMessageEntry.setId(getNextMessageId());
// Write out request and then response
//==== SS start : what this line is used for??? - causes memory leak, as no removeLogEntry is called ====
// log.addLogEntry(requestMessageEntry);
//==== SS end ===
StringReader requestReader =
new StringReader(requestMessageEntry.toXMLString(""));
logWriter.write(requestReader);
// Display message
printMessage(requestMessageEntry);
// Write out response
//==== SS start : what this line is used for??? - causes memory leak, as no removeLogEntry is called ====
// log.addLogEntry(responseMessageEntry);
//==== SS end ===
StringReader responseReader =
new StringReader(responseMessageEntry.toXMLString(""));
logWriter.write(responseReader);
// Display message
printMessage(responseMessageEntry);