1. /*
  2. * @(#)BootStrapActivation.java 1.11 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.Activation;
  8. import java.io.File;
  9. import java.util.Properties;
  10. import org.omg.CosNaming.NamingContext;
  11. import org.omg.CORBA.INTERNAL ;
  12. import com.sun.corba.se.internal.POA.POAORB;
  13. import com.sun.corba.se.ActivationIDL.Repository;
  14. import com.sun.corba.se.ActivationIDL.RepositoryPackage.ServerDef;
  15. import com.sun.corba.se.ActivationIDL.Locator;
  16. import com.sun.corba.se.ActivationIDL.LocatorHelper;
  17. import com.sun.corba.se.ActivationIDL.Activator;
  18. import com.sun.corba.se.ActivationIDL.ActivatorHelper;
  19. import com.sun.corba.se.internal.CosNaming.BootstrapServer;
  20. import com.sun.corba.se.internal.orbutil.ORBConstants;
  21. public class BootStrapActivation
  22. {
  23. private POAORB orb;
  24. private String dbDirName;
  25. private File dbDir;
  26. private InitialNamingImpl ins;
  27. public BootStrapActivation( POAORB theorb )
  28. {
  29. orb = theorb;
  30. }
  31. private void createSystemDirs(String defaultDbDir ) {
  32. Properties props = System.getProperties();
  33. String fileSep = props.getProperty("file.separator");
  34. dbDir = new File(props.getProperty(
  35. ORBConstants.DB_DIR_PROPERTY,
  36. props.getProperty("user.dir") + fileSep +
  37. ORBConstants.DEFAULT_DB_DIR ) );
  38. dbDirName = dbDir.getAbsolutePath( );
  39. props.put(ORBConstants.DB_DIR_PROPERTY, dbDirName );
  40. if( !dbDir.exists() ) {
  41. dbDir.mkdir();
  42. }
  43. File logDir = new File( dbDir, "logs");
  44. if( !logDir.exists() ) {
  45. logDir.mkdir();
  46. }
  47. }
  48. private void initializeBootNaming( )
  49. {
  50. try {
  51. createSystemDirs( ORBConstants.DEFAULT_DB_DIR );
  52. Properties props = new Properties(); // null properties
  53. String fileSep = System.getProperty("file.separator");
  54. File nameFile = new File(dbDir, fileSep +
  55. ORBConstants.INITIAL_ORB_DB);
  56. // create a bootstrap server
  57. BootstrapServer bootServer;
  58. int initSvcPort = orb.getORBInitialPort();
  59. bootServer = new BootstrapServer(orb, initSvcPort,
  60. nameFile, props);
  61. bootServer.start();
  62. // add the Initial Naming object
  63. ins = new InitialNamingImpl((org.omg.CORBA.ORB)orb,
  64. bootServer);
  65. } catch( Exception e ) {
  66. // No Exception is displayed, Because the NameService release
  67. // Expects the exception in certain format.
  68. // _REVISIT_ and print out the right message
  69. }
  70. }
  71. public void start( )
  72. {
  73. try {
  74. initializeBootNaming( );
  75. // Initialize Server Repository
  76. RepositoryImpl repository =
  77. (RepositoryImpl) orb.getInitialService(
  78. ORBConstants.SERVER_REPOSITORY_NAME );
  79. if( repository == null ) {
  80. repository = new RepositoryImpl(
  81. orb, dbDir, orb.orbdDebugFlag );
  82. }
  83. ins.bind( ORBConstants.SERVER_REPOSITORY_NAME, repository,
  84. false );
  85. // Initialize Locator and Activator objects
  86. ServerManagerImpl serverMgr =
  87. (ServerManagerImpl)orb.getInitialService(
  88. ORBConstants.SERVER_LOCATOR_NAME );
  89. if( serverMgr == null ) {
  90. com.sun.corba.se.internal.core.ServerGIOP sgiop =
  91. orb.getServerGIOP();
  92. sgiop.initEndpoints();
  93. serverMgr = new ServerManagerImpl( orb,
  94. sgiop, repository, dbDirName, orb.orbdDebugFlag );
  95. }
  96. Locator locator = LocatorHelper.narrow( serverMgr );
  97. ins.bind( ORBConstants.SERVER_LOCATOR_NAME, locator, false );
  98. Activator activator = ActivatorHelper.narrow( serverMgr );
  99. ins.bind( ORBConstants.SERVER_ACTIVATOR_NAME, activator,
  100. false );
  101. // Initialize Name Service
  102. org.omg.CORBA.Object rootContext =
  103. orb.getInitialService("NameService");
  104. ins.bind( "NameService", rootContext, false );
  105. } catch( Exception e ) {
  106. throw new INTERNAL() ;
  107. }
  108. }
  109. }