clientInfo += " (" + clientHostAddress + ")";
}
boolean firstMessage = true;
CdrInputStream input = CdrInputStream.getInstance();
CdrOutputStream output = CdrOutputStream.getInstance();
CdrOutputStream results = CdrOutputStream.getInstance();
for (; ;) {
boolean sendResponse = true;
GiopMessage inputMessage;
try {
inputMessage = input.receive_message( in, clientInfo );
firstMessage = false;
} catch (BadMagicException ex) {
if (firstMessage) {
warnBadMagic(clientInfo, ex);
} else {
warnBadMagicBadSize(clientInfo, ex);
}
closeStreams( in, out );
return;
} catch (UnsupportedProtocolVersionException ex) {
warnGiopVersion( clientInfo, ex);
closeStreams( in, out );
return;
} catch (Exception ex) {
if (input.getOffset() > 0) {
ex.printStackTrace();
warnReceiveFailed( clientInfo, ex);
}
// Otherwise client shutdown was not in the middle of a
// request, i.e. probably 'normal' and unworthy of a
// log message.
closeStreams( in, out );
return;
}
output.setGiopVersion(input.getGiopVersion());
switch (inputMessage.type) {
case MsgType_1_1._Request:
processRequest(input, output, results, inputMessage.request, clientInfo);
if ((inputMessage.request.response_flags & 1) == 0) {
sendResponse = false; // oneway request
}
break;
case MsgType_1_1._LocateRequest:
processLocateRequest(output, inputMessage.locateRequest);
break;
default:
throw new SystemException("TODO: message type = " + inputMessage.type);
}
if (sendResponse) {
try {
if(inputMessage.httpTunneling)
{
output.send_http_response( out, clientInfo );
}
else
{
output.send_message( out, clientInfo );
}
} catch (Exception ex) {
warnSendFailed(clientInfo, ex);
closeStreams( in, out );
return;
}
}
input.reset();
output.reset();
results.reset();
}
}