1. /*
  2. * @(#)ORBSocketFactory.java 1.14 04/06/21
  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.spi.legacy.connection;
  8. import java.net.ServerSocket;
  9. import java.net.Socket;
  10. import java.io.IOException;
  11. import com.sun.corba.se.spi.ior.IOR;
  12. import com.sun.corba.se.spi.transport.SocketInfo;
  13. /**
  14. *
  15. * DEPRECATED. DEPRECATED. DEPRECATED. DEPRECATED. <p>
  16. * DEPRECATED. DEPRECATED. DEPRECATED. DEPRECATED. <p>
  17. *
  18. * This interface gives one the ability to plug in their own socket
  19. * factory class to an ORB. <p>
  20. *
  21. * Usage: <p>
  22. *
  23. * One specifies a class which implements this interface via the
  24. *
  25. * <code>ORBConstants.SOCKET_FACTORY_CLASS_PROPERTY</code>
  26. *
  27. * property. <p>
  28. *
  29. * Example: <p>
  30. * <pre>
  31. * -Dcom.sun.CORBA.connection.ORBSocketFactoryClass=MySocketFactory
  32. * </pre> <p>
  33. *
  34. * Typically one would use the same socket factory class on both the
  35. * server side and the client side (but this is not required). <p>
  36. *
  37. * A <code>ORBSocketFactory</code> class should have a public default
  38. * constructor which is called once per instantiating ORB.init call.
  39. * That ORB then calls the methods of that <code>ORBSocketFactory</code>
  40. * to obtain client and server sockets. <p>
  41. *
  42. * This interface also supports multiple server end points. See the
  43. * documentation on <code>createServerSocket</code> below.
  44. *
  45. */
  46. public interface ORBSocketFactory
  47. {
  48. /**
  49. * DEPRECATED. DEPRECATED. DEPRECATED. DEPRECATED. <p>
  50. *
  51. * A server ORB always creates an "IIOP_CLEAR_TEXT" listening port.
  52. * That port is put into IOP profiles of object references exported
  53. * by an ORB. <p>
  54. *
  55. * If
  56. *
  57. * <code>createServerSocket(String type, int port)</code>
  58. *
  59. * is passed <code>IIOP_CLEAR_TEXT</code> as a <code>type</code>
  60. * argument it should then call and return
  61. *
  62. * <code>new java.net.ServerSocket(int port)</code> <p>
  63. *
  64. * If
  65. *
  66. * <code>createSocket(SocketInfo socketInfo)</code>
  67. *
  68. * is passed <code>IIOP_CLEAR_TEXT</code> in
  69. * <code>socketInfo.getType()</code> it should
  70. * then call and return
  71. *
  72. * <pre>
  73. * new java.net.Socket(socketInfo.getHost(),
  74. * socketInfo.getPort())
  75. * </pre>
  76. *
  77. */
  78. public static final String IIOP_CLEAR_TEXT = "IIOP_CLEAR_TEXT";
  79. /**
  80. * DEPRECATED. DEPRECATED. DEPRECATED. DEPRECATED. <p>
  81. *
  82. * This method is used by a server side ORB. <p>
  83. *
  84. * When an ORB needs to create a listen socket on which connection
  85. * requests are accepted it calls
  86. *
  87. * <code>createServerSocket(String type, int port)</code>.
  88. *
  89. * The type argument says which type of socket should be created. <p>
  90. *
  91. * The interpretation of the type argument is the responsibility of
  92. * an instance of <code>ORBSocketFactory</code>, except in the case
  93. * of <code>IIOP_CLEAR_TEXT</code>, in which case a standard server
  94. * socket should be created. <p>
  95. *
  96. *
  97. * Multiple Server Port API: <p>
  98. *
  99. * In addition to the IIOP_CLEAR_TEXT listening port, it is possible
  100. * to specify that an ORB listen on additional port of specific types. <p>
  101. *
  102. * This API allows one to specify that an ORB should create an X,
  103. * or an X and a Y listen socket. <p>
  104. *
  105. * If X, to the user, means SSL, then one just plugs in an SSL
  106. * socket factory. <p>
  107. *
  108. * Or, another example, if X and Y, to the user, means SSL without
  109. * authentication and SSL with authentication respectively, then they
  110. * plug in a factory which will either create an X or a Y socket
  111. * depending on the type given to
  112. *
  113. * <code>createServerSocket(String type, int port)</code>. <p>
  114. *
  115. * One specifies multiple listening ports (in addition to the
  116. * default IIOP_CLEAR_TEXT port) using the
  117. *
  118. * <code>ORBConstants.LISTEN_SOCKET_PROPERTY</code>
  119. *
  120. * property. <p>
  121. *
  122. * Example usage:<p>
  123. *
  124. * <pre>
  125. * ... \
  126. * -Dcom.sun.CORBA.connection.ORBSocketFactoryClass=com.my.MySockFact \
  127. * -Dcom.sun.CORBA.connection.ORBListenSocket=SSL:0,foo:1 \
  128. * ...
  129. * </pre>
  130. *
  131. * The meaning of the "type" (SSL and foo above) is controlled
  132. * by the user. <p>
  133. *
  134. * ORBListenSocket is only meaningful for servers. <p>
  135. *
  136. * The property value is interpreted as follows. For each
  137. * type/number pair: <p>
  138. *
  139. * If number is 0 then use an emphemeral port for the listener of
  140. * the associated type. <p>
  141. *
  142. * If number is greater then 0 use that port number. <p>
  143. *
  144. * An ORB creates a listener socket for each type
  145. * specified by the user by calling
  146. *
  147. * <code>createServerSocket(String type, int port)</code>
  148. *
  149. * with the type specified by the user. <p>
  150. *
  151. * After an ORB is initialized and the RootPOA has been resolved,
  152. * it is then listening on
  153. * all the end points which were specified. It may be necessary
  154. * to add this additional end point information to object references
  155. * exported by this ORB. <p>
  156. *
  157. * Each object reference will contain the ORB's default IIOP_CLEAR_TEXT
  158. * end point in its IOP profile. To add additional end point information
  159. * (i.e., an SSL port) to an IOR (i.e., an object reference) one needs
  160. * to intercept IOR creation using
  161. * an <code>PortableInterceptor::IORInterceptor</code>. <p>
  162. *
  163. * Using PortableInterceptors (with a non-standard extension): <p>
  164. *
  165. * Register an <code>IORInterceptor</code>. Inside its
  166. * <code>establish_components</code> operation:
  167. *
  168. * <pre>
  169. *
  170. * com.sun.corba.se.spi.legacy.interceptor.IORInfoExt ext;
  171. * ext = (com.sun.corba.se.spi.legacy.interceptor.IORInfoExt)info;
  172. *
  173. * int port = ext.getServerPort("myType");
  174. *
  175. * </pre>
  176. *
  177. * Once you have the port you may add information to references
  178. * created by the associated adapter by calling
  179. *
  180. * <code>IORInfo::add_ior_component</code><p> <p>
  181. *
  182. *
  183. * Note: if one is using a POA and the lifespan policy of that
  184. * POA is persistent then the port number returned
  185. * by <code>getServerPort</code> <em>may</em>
  186. * be the corresponding ORBD port, depending on whether the POA/ORBD
  187. * protocol is the present port exchange or if, in the future,
  188. * the protocol is based on object reference template exchange.
  189. * In either
  190. * case, the port returned will be correct for the protocol.
  191. * (In more detail, if the port exchange protocol is used then
  192. * getServerPort will return the ORBD's port since the port
  193. * exchange happens before, at ORB initialization.
  194. * If object reference
  195. * exchange is used then the server's transient port will be returned
  196. * since the templates are exchanged after adding components.) <p>
  197. *
  198. *
  199. * Persistent object reference support: <p>
  200. *
  201. * When creating persistent object references with alternate
  202. * type/port info, ones needs to configure the ORBD to also support
  203. * this alternate info. This is done as follows: <p>
  204. *
  205. * - Give the ORBD the same socket factory you gave to the client
  206. * and server. <p>
  207. *
  208. * - specify ORBListenSocket ports of the same types that your
  209. * servers support. You should probably specify explicit port
  210. * numbers for ORBD if you embed these numbers inside IORs. <p>
  211. *
  212. * Note: when using the port exchange protocol
  213. * the ORBD and servers will exchange port
  214. * numbers for each given type so they know about each other.
  215. * When using object reference template exchange the server's
  216. * transient ports are contained in the template. <p>
  217. *
  218. *
  219. * - specify your <code>BadServerIdHandler</code> (discussed below)
  220. * using the
  221. *
  222. * <code>ORBConstants.BAD_SERVER_ID_HANDLER_CLASS_PROPERTY</code> <p>
  223. *
  224. * Example: <p>
  225. *
  226. * <pre>
  227. *
  228. * -Dcom.sun.CORBA.POA.ORBBadServerIdHandlerClass=corba.socketPersistent.MyBadServerIdHandler
  229. *
  230. * </pre>
  231. *
  232. * The <code>BadServerIdHandler</code> ...<p>
  233. *
  234. * See <code>com.sun.corba.se.impl.activation.ServerManagerImpl.handle</code>
  235. * for example code on writing a bad server id handler. NOTE: This
  236. * is an unsupported internal API. It will not exist in future releases.
  237. * <p>
  238. *
  239. *
  240. * Secure connections to other services: <p>
  241. *
  242. * If one wants secure connections to other services such as
  243. * Naming then one should configure them with the same
  244. *
  245. * <code>SOCKET_FACTORY_CLASS_PROPERTY</code> and
  246. * <code>LISTEN_SOCKET_PROPERTY</code>
  247. *
  248. * as used by other clients and servers in your distributed system. <p>
  249. *
  250. */
  251. public ServerSocket createServerSocket(String type, int port)
  252. throws
  253. IOException;
  254. /**
  255. * DEPRECATED. DEPRECATED. DEPRECATED. DEPRECATED. <p>
  256. *
  257. * This method is used by a client side ORB. <p>
  258. *
  259. * Each time a client invokes on an object reference, the reference's
  260. * associated ORB will call
  261. *
  262. * <pre>
  263. * getEndPointInfo(ORB orb,
  264. * IOR ior,
  265. * SocketInfo socketInfo)
  266. * </pre>
  267. *
  268. * NOTE: The type of the <code>ior</code> argument is an internal
  269. * representation for efficiency. If the <code>ORBSocketFactory</code>
  270. * interface ever becomes standardized then the <code>ior</code> will
  271. * most likely change to a standard type (e.g., a stringified ior,
  272. * an <code>org.omg.IOP.IOR</code>, or ...). <p>
  273. *
  274. * Typically, this method will look at tagged components in the
  275. * given <code>ior</code> to determine what type of socket to create. <p>
  276. *
  277. * Typically, the <code>ior</code> will contain a tagged component
  278. * specifying an alternate port type and number. <p>
  279. *
  280. * This method should return an <code>SocketInfo</code> object
  281. * containing the type/host/port to be used for the connection.
  282. *
  283. * If there are no appropriate tagged components then this method
  284. * should return an <code>SocketInfo</code> object with the type
  285. * <code>IIOP_CLEAR_TEXT</code> and host/port from the ior's IOP
  286. * profile. <p>
  287. *
  288. * If the ORB already has an existing connection to the returned
  289. * type/host/port, then that connection is used. Otherwise the ORB calls
  290. *
  291. * <code>createSocket(SocketInfo socketInfo)</code> <p>
  292. *
  293. * The <code>orb</code> argument is useful for handling
  294. * the <code>ior</code> argument. <p>
  295. *
  296. * The <code>SocketInfo</code> given to <code>getEndPointInfo</code>
  297. * is either null or an object obtained
  298. * from <code>GetEndPointInfoAgainException</code> <p>
  299. *
  300. */
  301. public SocketInfo getEndPointInfo(org.omg.CORBA.ORB orb,
  302. IOR ior,
  303. SocketInfo socketInfo);
  304. /**
  305. * DEPRECATED. DEPRECATED. DEPRECATED. DEPRECATED. <p
  306. *
  307. * This method is used by a client side ORB. <p>
  308. *
  309. * This method should return a client socket of the given
  310. * type/host/port. <p>
  311. *
  312. * Note: the <code>SocketInfo</code> is the same instance as was
  313. * returned by <code>getSocketInfo</code> so extra cookie info may
  314. * be attached. <p>
  315. *
  316. * If this method throws GetEndPointInfoAgainException then the
  317. * ORB calls <code>getEndPointInfo</code> again, passing it the
  318. * <code>SocketInfo</code> object contained in the exception. <p>
  319. *
  320. */
  321. public Socket createSocket(SocketInfo socketInfo)
  322. throws
  323. IOException,
  324. GetEndPointInfoAgainException;
  325. }
  326. // End of file.