1. /*
  2. * @(#)SharedCDRContactInfoImpl.java 1.9 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.corba.se.impl.transport;
  8. import com.sun.corba.se.pept.broker.Broker;
  9. import com.sun.corba.se.pept.encoding.OutputObject;
  10. import com.sun.corba.se.pept.protocol.ClientRequestDispatcher;
  11. import com.sun.corba.se.pept.protocol.MessageMediator;
  12. import com.sun.corba.se.pept.transport.Connection;
  13. import com.sun.corba.se.pept.transport.ContactInfo;
  14. import com.sun.corba.se.spi.orb.ORB;
  15. import com.sun.corba.se.spi.ior.IOR;
  16. import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
  17. import com.sun.corba.se.spi.logging.CORBALogDomains;
  18. import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
  19. import com.sun.corba.se.spi.transport.CorbaContactInfoList;
  20. import com.sun.corba.se.impl.encoding.BufferManagerFactory;
  21. import com.sun.corba.se.impl.encoding.CDROutputObject;
  22. import com.sun.corba.se.impl.encoding.CDROutputStream;
  23. import com.sun.corba.se.impl.logging.ORBUtilSystemException;
  24. import com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl;
  25. import com.sun.corba.se.impl.protocol.SharedCDRClientRequestDispatcherImpl;
  26. public class SharedCDRContactInfoImpl
  27. extends
  28. CorbaContactInfoBase
  29. {
  30. // This is only necessary for the pi.clientrequestinfo test.
  31. // It tests that request ids are different.
  32. // Rather than rewrite the test, just fake it.
  33. private static int requestId = 0;
  34. protected ORBUtilSystemException wrapper;
  35. public SharedCDRContactInfoImpl(
  36. ORB orb,
  37. CorbaContactInfoList contactInfoList,
  38. IOR effectiveTargetIOR,
  39. short addressingDisposition)
  40. {
  41. this.orb = orb;
  42. this.contactInfoList = contactInfoList;
  43. this.effectiveTargetIOR = effectiveTargetIOR;
  44. this.addressingDisposition = addressingDisposition;
  45. }
  46. ////////////////////////////////////////////////////
  47. //
  48. // pept.transport.ContactInfo
  49. //
  50. public ClientRequestDispatcher getClientRequestDispatcher()
  51. {
  52. // REVISIT - use registry
  53. return new SharedCDRClientRequestDispatcherImpl();
  54. }
  55. public boolean isConnectionBased()
  56. {
  57. return false;
  58. }
  59. public boolean shouldCacheConnection()
  60. {
  61. return false;
  62. }
  63. public String getConnectionCacheType()
  64. {
  65. throw getWrapper().methodShouldNotBeCalled();
  66. }
  67. public Connection createConnection()
  68. {
  69. throw getWrapper().methodShouldNotBeCalled();
  70. }
  71. // Called when client making an invocation.
  72. public MessageMediator createMessageMediator(Broker broker,
  73. ContactInfo contactInfo,
  74. Connection connection,
  75. String methodName,
  76. boolean isOneWay)
  77. {
  78. if (connection != null) {
  79. /// XXX LOGGING
  80. throw new RuntimeException("connection is not null");
  81. }
  82. CorbaMessageMediator messageMediator =
  83. new CorbaMessageMediatorImpl(
  84. (ORB) broker,
  85. contactInfo,
  86. null, // Connection;
  87. GIOPVersion.chooseRequestVersion( (ORB)broker,
  88. effectiveTargetIOR),
  89. effectiveTargetIOR,
  90. requestId++, // Fake RequestId
  91. getAddressingDisposition(),
  92. methodName,
  93. isOneWay);
  94. return messageMediator;
  95. }
  96. public OutputObject createOutputObject(MessageMediator messageMediator)
  97. {
  98. CorbaMessageMediator corbaMessageMediator = (CorbaMessageMediator)
  99. messageMediator;
  100. // NOTE: GROW.
  101. OutputObject outputObject =
  102. new CDROutputObject(orb, messageMediator,
  103. corbaMessageMediator.getRequestHeader(),
  104. corbaMessageMediator.getStreamFormatVersion(),
  105. BufferManagerFactory.GROW);
  106. messageMediator.setOutputObject(outputObject);
  107. return outputObject;
  108. }
  109. ////////////////////////////////////////////////////
  110. //
  111. // spi.transport.CorbaContactInfo
  112. //
  113. public String getMonitoringName()
  114. {
  115. throw getWrapper().methodShouldNotBeCalled();
  116. }
  117. ////////////////////////////////////////////////////
  118. //
  119. // java.lang.Object
  120. //
  121. ////////////////////////////////////////////////////
  122. //
  123. // java.lang.Object
  124. //
  125. public String toString()
  126. {
  127. return
  128. "SharedCDRContactInfoImpl["
  129. + "]";
  130. }
  131. //////////////////////////////////////////////////
  132. //
  133. // Implementation
  134. //
  135. protected ORBUtilSystemException getWrapper()
  136. {
  137. if (wrapper == null) {
  138. wrapper = ORBUtilSystemException.get( orb,
  139. CORBALogDomains.RPC_TRANSPORT ) ;
  140. }
  141. return wrapper;
  142. }
  143. }
  144. // End of file.