protected void handleLocateRequest(CorbaMessageMediator messageMediator)
{
ORB orb = (ORB)messageMediator.getBroker();
LocateRequestMessage msg = (LocateRequestMessage)
messageMediator.getDispatchHeader();
IOR ior = null;
LocateReplyMessage reply = null;
short addrDisp = -1;
try {
((CDRInputObject)messageMediator.getInputObject()).unmarshalHeader();
CorbaServerRequestDispatcher sc =
msg.getObjectKey().getServerRequestDispatcher( orb ) ;
if (sc == null) {
return;
}
ior = sc.locate(msg.getObjectKey());
if ( ior == null ) {
reply = MessageBase.createLocateReply(
orb, msg.getGIOPVersion(),
msg.getEncodingVersion(),
msg.getRequestId(),
LocateReplyMessage.OBJECT_HERE, null);
} else {
reply = MessageBase.createLocateReply(
orb, msg.getGIOPVersion(),
msg.getEncodingVersion(),
msg.getRequestId(),
LocateReplyMessage.OBJECT_FORWARD, ior);
}
// REVISIT: Should we catch SystemExceptions?
} catch (AddressingDispositionException ex) {
// create a response containing the expected target
// addressing disposition.
reply = MessageBase.createLocateReply(
orb, msg.getGIOPVersion(),
msg.getEncodingVersion(),
msg.getRequestId(),
LocateReplyMessage.LOC_NEEDS_ADDRESSING_MODE, null);
addrDisp = ex.expectedAddrDisp();
} catch (RequestCanceledException ex) {
return; // no need to send reply
} catch ( Exception ex ) {
// REVISIT If exception is not OBJECT_NOT_EXIST, it should
// have a different reply
// This handles OBJECT_NOT_EXIST exceptions thrown in
// the subcontract or obj manager. Send back UNKNOWN_OBJECT.
reply = MessageBase.createLocateReply(
orb, msg.getGIOPVersion(),
msg.getEncodingVersion(),
msg.getRequestId(),
LocateReplyMessage.UNKNOWN_OBJECT, null);
}
CDROutputObject outputObject =
createAppropriateOutputObject(messageMediator,
msg, reply);
messageMediator.setOutputObject(outputObject);
outputObject.setMessageMediator(messageMediator);
reply.write(outputObject);
// outputObject.setMessage(reply); // REVISIT - not necessary
if (ior != null) {
ior.write(outputObject);
}
if (addrDisp != -1) {
AddressingDispositionHelper.write(outputObject, addrDisp);
}
}