1. /*
  2. * @(#)DefaultSocketFactory.java 1.5 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.corba.se.internal.iiop;
  8. import java.io.IOException;
  9. import java.net.ServerSocket;
  10. import java.net.Socket;
  11. import java.net.UnknownHostException;
  12. import org.omg.CORBA.ORB;
  13. import org.omg.CORBA.COMM_FAILURE;
  14. import org.omg.CORBA.CompletionStatus;
  15. import com.sun.corba.se.connection.EndPointInfo;
  16. import com.sun.corba.se.connection.GetEndPointInfoAgainException;
  17. import com.sun.corba.se.connection.ORBSocketFactory;
  18. import com.sun.corba.se.internal.core.IOR;
  19. import com.sun.corba.se.internal.iiop.EndPointImpl;
  20. import com.sun.corba.se.internal.ior.IIOPProfileTemplate ;
  21. import com.sun.corba.se.internal.ior.IIOPAddress ;
  22. import com.sun.corba.se.internal.orbutil.MinorCodes;
  23. public class DefaultSocketFactory
  24. implements
  25. ORBSocketFactory
  26. {
  27. public DefaultSocketFactory()
  28. {
  29. }
  30. public ServerSocket createServerSocket(String type, int port)
  31. throws
  32. IOException
  33. {
  34. if (! type.equals(ORBSocketFactory.IIOP_CLEAR_TEXT)) {
  35. throw new COMM_FAILURE(
  36. "DefaultSocketFactory.createServerSocket only handles " +
  37. "IIOP_CLEAR_TEXT, given: " + type,
  38. MinorCodes.DEFAULT_CREATE_SERVER_SOCKET_GIVEN_NON_IIOP_CLEAR_TEST,
  39. CompletionStatus.COMPLETED_NO);
  40. }
  41. return new ServerSocket(port);
  42. }
  43. public EndPointInfo getEndPointInfo(ORB orb,
  44. IOR ior,
  45. EndPointInfo endPointInfo)
  46. {
  47. IIOPProfileTemplate temp = ior.getProfile().getTemplate() ;
  48. IIOPAddress primary = temp.getPrimaryAddress() ;
  49. return new EndPointImpl(ORBSocketFactory.IIOP_CLEAR_TEXT,
  50. primary.getPort(),
  51. primary.getHost().toLowerCase());
  52. }
  53. public Socket createSocket(EndPointInfo endPointInfo)
  54. throws
  55. IOException,
  56. GetEndPointInfoAgainException
  57. {
  58. return new Socket(endPointInfo.getHost(), endPointInfo.getPort());
  59. }
  60. }