📄 corbaclientrequestdispatcherimpl.java
字号:
+ ": throwing sex:" + exception); } throw (SystemException)exception; } } protected CorbaContactInfoListIterator getContactInfoListIterator(ORB orb) { return (CorbaContactInfoListIterator) ((CorbaInvocationInfo)orb.getInvocationInfo()) .getContactInfoListIterator(); } protected void registerWaiter(CorbaMessageMediator messageMediator) { if (messageMediator.getConnection() != null) { messageMediator.getConnection().registerWaiter(messageMediator); } } protected void unregisterWaiter(ORB orb) { MessageMediator messageMediator = orb.getInvocationInfo().getMessageMediator(); if (messageMediator!=null && messageMediator.getConnection() != null) { // REVISIT: // The messageMediator may be null if COMM_FAILURE before // it is created. messageMediator.getConnection().unregisterWaiter(messageMediator); } } protected void addServiceContexts(CorbaMessageMediator messageMediator) { ORB orb = (ORB)messageMediator.getBroker(); CorbaConnection c = (CorbaConnection) messageMediator.getConnection(); GIOPVersion giopVersion = messageMediator.getGIOPVersion(); ServiceContexts contexts = messageMediator.getRequestServiceContexts(); addCodeSetServiceContext(c, contexts, giopVersion); // Add the RMI-IIOP max stream format version // service context to every request. Once we have GIOP 1.3, // we could skip it since we now support version 2, but // probably safer to always send it. contexts.put(MaxStreamFormatVersionServiceContext.singleton); // ORBVersion servicecontext needs to be sent ORBVersionServiceContext ovsc = new ORBVersionServiceContext( ORBVersionFactory.getORBVersion() ) ; contexts.put( ovsc ) ; // NOTE : We only want to send the runtime context the first time if ((c != null) && !c.isPostInitialContexts()) { // Do not do c.setPostInitialContexts() here. // If a client interceptor send_request does a ForwardRequest // which ends up using the same connection then the service // context would not be sent. SendingContextServiceContext scsc = new SendingContextServiceContext( orb.getFVDCodeBaseIOR() ) ; //d11638 contexts.put( scsc ) ; } } protected void consumeServiceContexts(ORB orb, CorbaMessageMediator messageMediator) { ServiceContexts ctxts = messageMediator.getReplyServiceContexts(); ServiceContext sc ; ORBUtilSystemException wrapper = ORBUtilSystemException.get( orb, CORBALogDomains.RPC_PROTOCOL ) ; if (ctxts == null) { return; // no service context available, return gracefully. } sc = ctxts.get( SendingContextServiceContext.SERVICE_CONTEXT_ID ) ; if (sc != null) { SendingContextServiceContext scsc = (SendingContextServiceContext)sc ; IOR ior = scsc.getIOR() ; try { // set the codebase returned by the server if (messageMediator.getConnection() != null) { ((CorbaConnection)messageMediator.getConnection()).setCodeBaseIOR(ior); } } catch (ThreadDeath td) { throw td ; } catch (Throwable t) { throw wrapper.badStringifiedIor( t ) ; } } // see if the version subcontract is present, if yes, then set // the ORBversion sc = ctxts.get( ORBVersionServiceContext.SERVICE_CONTEXT_ID ) ; if (sc != null) { ORBVersionServiceContext ovsc = (ORBVersionServiceContext) sc; ORBVersion version = ovsc.getVersion(); orb.setORBVersion( version ) ; } getExceptionDetailMessage(messageMediator, wrapper); } protected void getExceptionDetailMessage( CorbaMessageMediator messageMediator, ORBUtilSystemException wrapper) { ServiceContext sc = messageMediator.getReplyServiceContexts() .get(ExceptionDetailMessage.value); if (sc == null) return ; if (! (sc instanceof UnknownServiceContext)) { throw wrapper.badExceptionDetailMessageServiceContextType(); } byte[] data = ((UnknownServiceContext)sc).getData(); EncapsInputStream in = new EncapsInputStream((ORB)messageMediator.getBroker(), data, data.length); in.consumeEndian(); String msg = "----------BEGIN server-side stack trace----------\n" + in.read_wstring() + "\n" + "----------END server-side stack trace----------"; messageMediator.setReplyExceptionDetailMessage(msg); } public void endRequest(Broker broker, Object self, InputObject inputObject) { ORB orb = (ORB)broker ; try { if (orb.subcontractDebugFlag) { dprint(".endRequest->"); } // Note: the inputObject may be null if an error occurs // in request or before _invoke returns. // Note: self may be null also (e.g., compiler generates null in stub). MessageMediator messageMediator = orb.getInvocationInfo().getMessageMediator(); if (messageMediator != null) { if (messageMediator.getConnection() != null) { ((CorbaMessageMediator)messageMediator) .sendCancelRequestIfFinalFragmentNotSent(); } // Release any outstanding NIO ByteBuffers to the ByteBufferPool InputObject inputObj = messageMediator.getInputObject(); if (inputObj != null) { inputObj.close(); } OutputObject outputObj = messageMediator.getOutputObject(); if (outputObj != null) { outputObj.close(); } } // XREVISIT NOTE - Assumes unregistering the waiter for // location forwards has already happened somewhere else. // The code below is only going to unregister the final successful // request. // NOTE: In the case of a recursive stack of endRequests in a // finally block (because of Remarshal) only the first call to // unregisterWaiter will remove the waiter. The rest will be // noops. unregisterWaiter(orb); // Invoke Portable Interceptors cleanup. This is done to handle // exceptions during stream marshaling. More generally, exceptions // that occur in the ORB after send_request (which includes // after returning from _request) before _invoke: orb.getPIHandler().cleanupClientPIRequest(); // REVISIT: Early replies? } catch (IOException ex) { // See CDRInput/OutputObject.close() for more info. // This won't result in a Corba error if an IOException happens. if (orb.subcontractDebugFlag) { dprint(".endRequest: ignoring IOException - " + ex.toString()); } } finally { if (orb.subcontractDebugFlag) { dprint(".endRequest<-"); } } } protected void performCodeSetNegotiation(CorbaMessageMediator messageMediator) { CorbaConnection conn = (CorbaConnection) messageMediator.getConnection(); IOR ior = ((CorbaContactInfo)messageMediator.getContactInfo()) .getEffectiveTargetIOR(); GIOPVersion giopVersion = messageMediator.getGIOPVersion(); // XXX This seems to be a broken double checked locking idiom: FIX IT! // conn.getCodeSetContext() is null when no other requests have // been made on this connection to trigger code set negotation. if (conn != null && conn.getCodeSetContext() == null && !giopVersion.equals(GIOPVersion.V1_0)) { synchronized(conn) { // Double checking. Don't let any other // threads use this connection until the // code sets are straight. if (conn.getCodeSetContext() != null) return; // This only looks at the first code set component. If // there can be multiple locations with multiple code sets, // this requires more work. IIOPProfileTemplate temp = (IIOPProfileTemplate)ior.getProfile(). getTaggedProfileTemplate(); Iterator iter = temp.iteratorById(TAG_CODE_SETS.value); if (!iter.hasNext()) { // Didn't have a code set component. The default will // be to use ISO8859-1 for char data and throw an // exception if wchar data is used. return; } // Get the native and conversion code sets the // server specified in its IOR CodeSetComponentInfo serverCodeSets = ((CodeSetsComponent)iter.next()).getCodeSetComponentInfo(); // Perform the negotiation between this ORB's code sets and // the ones from the IOR CodeSetComponentInfo.CodeSetContext result = CodeSetConversion.impl().negotiate( conn.getBroker().getORBData().getCodeSetComponentInfo(), serverCodeSets); conn.setCodeSetContext(result); } } } protected void addCodeSetServiceContext(CorbaConnection conn, ServiceContexts ctxs, GIOPVersion giopVersion) { // REVISIT. OMG issue 3318 concerning sending the code set // service context more than once was deemed too much for the // RTF. Here's our strategy for the moment: // // Send it on every request (necessary in cases of fragmentation // with multithreaded clients or when the first thing on a // connection is a LocateRequest). Provide an ORB property // to disable multiple sends. // // Note that the connection is null in the local case and no // service context is included. We use the ORB provided // encapsulation streams. // // Also, there will be no negotiation or service context // in GIOP 1.0. ISO8859-1 is used for char/string, and // wchar/wstring are illegal. // if (giopVersion.equals(GIOPVersion.V1_0) || conn == null) return; CodeSetComponentInfo.CodeSetContext codeSetCtx = null; if (conn.getBroker().getORBData().alwaysSendCodeSetServiceContext() || !conn.isPostInitialContexts()) { // Get the negotiated code sets (if any) out of the connection codeSetCtx = conn.getCodeSetContext(); } // Either we shouldn't send the code set service context, or // for some reason, the connection doesn't have its code sets. // Perhaps the server didn't include them in the IOR. Uses // ISO8859-1 for char and makes wchar/wstring illegal. if (codeSetCtx == null) return; CodeSetServiceContext cssc = new CodeSetServiceContext(codeSetCtx); ctxs.put(cssc); } protected String peekUserExceptionId(InputObject inputObject) { CDRInputObject cdrInputObject = (CDRInputObject) inputObject; // REVISIT - need interface for mark/reset cdrInputObject.mark(Integer.MAX_VALUE); String result = cdrInputObject.read_string(); cdrInputObject.reset(); return result; } protected void dprint(String msg) { ORBUtility.dprint("CorbaClientRequestDispatcherImpl", msg); } protected String opAndId(CorbaMessageMediator mediator) { return ORBUtility.operationNameAndRequestId(mediator); }}// End of file.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -