synchronized protected void processLocateReply()

in yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPConnection.java [726:834]


    synchronized protected void processLocateReply(GIOPIncomingMessage msg) {
        if ((properties_ & Property.ClientEnabled) == 0) {
            processException(State.Closed, new COMM_FAILURE(
                    MinorCodes.describeCommFailure(MinorCodes.MinorWrongMessage),
                    MinorCodes.MinorWrongMessage,
                    CompletionStatus.COMPLETED_MAYBE), false);
            return;
        }

        int reqId;
        org.omg.GIOP.LocateStatusType_1_2Holder status = new org.omg.GIOP.LocateStatusType_1_2Holder();

        try {
            reqId = msg.readLocateReplyHeader(status);
        } catch (SystemException ex) {
            processException(State.Error, ex, false);
            return;
        }

        Downcall down = messageQueue_.findAndRemovePending(reqId);
        if (down == null) {
            //
            // Request id is unknown
            //
            processException(State.Error, new COMM_FAILURE(
                    MinorCodes.describeCommFailure(MinorCodes.MinorUnknownReqId),
                    MinorCodes.MinorUnknownReqId,
                    CompletionStatus.COMPLETED_MAYBE), false);
            return;
        }

        //
        // Was this a LocateRequest?
        //
        String op = down.operation();
        if (!op.equals("_locate")) {
            processException(State.Error, new COMM_FAILURE(
                    MinorCodes.describeCommFailure(MinorCodes.MinorWrongMessage),
                    MinorCodes.MinorWrongMessage,
                    CompletionStatus.COMPLETED_MAYBE), false);
            return;
        }

        org.apache.yoko.orb.CORBA.InputStream in = msg.input();
        Logger logger = orbInstance_.getLogger();

        switch (status.value.value()) {
            case LocateStatusType_1_2._UNKNOWN_OBJECT:
                down.setSystemException(new org.omg.CORBA.OBJECT_NOT_EXIST());
                break;

            case LocateStatusType_1_2._OBJECT_HERE:
                down.setNoException(in);
                break;

            case LocateStatusType_1_2._OBJECT_FORWARD:
                try {
                    IOR ior = IORHelper.read(in);
                    down.setLocationForward(ior, false);
                    if (logger.isDebugEnabled()) {
                        logger.debug("Locate request forwarded to " + IORDump.PrintObjref(orbInstance_.getORB(), ior));
                    }
                } catch (SystemException ex) {
                    logger.warning("An error occurred while reading a "
                                    + "locate reply, possibly indicating\n"
                                    + "an interoperability problem. You may "
                                    + "need to set the LocateRequestPolicy\n"
                                    + "to false.");
                    down.setSystemException(ex);
                    processException(State.Error, ex, false);
                }
                break;

            case LocateStatusType_1_2._OBJECT_FORWARD_PERM:
                try {
                    IOR ior = IORHelper.read(in);
                    down.setLocationForward(ior, true);
                    if (logger.isDebugEnabled()) {
                        logger.debug("Locate request forwarded to " + IORDump.PrintObjref(orbInstance_.getORB(), ior));
                    }
                } catch (SystemException ex) {
                    logger.warning("An error occurred while reading a "
                                    + "locate reply, possibly indicating\n"
                                    + "an interoperability problem. You may "
                                    + "need to set the LocateRequestPolicy\n"
                                    + "to false.");
                    down.setSystemException(ex);
                    processException(State.Error, ex, false);
                }

                break;

            case LocateStatusType_1_2._LOC_SYSTEM_EXCEPTION:
                try {
                    SystemException ex = SystemExceptionHelper.read(in);
                    down.setSystemException(ex);
                } catch (SystemException ex) {
                    down.setSystemException(ex);
                    processException(State.Error, ex, false);
                }

                break;

            case LocateStatusType_1_2._LOC_NEEDS_ADDRESSING_MODE:
                // TODO: implement
                processException(State.Error, new NO_IMPLEMENT(), false);
                break;
        }
    }