1 7 8 16 17 package com.sun.corba.se.impl.protocol; 18 19 import java.io.IOException ; 20 import java.util.Iterator ; 21 import java.rmi.RemoteException ; 22 23 import javax.rmi.CORBA.Util ; 24 import javax.rmi.CORBA.Tie ; 25 26 import org.omg.CORBA.COMM_FAILURE ; 27 import org.omg.CORBA.INTERNAL ; 28 import org.omg.CORBA.SystemException ; 29 import org.omg.CORBA.Request ; 30 import org.omg.CORBA.NamedValue ; 31 import org.omg.CORBA.NVList ; 32 import org.omg.CORBA.Context ; 33 import org.omg.CORBA.ContextList ; 34 import org.omg.CORBA.ExceptionList ; 35 import org.omg.CORBA.TypeCode ; 36 import org.omg.CORBA.portable.RemarshalException ; 37 import org.omg.CORBA_2_3.portable.InputStream ; 38 import org.omg.CORBA_2_3.portable.OutputStream ; 39 import org.omg.CORBA.portable.Delegate ; 40 import org.omg.CORBA.portable.ServantObject ; 41 import org.omg.CORBA.portable.ApplicationException ; 42 import org.omg.CORBA.portable.UnknownException ; 43 import org.omg.IOP.ExceptionDetailMessage ; 44 import org.omg.IOP.TAG_CODE_SETS ; 45 46 import com.sun.org.omg.SendingContext.CodeBase; 47 48 import com.sun.corba.se.pept.broker.Broker; 49 import com.sun.corba.se.pept.encoding.InputObject; 50 import com.sun.corba.se.pept.encoding.OutputObject; 51 import com.sun.corba.se.pept.protocol.ClientRequestDispatcher; 52 import com.sun.corba.se.pept.protocol.MessageMediator; 53 import com.sun.corba.se.pept.transport.Connection; 54 import com.sun.corba.se.pept.transport.OutboundConnectionCache; 55 import com.sun.corba.se.pept.transport.ContactInfo; 56 57 import com.sun.corba.se.spi.ior.IOR; 58 import com.sun.corba.se.spi.ior.iiop.GIOPVersion; 59 import com.sun.corba.se.spi.ior.iiop.IIOPProfileTemplate; 60 import com.sun.corba.se.spi.ior.iiop.CodeSetsComponent; 61 import com.sun.corba.se.spi.oa.OAInvocationInfo; 62 import com.sun.corba.se.spi.oa.ObjectAdapterFactory; 63 import com.sun.corba.se.spi.orb.ORB; 64 import com.sun.corba.se.spi.orb.ORBVersion; 65 import com.sun.corba.se.spi.orb.ORBVersionFactory; 66 import com.sun.corba.se.spi.protocol.CorbaMessageMediator; 67 import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry; 68 import com.sun.corba.se.spi.transport.CorbaContactInfo ; 69 import com.sun.corba.se.spi.transport.CorbaContactInfoList ; 70 import com.sun.corba.se.spi.transport.CorbaContactInfoListIterator ; 71 import com.sun.corba.se.spi.transport.CorbaConnection; 72 import com.sun.corba.se.spi.logging.CORBALogDomains; 73 74 import com.sun.corba.se.spi.servicecontext.MaxStreamFormatVersionServiceContext; 75 import com.sun.corba.se.spi.servicecontext.ServiceContext; 76 import com.sun.corba.se.spi.servicecontext.ServiceContexts; 77 import com.sun.corba.se.spi.servicecontext.UEInfoServiceContext; 78 import com.sun.corba.se.spi.servicecontext.CodeSetServiceContext; 79 import com.sun.corba.se.spi.servicecontext.SendingContextServiceContext; 80 import com.sun.corba.se.spi.servicecontext.ORBVersionServiceContext; 81 import com.sun.corba.se.spi.servicecontext.MaxStreamFormatVersionServiceContext; 82 import com.sun.corba.se.spi.servicecontext.UnknownServiceContext; 83 84 import com.sun.corba.se.impl.encoding.CDRInputObject; 85 import com.sun.corba.se.impl.encoding.CodeSetComponentInfo; 86 import com.sun.corba.se.impl.encoding.CodeSetConversion; 87 import com.sun.corba.se.impl.encoding.EncapsInputStream; 88 import com.sun.corba.se.impl.encoding.MarshalOutputStream; 89 import com.sun.corba.se.impl.encoding.MarshalInputStream; 90 import com.sun.corba.se.impl.logging.ORBUtilSystemException; 91 import com.sun.corba.se.impl.orbutil.ORBUtility; 92 import com.sun.corba.se.impl.orbutil.ORBConstants; 93 import com.sun.corba.se.impl.protocol.giopmsgheaders.ReplyMessage; 94 import com.sun.corba.se.impl.protocol.giopmsgheaders.KeyAddr; 95 import com.sun.corba.se.impl.protocol.giopmsgheaders.ProfileAddr; 96 import com.sun.corba.se.impl.protocol.giopmsgheaders.ReferenceAddr; 97 import com.sun.corba.se.impl.transport.CorbaContactInfoListIteratorImpl; 98 import com.sun.corba.se.impl.util.JDKBridge; 99 100 105 public class CorbaClientRequestDispatcherImpl 106 implements 107 ClientRequestDispatcher 108 { 109 private Object lock = new Object (); 111 112 public OutputObject beginRequest(Object self, String opName, 113 boolean isOneWay, ContactInfo contactInfo) 114 { 115 ORB orb = null; 116 try { 117 CorbaContactInfo corbaContactInfo = (CorbaContactInfo) contactInfo; 118 orb = (ORB)contactInfo.getBroker(); 119 120 if (orb.subcontractDebugFlag) { 121 dprint(".beginRequest->: op/" + opName); 122 } 123 124 128 orb.getPIHandler().initiateClientPIRequest( false ); 129 130 134 CorbaConnection connection = null; 135 136 synchronized (lock) { 139 if (contactInfo.isConnectionBased()) { 140 if (contactInfo.shouldCacheConnection()) { 141 connection = (CorbaConnection) 142 orb.getTransportManager() 143 .getOutboundConnectionCache(contactInfo).get(contactInfo); 144 } 145 if (connection != null) { 146 if (orb.subcontractDebugFlag) { 147 dprint(".beginRequest: op/" + opName 148 + ": Using cached connection: " + connection); 149 } 150 } else { 151 try { 152 connection = (CorbaConnection) 153 contactInfo.createConnection(); 154 if (orb.subcontractDebugFlag) { 155 dprint(".beginRequest: op/" + opName 156 + ": Using created connection: " + connection); 157 } 158 } catch (RuntimeException e) { 159 if (orb.subcontractDebugFlag) { 160 dprint(".beginRequest: op/" + opName 161 + ": failed to create connection: " + e); 162 } 163 boolean retry = getContactInfoListIterator(orb) 165 .reportException(contactInfo, e); 166 if (retry) { 169 if(getContactInfoListIterator(orb).hasNext()) { 170 contactInfo = (ContactInfo) 171 getContactInfoListIterator(orb).next(); 172 return beginRequest(self, opName, 173 isOneWay, contactInfo); 174 } else { 175 throw e; 176 } 177 } else { 178 throw e; 179 } 180 } 181 if (connection.shouldRegisterReadEvent()) { 182 orb.getTransportManager().getSelector(0) 184 .registerForEvent(connection.getEventHandler()); 185 connection.setState("ESTABLISHED"); 186 } 187 if (contactInfo.shouldCacheConnection()) { 191 OutboundConnectionCache connectionCache = 192 orb.getTransportManager() 193 .getOutboundConnectionCache(contactInfo); 194 connectionCache.stampTime(connection); 195 connectionCache.put(contactInfo, connection); 196 } 198 } 199 } 200 } 201 202 CorbaMessageMediator messageMediator = (CorbaMessageMediator) 203 contactInfo.createMessageMediator( 204 orb, contactInfo, connection, opName, isOneWay); 205 if (orb.subcontractDebugFlag) { 206 dprint(".beginRequest: " + opAndId(messageMediator) 207 + ": created message mediator: " + messageMediator); 208 } 209 210 220 orb.getInvocationInfo().setMessageMediator(messageMediator); 221 222 if (connection != null && connection.getCodeSetContext() == null) { 223 performCodeSetNegotiation(messageMediator); 224 } 225 226 addServiceContexts(messageMediator); 227 228 OutputObject outputObject = 229 contactInfo.createOutputObject(messageMediator); 230 if (orb.subcontractDebugFlag) { 231 dprint(".beginRequest: " + opAndId(messageMediator) 232 + ": created output object: " + outputObject); 233 } 234 235 236 registerWaiter(messageMediator); 240 241 synchronized (lock) { 243 if (contactInfo.isConnectionBased()) { 244 if (contactInfo.shouldCacheConnection()) { 245 OutboundConnectionCache connectionCache = 246 orb.getTransportManager() 247 .getOutboundConnectionCache(contactInfo); 248 connectionCache.reclaim(); 249 } 250 } 251 } 252 253 orb.getPIHandler().setClientPIInfo(messageMediator); 254 try { 255 orb.getPIHandler().invokeClientPIStartingPoint(); 259 } catch( RemarshalException e ) { 260 if (orb.subcontractDebugFlag) { 261 dprint(".beginRequest: " + opAndId(messageMediator) 262 + ": Remarshal"); 263 } 264 265 269 274 if (getContactInfoListIterator(orb).hasNext()) { 279 contactInfo = (ContactInfo) 280 getContactInfoListIterator(orb).next(); 281 return beginRequest(self, opName, isOneWay, contactInfo); 282 } else { 283 ORBUtilSystemException wrapper = 284 ORBUtilSystemException.get(orb, 285 CORBALogDomains.RPC_PROTOCOL); 286 throw wrapper.remarshalWithNowhereToGo(); 287 } 288 } 289 290 messageMediator.initializeMessage(); 291 if (orb.subcontractDebugFlag) { 292 dprint(".beginRequest: " + opAndId(messageMediator) 293 + ": initialized message"); 294 } 295 296 return outputObject; 297 298 } finally { 299 if (orb.subcontractDebugFlag) { 300 dprint(".beginRequest<-: op/" + opName); 301 } 302 } 303 } 304 305 public InputObject marshalingComplete(java.lang.Object self, 306 OutputObject outputObject) 307 throws 308 ApplicationException , 309 org.omg.CORBA.portable.RemarshalException 310 { 311 ORB orb = null; 312 CorbaMessageMediator messageMediator = null; 313 try { 314 messageMediator = (CorbaMessageMediator) 315 outputObject.getMessageMediator(); 316 317 orb = (ORB) messageMediator.getBroker(); 318 319 if (orb.subcontractDebugFlag) { 320 dprint(".marshalingComplete->: " + opAndId(messageMediator)); 321 } 322 323 InputObject inputObject = 324 marshalingComplete1(orb, messageMediator); 325 326 return processResponse(orb, messageMediator, inputObject); 327 328 } finally { 329 if (orb.subcontractDebugFlag) { 330 dprint(".marshalingComplete<-: " + opAndId(messageMediator)); 331 } 332 } 333 } 334 335 public InputObject marshalingComplete1( 336 ORB orb, CorbaMessageMediator messageMediator) 337 throws 338 ApplicationException , 339 org.omg.CORBA.portable.RemarshalException 340 { 341 try { 342 messageMediator.finishSendingRequest(); 343 344 if (orb.subcontractDebugFlag) { 345 dprint(".marshalingComplete: " + opAndId(messageMediator) 346 + ": finished sending request"); 347 } 348 349 return messageMediator.waitForResponse(); 350 351 } catch (RuntimeException e) { 352 353 if (orb.subcontractDebugFlag) { 354 dprint(".marshalingComplete: " + opAndId(messageMediator) 355 + ": exception: " + e.toString()); 356 } 357 358 boolean retry = 359 getContactInfoListIterator(orb) 360 .reportException(messageMediator.getContactInfo(), e); 361 if (retry) { 362 Exception newException = 364 orb.getPIHandler().invokeClientPIEndingPoint( 365 ReplyMessage.SYSTEM_EXCEPTION, e); 366 if (newException == e) { 367 continueOrThrowSystemOrRemarshal(messageMediator, 368 new RemarshalException ()); 369 } else { 370 continueOrThrowSystemOrRemarshal(messageMediator, 371 newException); 372 } 373 } else { 374 throw e; 376 } 377 return null; } 379 } 380 381 protected InputObject processResponse(ORB orb, 382 CorbaMessageMediator messageMediator, 383 InputObject inputObject) 384 throws 385 ApplicationException , 386 org.omg.CORBA.portable.RemarshalException 387 { 388 ORBUtilSystemException wrapper = 389 ORBUtilSystemException.get( orb, 390 CORBALogDomains.RPC_PROTOCOL ) ; 391 392 if (orb.subcontractDebugFlag) { 393 dprint(".processResponse: " + opAndId(messageMediator) 394 + ": response received"); 395 } 396 397 if (messageMediator.getConnection() != null) { 400 ((CorbaConnection)messageMediator.getConnection()) 401 .setPostInitialContexts(); 402 } 403 404 407 409 Exception exception = null; 410 411 if (messageMediator.isOneWay()) { 412 getContactInfoListIterator(orb) 413 .reportSuccess(messageMediator.getContactInfo()); 414 exception = orb.getPIHandler().invokeClientPIEndingPoint( 416 ReplyMessage.NO_EXCEPTION, exception ); 417 continueOrThrowSystemOrRemarshal(messageMediator, exception); 418 return null; 419 } 420 421 consumeServiceContexts(orb, messageMediator); 422 423 ((CDRInputObject)inputObject).performORBVersionSpecificInit(); 427 428 if (messageMediator.isSystemExceptionReply()) { 429 430 SystemException se = messageMediator.getSystemExceptionReply(); 431 432 if (orb.subcontractDebugFlag) { 433 dprint(".processResponse: " + opAndId(messageMediator) 434 + ": received system exception: " + se); 435 } 436 437 boolean doRemarshal = 438 getContactInfoListIterator(orb) 439 .reportException(messageMediator.getContactInfo(), se); 440 441 if (doRemarshal) { 442 443 exception = orb.getPIHandler().invokeClientPIEndingPoint( 445 ReplyMessage.SYSTEM_EXCEPTION, se ); 446 447 if( se == exception ) { 450 exception = null; 453 continueOrThrowSystemOrRemarshal(messageMediator, 454 new RemarshalException ()); 455 throw wrapper.statementNotReachable1() ; 456 } else { 457 continueOrThrowSystemOrRemarshal(messageMediator, 459 exception); 460 throw wrapper.statementNotReachable2() ; 461 } 462 } 463 464 466 ServiceContexts contexts = 467 messageMediator.getReplyServiceContexts(); 468 if (contexts != null) { 469 UEInfoServiceContext usc = 470 (UEInfoServiceContext) 471 contexts.get(UEInfoServiceContext.SERVICE_CONTEXT_ID); 472 473 if (usc != null) { 474 Throwable unknown = usc.getUE() ; 475 UnknownException ue = new UnknownException (unknown); 476 477 exception = orb.getPIHandler().invokeClientPIEndingPoint( 479 ReplyMessage.SYSTEM_EXCEPTION, ue ); 480 481 continueOrThrowSystemOrRemarshal(messageMediator, exception); 482 throw wrapper.statementNotReachable3() ; 483 } 484 } 485 486 489 exception = orb.getPIHandler().invokeClientPIEndingPoint( 491 ReplyMessage.SYSTEM_EXCEPTION, se ); 492 493 continueOrThrowSystemOrRemarshal(messageMediator, exception); 494 495 throw wrapper.statementNotReachable4() ; 498 } else if (messageMediator.isUserExceptionReply()) { 499 500 if (orb.subcontractDebugFlag) { 501 dprint(".processResponse: " + opAndId(messageMediator) 502 + ": received user exception"); 503 } 504 505 getContactInfoListIterator(orb) 506 .reportSuccess(messageMediator.getContactInfo()); 507 508 String exceptionRepoId = peekUserExceptionId(inputObject); 509 Exception newException = null; 510 511 if (messageMediator.isDIIRequest()) { 512 exception = messageMediator.unmarshalDIIUserException( 513 exceptionRepoId, (InputStream )inputObject); 514 newException = orb.getPIHandler().invokeClientPIEndingPoint( 515 ReplyMessage.USER_EXCEPTION, exception ); 516 messageMediator.setDIIException(newException); 517 518 } else { 519 ApplicationException appException = 520 new ApplicationException ( 521 exceptionRepoId, 522 (org.omg.CORBA.portable.InputStream )inputObject); 523 exception = appException; 524 newException = orb.getPIHandler().invokeClientPIEndingPoint( 525 ReplyMessage.USER_EXCEPTION, appException ); 526 } 527 528 if (newException != exception) { 529 continueOrThrowSystemOrRemarshal(messageMediator,newException); 530 } 531 532 if (newException instanceof ApplicationException ) { 533 throw (ApplicationException )newException; 534 } 535 return inputObject; 538 539 } else if (messageMediator.isLocationForwardReply()) { 540 541 if (orb.subcontractDebugFlag) { 542 dprint(".processResponse: " + opAndId(messageMediator) 543 + ": received location forward"); 544 } 545 546 getContactInfoListIterator(orb).reportRedirect( 548 (CorbaContactInfo)messageMediator.getContactInfo(), 549 messageMediator.getForwardedIOR()); 550 551 Exception newException = orb.getPIHandler().invokeClientPIEndingPoint( 553 ReplyMessage.LOCATION_FORWARD, null ); 554 555 if( !(newException instanceof RemarshalException ) ) { 556 exception = newException; 557 } 558 559 if( exception != null ) { 563 continueOrThrowSystemOrRemarshal(messageMediator, exception); 564 } 565 continueOrThrowSystemOrRemarshal(messageMediator, 566 new RemarshalException ()); 567 throw wrapper.statementNotReachable5() ; 568 569 } else if (messageMediator.isDifferentAddrDispositionRequestedReply()){ 570 571 if (orb.subcontractDebugFlag) { 572 dprint(".processResponse: " + opAndId(messageMediator) 573 + ": received different addressing dispostion request"); 574 } 575 576 getContactInfoListIterator(orb).reportAddrDispositionRetry( 578 (CorbaContactInfo)messageMediator.getContactInfo(), 579 messageMediator.getAddrDispositionReply()); 580 581 Exception newException = orb.getPIHandler().invokeClientPIEndingPoint( 583 ReplyMessage.NEEDS_ADDRESSING_MODE, null); 584 585 if( !(newException instanceof RemarshalException ) ) { 587 exception = newException; 588 } 589 590 if( exception != null ) { 594 continueOrThrowSystemOrRemarshal(messageMediator, exception); 595 } 596 continueOrThrowSystemOrRemarshal(messageMediator, 597 new RemarshalException ()); 598 throw wrapper.statementNotReachable6() ; 599 } else { 600 601 if (orb.subcontractDebugFlag) { 602 dprint(".processResponse: " + opAndId(messageMediator) 603 + ": received normal response"); 604 } 605 606 getContactInfoListIterator(orb) 607 .reportSuccess(messageMediator.getContactInfo()); 608 609 messageMediator.handleDIIReply((InputStream )inputObject); 610 611 exception = orb.getPIHandler().invokeClientPIEndingPoint( 613 ReplyMessage.NO_EXCEPTION, null ); 614 615 continueOrThrowSystemOrRemarshal(messageMediator, exception); 617 618 return inputObject; 619 } 620 } 621 622 protected void continueOrThrowSystemOrRemarshal( 630 CorbaMessageMediator messageMediator, Exception exception) 631 throws 632 SystemException , RemarshalException 633 { 634 635 ORB orb = (ORB) messageMediator.getBroker(); 636 637 if( exception == null ) { 638 639 641 } else if( exception instanceof RemarshalException ) { 642 643 orb.getInvocationInfo().setIsRetryInvocation(true); 645 646 unregisterWaiter(orb); 651 652 if (orb.subcontractDebugFlag) { 653 dprint(".continueOrThrowSystemOrRemarshal: " 654 + opAndId(messageMediator) 655 + ": throwing Remarshal"); 656 } 657 658 throw (RemarshalException )exception; 659 660 } else { 661 662 if (orb.subcontractDebugFlag) { 663 dprint(".continueOrThrowSystemOrRemarshal: " 664 + opAndId(messageMediator) 665 + ": throwing sex:" 666 + exception); 667 } 668 669 throw (SystemException )exception; 670 } 671 } 672 673 protected CorbaContactInfoListIterator getContactInfoListIterator(ORB orb) 674 { 675 return (CorbaContactInfoListIterator) 676 ((CorbaInvocationInfo)orb.getInvocationInfo()) 677 .getContactInfoListIterator(); 678 } 679 680 protected void registerWaiter(CorbaMessageMediator messageMediator) 681 { 682 if (messageMediator.getConnection() != null) { 683 messageMediator.getConnection().registerWaiter(messageMediator); 684 } 685 } 686 687 protected void unregisterWaiter(ORB orb) 688 { 689 MessageMediator messageMediator = 690 orb.getInvocationInfo().getMessageMediator(); 691 if (messageMediator!=null && messageMediator.getConnection() != null) { 692 messageMediator.getConnection().unregisterWaiter(messageMediator); 696 } 697 } 698 699 protected void addServiceContexts(CorbaMessageMediator messageMediator) 700 { 701 ORB orb = (ORB)messageMediator.getBroker(); 702 CorbaConnection c = (CorbaConnection) messageMediator.getConnection(); 703 GIOPVersion giopVersion = messageMediator.getGIOPVersion(); 704 705 ServiceContexts contexts = messageMediator.getRequestServiceContexts(); 706 707 addCodeSetServiceContext(c, contexts, giopVersion); 708 709 contexts.put(MaxStreamFormatVersionServiceContext.singleton); 714 715 ORBVersionServiceContext ovsc = new ORBVersionServiceContext( 717 ORBVersionFactory.getORBVersion() ) ; 718 contexts.put( ovsc ) ; 719 720 if ((c != null) && !c.isPostInitialContexts()) { 722 SendingContextServiceContext scsc = 727 new SendingContextServiceContext( orb.getFVDCodeBaseIOR() ) ; contexts.put( scsc ) ; 729 } 730 } 731 732 protected void consumeServiceContexts(ORB orb, 733 CorbaMessageMediator messageMediator) 734 { 735 ServiceContexts ctxts = messageMediator.getReplyServiceContexts(); 736 ServiceContext sc ; 737 ORBUtilSystemException wrapper = ORBUtilSystemException.get( orb, 738 CORBALogDomains.RPC_PROTOCOL ) ; 739 740 if (ctxts == null) { 741 return; } 743 744 sc = ctxts.get( SendingContextServiceContext.SERVICE_CONTEXT_ID ) ; 745 746 if (sc != null) { 747 SendingContextServiceContext scsc = 748 (SendingContextServiceContext)sc ; 749 IOR ior = scsc.getIOR() ; 750 751 try { 752 if (messageMediator.getConnection() != null) { 754 ((CorbaConnection)messageMediator.getConnection()).setCodeBaseIOR(ior); 755 } 756 } catch (ThreadDeath td) { 757 throw td ; 758 } catch (Throwable t) { 759 throw wrapper.badStringifiedIor( t ) ; 760 } 761 } 762 763 sc = ctxts.get( ORBVersionServiceContext.SERVICE_CONTEXT_ID ) ; 766 767 if (sc != null) { 768 ORBVersionServiceContext ovsc = 769 (ORBVersionServiceContext) sc; 770 771 ORBVersion version = ovsc.getVersion(); 772 orb.setORBVersion( version ) ; 773 } 774 775 getExceptionDetailMessage(messageMediator, wrapper); 776 } 777 778 protected void getExceptionDetailMessage( 779 CorbaMessageMediator messageMediator, 780 ORBUtilSystemException wrapper) 781 { 782 ServiceContext sc = messageMediator.getReplyServiceContexts() 783 .get(ExceptionDetailMessage.value); 784 if (sc == null) 785 return ; 786 787 if (! (sc instanceof UnknownServiceContext)) { 788 throw wrapper.badExceptionDetailMessageServiceContextType(); 789 } 790 byte[] data = ((UnknownServiceContext)sc).getData(); 791 EncapsInputStream in = 792 new EncapsInputStream((ORB)messageMediator.getBroker(), 793 data, data.length); 794 in.consumeEndian(); 795 796 String msg = 797 "----------BEGIN server-side stack trace----------\n" 798 + in.read_wstring() + "\n" 799 + "----------END server-side stack trace----------"; 800 801 messageMediator.setReplyExceptionDetailMessage(msg); 802 } 803 804 public void endRequest(Broker broker, Object self, InputObject inputObject) 805 { 806 ORB orb = (ORB)broker ; 807 808 try { 809 if (orb.subcontractDebugFlag) { 810 dprint(".endRequest->"); 811 } 812 813 817 MessageMediator messageMediator = 818 orb.getInvocationInfo().getMessageMediator(); 819 if (messageMediator != null) 820 { 821 if (messageMediator.getConnection() != null) 822 { 823 ((CorbaMessageMediator)messageMediator) 824 .sendCancelRequestIfFinalFragmentNotSent(); 825 } 826 827 829 InputObject inputObj = messageMediator.getInputObject(); 830 if (inputObj != null) { 831 inputObj.close(); 832 } 833 834 OutputObject outputObj = messageMediator.getOutputObject(); 835 if (outputObj != null) { 836 outputObj.close(); 837 } 838 839 } 840 841 846 unregisterWaiter(orb); 851 852 orb.getPIHandler().cleanupClientPIRequest(); 857 858 } catch (IOException ex) { 860 if (orb.subcontractDebugFlag) 863 { 864 dprint(".endRequest: ignoring IOException - " + ex.toString()); 865 } 866 } finally { 867 if (orb.subcontractDebugFlag) { 868 dprint(".endRequest<-"); 869 } 870 } 871 } 872 873 874 protected void performCodeSetNegotiation(CorbaMessageMediator messageMediator) 875 { 876 CorbaConnection conn = 877 (CorbaConnection) messageMediator.getConnection(); 878 IOR ior = 879 ((CorbaContactInfo)messageMediator.getContactInfo()) 880 .getEffectiveTargetIOR(); 881 GIOPVersion giopVersion = messageMediator.getGIOPVersion(); 882 883 885 if (conn != null && 888 conn.getCodeSetContext() == null && 889 !giopVersion.equals(GIOPVersion.V1_0)) { 890 891 synchronized(conn) { 892 if (conn.getCodeSetContext() != null) 896 return; 897 898 IIOPProfileTemplate temp = 902 (IIOPProfileTemplate)ior.getProfile(). 903 getTaggedProfileTemplate(); 904 Iterator iter = temp.iteratorById(TAG_CODE_SETS.value); 905 if (!iter.hasNext()) { 906 return; 910 } 911 912 CodeSetComponentInfo serverCodeSets 915 = ((CodeSetsComponent)iter.next()).getCodeSetComponentInfo(); 916 917 CodeSetComponentInfo.CodeSetContext result 920 = CodeSetConversion.impl().negotiate( 921 conn.getBroker().getORBData().getCodeSetComponentInfo(), 922 serverCodeSets); 923 924 conn.setCodeSetContext(result); 925 } 926 } 927 } 928 929 protected void addCodeSetServiceContext(CorbaConnection conn, 930 ServiceContexts ctxs, 931 GIOPVersion giopVersion) { 932 933 if (giopVersion.equals(GIOPVersion.V1_0) || conn == null) 951 return; 952 953 CodeSetComponentInfo.CodeSetContext codeSetCtx = null; 954 955 if (conn.getBroker().getORBData().alwaysSendCodeSetServiceContext() || 956 !conn.isPostInitialContexts()) { 957 958 codeSetCtx = conn.getCodeSetContext(); 960 } 961 962 if (codeSetCtx == null) 967 return; 968 969 CodeSetServiceContext cssc = new CodeSetServiceContext(codeSetCtx); 970 ctxs.put(cssc); 971 } 972 973 protected String peekUserExceptionId(InputObject inputObject) 974 { 975 CDRInputObject cdrInputObject = (CDRInputObject) inputObject; 976 cdrInputObject.mark(Integer.MAX_VALUE); 978 String result = cdrInputObject.read_string(); 979 cdrInputObject.reset(); 980 return result; 981 } 982 983 protected void dprint(String msg) 984 { 985 ORBUtility.dprint("CorbaClientRequestDispatcherImpl", msg); 986 } 987 988 protected String opAndId(CorbaMessageMediator mediator) 989 { 990 return ORBUtility.operationNameAndRequestId(mediator); 991 } 992 } 993 994 | Popular Tags |