FileDocCategorySizeDatePackage
ORBD.javaAPI DocJava SE 5 API10844Fri Aug 26 14:54:18 BST 2005com.sun.corba.se.impl.activation

ORBD

public class ORBD extends Object
version
1.10, 97/12/06
author
Rohit Garg
since
JDK1.2

Fields Summary
private int
initSvcPort
protected File
dbDir
private String
dbDirName
protected Locator
locator
protected Activator
activator
protected RepositoryImpl
repository
private static String[]
orbServers
List of servers to be auto registered and started by the ORBd. Each server entry is of the form {id, name, path, args, vmargs}.
Constructors Summary
Methods Summary
protected com.sun.corba.se.spi.orb.ORBcreateORB(java.lang.String[] args)

	Properties props = System.getProperties();

	// For debugging.
	//props.put( ORBConstants.DEBUG_PROPERTY, "naming" ) ;
	//props.put( ORBConstants.DEBUG_PROPERTY, "transport,giop,naming" ) ;

	props.put( ORBConstants.SERVER_ID_PROPERTY, "1000" ) ;
	props.put( ORBConstants.PERSISTENT_SERVER_PORT_PROPERTY, 
	    props.getProperty( ORBConstants.ORBD_PORT_PROPERTY,
		Integer.toString( 
		    ORBConstants.DEFAULT_ACTIVATION_PORT ) ) ) ;

	// See Bug 4396928 for more information about why we are initializing
	// the ORBClass to PIORB (now ORBImpl, but should check the bugid).
	props.put("org.omg.CORBA.ORBClass", 
	    "com.sun.corba.se.impl.orb.ORBImpl");

	return (ORB) ORB.init(args, props);
    
protected booleancreateSystemDirs(java.lang.String defaultDbDir)
Ensure that the Db directory exists. If not, create the Db and the log directory and return true. Otherwise return false.

	boolean dirCreated = false;
	Properties props = System.getProperties();
	String fileSep = props.getProperty("file.separator");

	// determine the ORB db directory
	dbDir = new File (props.getProperty( ORBConstants.DB_DIR_PROPERTY,
	    props.getProperty("user.dir") + fileSep + defaultDbDir));

	// create the db and the logs directories
        dbDirName = dbDir.getAbsolutePath();
	props.put(ORBConstants.DB_DIR_PROPERTY, dbDirName);
	if (!dbDir.exists()) {
	    dbDir.mkdir();
	    dirCreated = true;
	}

	File logDir = new File (dbDir, ORBConstants.SERVER_LOG_DIR ) ;
	if (!logDir.exists()) logDir.mkdir();

	return dirCreated;
    
protected com.sun.corba.se.spi.activation.ActivatorgetActivator()

	return activator;
    
protected java.io.FilegetDbDir()

	return dbDir;
    
protected java.lang.StringgetDbDirName()

	return dbDirName;
    
protected com.sun.corba.se.spi.activation.LocatorgetLocator()

	return locator;
    
protected com.sun.corba.se.impl.activation.RepositoryImplgetRepository()

	return repository;
    
protected voidinitializeBootNaming(com.sun.corba.se.spi.orb.ORB orb)

    	// create a bootstrap server
	initSvcPort = orb.getORBData().getORBInitialPort();

	Acceptor acceptor;
	// REVISIT: see ORBConfigurator. use factory in TransportDefault.
	if (orb.getORBData().getLegacySocketFactory() == null) {
	    acceptor = 
		new SocketOrChannelAcceptorImpl(
		    orb,
		    initSvcPort,
		    LegacyServerSocketEndPointInfo.BOOT_NAMING,
		    SocketInfo.IIOP_CLEAR_TEXT);
	} else {
	    acceptor = 
		new SocketFactoryAcceptorImpl(
		    orb,
		    initSvcPort,
		    LegacyServerSocketEndPointInfo.BOOT_NAMING,
		    SocketInfo.IIOP_CLEAR_TEXT);
	}
	orb.getCorbaTransportManager().registerAcceptor(acceptor);
    
protected voidinstallOrbServers(com.sun.corba.se.impl.activation.RepositoryImpl repository, com.sun.corba.se.spi.activation.Activator activator)
Go through the list of ORB Servers and initialize and start them up.

	int serverId;
	String[] server;
	ServerDef serverDef;

	for (int i=0; i < orbServers.length; i++) {
	    try {
		server = orbServers[i];
		serverDef = new ServerDef(server[1], server[2], 
					  server[3], server[4], server[5] );

		serverId = Integer.valueOf(orbServers[i][0]).intValue();

		repository.registerServer(serverDef, serverId);

		activator.activate(serverId);

	    } catch (Exception ex) {}
	}
    
public static voidmain(java.lang.String[] args)

	ORBD orbd = new ORBD();
	orbd.run(args);
    
private voidprocessArgs(java.lang.String[] args)

	Properties props = System.getProperties();
	for (int i=0; i < args.length; i++) {
	    if (args[i].equals("-port")) {
	        if ((i+1) < args.length) {
	            props.put(ORBConstants.ORBD_PORT_PROPERTY, args[++i]);
	        } else {
	            System.out.println(CorbaResourceUtil.getText(
			"orbd.usage", "orbd"));
	        }
	    } else if (args[i].equals("-defaultdb")) {
	        if ((i+1) < args.length) {
	            props.put(ORBConstants.DB_DIR_PROPERTY, args[++i]);
	        } else {
	            System.out.println(CorbaResourceUtil.getText(
			"orbd.usage", "orbd"));
	        }
	    } else if (args[i].equals("-serverid")) {
	        if ((i+1) < args.length) {
	            props.put(ORBConstants.SERVER_ID_PROPERTY, args[++i]);
	        } else {
	            System.out.println(CorbaResourceUtil.getText(
			"orbd.usage", "orbd"));
	        }
	    } else if (args[i].equals("-serverPollingTime")) {
	        if ((i+1) < args.length) {
	            props.put(ORBConstants.SERVER_POLLING_TIME, args[++i]);
	        } else {
	            System.out.println(CorbaResourceUtil.getText(
			"orbd.usage", "orbd"));
	        }
	    } else if (args[i].equals("-serverStartupDelay")) {
	        if ((i+1) < args.length) {
	            props.put(ORBConstants.SERVER_STARTUP_DELAY, args[++i]);
	        } else {
	            System.out.println(CorbaResourceUtil.getText(
			"orbd.usage", "orbd"));
	        }
            }
	}
    
private voidrun(java.lang.String[] args)

	try {
	    // parse the args and try setting the values for these
	    // properties
	    processArgs(args);

	    ORB orb = createORB(args);

	    if (orb.orbdDebugFlag) 
		System.out.println( "ORBD begins initialization." ) ;

	    boolean firstRun = createSystemDirs( ORBConstants.DEFAULT_DB_DIR );

	    startActivationObjects(orb);

	    if (firstRun) // orbd is being run the first time
		installOrbServers(getRepository(), getActivator());

	    if (orb.orbdDebugFlag) {
		System.out.println( "ORBD is ready." ) ;
	        System.out.println("ORBD serverid: " +
	                System.getProperty(ORBConstants.SERVER_ID_PROPERTY));
	        System.out.println("activation dbdir: " +
	                System.getProperty(ORBConstants.DB_DIR_PROPERTY));
	        System.out.println("activation port: " +
	                System.getProperty(ORBConstants.ORBD_PORT_PROPERTY));

                String pollingTime = System.getProperty(
                    ORBConstants.SERVER_POLLING_TIME);
                if( pollingTime == null ) {
                    pollingTime = Integer.toString( 
                        ORBConstants.DEFAULT_SERVER_POLLING_TIME );
                }
                System.out.println("activation Server Polling Time: " +
                        pollingTime + " milli-seconds ");

                String startupDelay = System.getProperty(
                    ORBConstants.SERVER_STARTUP_DELAY);
                if( startupDelay == null ) {
                    startupDelay = Integer.toString( 
                        ORBConstants.DEFAULT_SERVER_STARTUP_DELAY );
                }
	        System.out.println("activation Server Startup Delay: " +
                        startupDelay + " milli-seconds " );
	    }

	    // The following two lines start the Persistent NameService
            NameServiceStartThread theThread =
                new NameServiceStartThread( orb, dbDir );
            theThread.start( );

	    orb.run();
	} catch( org.omg.CORBA.COMM_FAILURE cex ) {
            System.out.println( CorbaResourceUtil.getText("orbd.commfailure"));
	    System.out.println( cex );
	    cex.printStackTrace();
        } catch( org.omg.CORBA.INTERNAL iex ) {
            System.out.println( CorbaResourceUtil.getText(
                "orbd.internalexception"));
	    System.out.println( iex );
	    iex.printStackTrace();
        } catch (Exception ex) {
	    System.out.println(CorbaResourceUtil.getText(
                "orbd.usage", "orbd"));
	    System.out.println( ex );
	    ex.printStackTrace();
	}
    
protected voidstartActivationObjects(com.sun.corba.se.spi.orb.ORB orb)

	// create Initial Name Service object
	initializeBootNaming(orb);

	// create Repository object
	repository = new RepositoryImpl(orb, dbDir, orb.orbdDebugFlag );
	orb.register_initial_reference( ORBConstants.SERVER_REPOSITORY_NAME, repository );

	// create Locator and Activator objects
	ServerManagerImpl serverMgr =
	    new ServerManagerImpl( orb, 
				   orb.getCorbaTransportManager(),
				   repository, 
				   getDbDirName(), 
				   orb.orbdDebugFlag );

	locator = LocatorHelper.narrow(serverMgr);
	orb.register_initial_reference( ORBConstants.SERVER_LOCATOR_NAME, locator );

	activator = ActivatorHelper.narrow(serverMgr);
	orb.register_initial_reference( ORBConstants.SERVER_ACTIVATOR_NAME, activator );

        // start Name Service
        TransientNameService nameService = new TransientNameService(orb, 
	    ORBConstants.TRANSIENT_NAME_SERVICE_NAME);