corba/src/share/classes/com/sun/corba/se/impl/activation/ORBD.java
author ohair
Tue, 25 May 2010 15:52:11 -0700
changeset 5555 b2b5ed3f0d0d
parent 4 02bb8761fcce
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     1
/*
02bb8761fcce Initial load
duke
parents:
diff changeset
     2
 *
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     3
 * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
02bb8761fcce Initial load
duke
parents:
diff changeset
     5
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
02bb8761fcce Initial load
duke
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     8
 * published by the Free Software Foundation.  Oracle designates this
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     9
 * particular file as subject to the "Classpath" exception as provided
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    10
 * by Oracle in the LICENSE file that accompanied this code.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    11
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    12
 * This code is distributed in the hope that it will be useful, but WITHOUT
02bb8761fcce Initial load
duke
parents:
diff changeset
    13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
02bb8761fcce Initial load
duke
parents:
diff changeset
    14
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
02bb8761fcce Initial load
duke
parents:
diff changeset
    15
 * version 2 for more details (a copy is included in the LICENSE file that
02bb8761fcce Initial load
duke
parents:
diff changeset
    16
 * accompanied this code).
02bb8761fcce Initial load
duke
parents:
diff changeset
    17
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    18
 * You should have received a copy of the GNU General Public License version
02bb8761fcce Initial load
duke
parents:
diff changeset
    19
 * 2 along with this work; if not, write to the Free Software Foundation,
02bb8761fcce Initial load
duke
parents:
diff changeset
    20
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
02bb8761fcce Initial load
duke
parents:
diff changeset
    21
 *
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    22
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    23
 * or visit www.oracle.com if you need additional information or have any
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    24
 * questions.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    25
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    26
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    27
02bb8761fcce Initial load
duke
parents:
diff changeset
    28
package com.sun.corba.se.impl.activation;
02bb8761fcce Initial load
duke
parents:
diff changeset
    29
02bb8761fcce Initial load
duke
parents:
diff changeset
    30
import java.io.File;
02bb8761fcce Initial load
duke
parents:
diff changeset
    31
import java.util.Properties;
02bb8761fcce Initial load
duke
parents:
diff changeset
    32
02bb8761fcce Initial load
duke
parents:
diff changeset
    33
import org.omg.CORBA.INITIALIZE;
02bb8761fcce Initial load
duke
parents:
diff changeset
    34
import org.omg.CORBA.INTERNAL;
02bb8761fcce Initial load
duke
parents:
diff changeset
    35
import org.omg.CORBA.CompletionStatus;
02bb8761fcce Initial load
duke
parents:
diff changeset
    36
import org.omg.CosNaming.NamingContext;
02bb8761fcce Initial load
duke
parents:
diff changeset
    37
import org.omg.PortableServer.POA;
02bb8761fcce Initial load
duke
parents:
diff changeset
    38
02bb8761fcce Initial load
duke
parents:
diff changeset
    39
import com.sun.corba.se.pept.transport.Acceptor;
02bb8761fcce Initial load
duke
parents:
diff changeset
    40
02bb8761fcce Initial load
duke
parents:
diff changeset
    41
import com.sun.corba.se.spi.activation.Repository;
02bb8761fcce Initial load
duke
parents:
diff changeset
    42
import com.sun.corba.se.spi.activation.RepositoryPackage.ServerDef;
02bb8761fcce Initial load
duke
parents:
diff changeset
    43
import com.sun.corba.se.spi.activation.Locator;
02bb8761fcce Initial load
duke
parents:
diff changeset
    44
import com.sun.corba.se.spi.activation.LocatorHelper;
02bb8761fcce Initial load
duke
parents:
diff changeset
    45
import com.sun.corba.se.spi.activation.Activator;
02bb8761fcce Initial load
duke
parents:
diff changeset
    46
import com.sun.corba.se.spi.activation.ActivatorHelper;
02bb8761fcce Initial load
duke
parents:
diff changeset
    47
import com.sun.corba.se.spi.activation.ServerAlreadyRegistered;
02bb8761fcce Initial load
duke
parents:
diff changeset
    48
import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketEndPointInfo;
02bb8761fcce Initial load
duke
parents:
diff changeset
    49
import com.sun.corba.se.spi.transport.SocketInfo;
02bb8761fcce Initial load
duke
parents:
diff changeset
    50
import com.sun.corba.se.spi.orb.ORB;
02bb8761fcce Initial load
duke
parents:
diff changeset
    51
02bb8761fcce Initial load
duke
parents:
diff changeset
    52
import com.sun.corba.se.impl.legacy.connection.SocketFactoryAcceptorImpl;
02bb8761fcce Initial load
duke
parents:
diff changeset
    53
import com.sun.corba.se.impl.naming.cosnaming.TransientNameService;
02bb8761fcce Initial load
duke
parents:
diff changeset
    54
import com.sun.corba.se.impl.naming.pcosnaming.NameService;
02bb8761fcce Initial load
duke
parents:
diff changeset
    55
import com.sun.corba.se.impl.orbutil.ORBConstants;
02bb8761fcce Initial load
duke
parents:
diff changeset
    56
import com.sun.corba.se.impl.orbutil.CorbaResourceUtil;
02bb8761fcce Initial load
duke
parents:
diff changeset
    57
import com.sun.corba.se.impl.transport.SocketOrChannelAcceptorImpl;
02bb8761fcce Initial load
duke
parents:
diff changeset
    58
02bb8761fcce Initial load
duke
parents:
diff changeset
    59
/**
02bb8761fcce Initial load
duke
parents:
diff changeset
    60
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    61
 * @author      Rohit Garg
02bb8761fcce Initial load
duke
parents:
diff changeset
    62
 * @since       JDK1.2
02bb8761fcce Initial load
duke
parents:
diff changeset
    63
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    64
public class ORBD
02bb8761fcce Initial load
duke
parents:
diff changeset
    65
{
02bb8761fcce Initial load
duke
parents:
diff changeset
    66
    private int initSvcPort;
02bb8761fcce Initial load
duke
parents:
diff changeset
    67
02bb8761fcce Initial load
duke
parents:
diff changeset
    68
    protected void initializeBootNaming(ORB orb)
02bb8761fcce Initial load
duke
parents:
diff changeset
    69
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
    70
        // create a bootstrap server
02bb8761fcce Initial load
duke
parents:
diff changeset
    71
        initSvcPort = orb.getORBData().getORBInitialPort();
02bb8761fcce Initial load
duke
parents:
diff changeset
    72
02bb8761fcce Initial load
duke
parents:
diff changeset
    73
        Acceptor acceptor;
02bb8761fcce Initial load
duke
parents:
diff changeset
    74
        // REVISIT: see ORBConfigurator. use factory in TransportDefault.
02bb8761fcce Initial load
duke
parents:
diff changeset
    75
        if (orb.getORBData().getLegacySocketFactory() == null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    76
            acceptor =
02bb8761fcce Initial load
duke
parents:
diff changeset
    77
                new SocketOrChannelAcceptorImpl(
02bb8761fcce Initial load
duke
parents:
diff changeset
    78
                    orb,
02bb8761fcce Initial load
duke
parents:
diff changeset
    79
                    initSvcPort,
02bb8761fcce Initial load
duke
parents:
diff changeset
    80
                    LegacyServerSocketEndPointInfo.BOOT_NAMING,
02bb8761fcce Initial load
duke
parents:
diff changeset
    81
                    SocketInfo.IIOP_CLEAR_TEXT);
02bb8761fcce Initial load
duke
parents:
diff changeset
    82
        } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
    83
            acceptor =
02bb8761fcce Initial load
duke
parents:
diff changeset
    84
                new SocketFactoryAcceptorImpl(
02bb8761fcce Initial load
duke
parents:
diff changeset
    85
                    orb,
02bb8761fcce Initial load
duke
parents:
diff changeset
    86
                    initSvcPort,
02bb8761fcce Initial load
duke
parents:
diff changeset
    87
                    LegacyServerSocketEndPointInfo.BOOT_NAMING,
02bb8761fcce Initial load
duke
parents:
diff changeset
    88
                    SocketInfo.IIOP_CLEAR_TEXT);
02bb8761fcce Initial load
duke
parents:
diff changeset
    89
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
    90
        orb.getCorbaTransportManager().registerAcceptor(acceptor);
02bb8761fcce Initial load
duke
parents:
diff changeset
    91
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    92
02bb8761fcce Initial load
duke
parents:
diff changeset
    93
    protected ORB createORB(String[] args)
02bb8761fcce Initial load
duke
parents:
diff changeset
    94
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
    95
        Properties props = System.getProperties();
02bb8761fcce Initial load
duke
parents:
diff changeset
    96
02bb8761fcce Initial load
duke
parents:
diff changeset
    97
        // For debugging.
02bb8761fcce Initial load
duke
parents:
diff changeset
    98
        //props.put( ORBConstants.DEBUG_PROPERTY, "naming" ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    99
        //props.put( ORBConstants.DEBUG_PROPERTY, "transport,giop,naming" ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   100
02bb8761fcce Initial load
duke
parents:
diff changeset
   101
        props.put( ORBConstants.SERVER_ID_PROPERTY, "1000" ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   102
        props.put( ORBConstants.PERSISTENT_SERVER_PORT_PROPERTY,
02bb8761fcce Initial load
duke
parents:
diff changeset
   103
            props.getProperty( ORBConstants.ORBD_PORT_PROPERTY,
02bb8761fcce Initial load
duke
parents:
diff changeset
   104
                Integer.toString(
02bb8761fcce Initial load
duke
parents:
diff changeset
   105
                    ORBConstants.DEFAULT_ACTIVATION_PORT ) ) ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   106
02bb8761fcce Initial load
duke
parents:
diff changeset
   107
        // See Bug 4396928 for more information about why we are initializing
02bb8761fcce Initial load
duke
parents:
diff changeset
   108
        // the ORBClass to PIORB (now ORBImpl, but should check the bugid).
02bb8761fcce Initial load
duke
parents:
diff changeset
   109
        props.put("org.omg.CORBA.ORBClass",
02bb8761fcce Initial load
duke
parents:
diff changeset
   110
            "com.sun.corba.se.impl.orb.ORBImpl");
02bb8761fcce Initial load
duke
parents:
diff changeset
   111
02bb8761fcce Initial load
duke
parents:
diff changeset
   112
        return (ORB) ORB.init(args, props);
02bb8761fcce Initial load
duke
parents:
diff changeset
   113
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   114
02bb8761fcce Initial load
duke
parents:
diff changeset
   115
    private void run(String[] args)
02bb8761fcce Initial load
duke
parents:
diff changeset
   116
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   117
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   118
            // parse the args and try setting the values for these
02bb8761fcce Initial load
duke
parents:
diff changeset
   119
            // properties
02bb8761fcce Initial load
duke
parents:
diff changeset
   120
            processArgs(args);
02bb8761fcce Initial load
duke
parents:
diff changeset
   121
02bb8761fcce Initial load
duke
parents:
diff changeset
   122
            ORB orb = createORB(args);
02bb8761fcce Initial load
duke
parents:
diff changeset
   123
02bb8761fcce Initial load
duke
parents:
diff changeset
   124
            if (orb.orbdDebugFlag)
02bb8761fcce Initial load
duke
parents:
diff changeset
   125
                System.out.println( "ORBD begins initialization." ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   126
02bb8761fcce Initial load
duke
parents:
diff changeset
   127
            boolean firstRun = createSystemDirs( ORBConstants.DEFAULT_DB_DIR );
02bb8761fcce Initial load
duke
parents:
diff changeset
   128
02bb8761fcce Initial load
duke
parents:
diff changeset
   129
            startActivationObjects(orb);
02bb8761fcce Initial load
duke
parents:
diff changeset
   130
02bb8761fcce Initial load
duke
parents:
diff changeset
   131
            if (firstRun) // orbd is being run the first time
02bb8761fcce Initial load
duke
parents:
diff changeset
   132
                installOrbServers(getRepository(), getActivator());
02bb8761fcce Initial load
duke
parents:
diff changeset
   133
02bb8761fcce Initial load
duke
parents:
diff changeset
   134
            if (orb.orbdDebugFlag) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   135
                System.out.println( "ORBD is ready." ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   136
                System.out.println("ORBD serverid: " +
02bb8761fcce Initial load
duke
parents:
diff changeset
   137
                        System.getProperty(ORBConstants.SERVER_ID_PROPERTY));
02bb8761fcce Initial load
duke
parents:
diff changeset
   138
                System.out.println("activation dbdir: " +
02bb8761fcce Initial load
duke
parents:
diff changeset
   139
                        System.getProperty(ORBConstants.DB_DIR_PROPERTY));
02bb8761fcce Initial load
duke
parents:
diff changeset
   140
                System.out.println("activation port: " +
02bb8761fcce Initial load
duke
parents:
diff changeset
   141
                        System.getProperty(ORBConstants.ORBD_PORT_PROPERTY));
02bb8761fcce Initial load
duke
parents:
diff changeset
   142
02bb8761fcce Initial load
duke
parents:
diff changeset
   143
                String pollingTime = System.getProperty(
02bb8761fcce Initial load
duke
parents:
diff changeset
   144
                    ORBConstants.SERVER_POLLING_TIME);
02bb8761fcce Initial load
duke
parents:
diff changeset
   145
                if( pollingTime == null ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   146
                    pollingTime = Integer.toString(
02bb8761fcce Initial load
duke
parents:
diff changeset
   147
                        ORBConstants.DEFAULT_SERVER_POLLING_TIME );
02bb8761fcce Initial load
duke
parents:
diff changeset
   148
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   149
                System.out.println("activation Server Polling Time: " +
02bb8761fcce Initial load
duke
parents:
diff changeset
   150
                        pollingTime + " milli-seconds ");
02bb8761fcce Initial load
duke
parents:
diff changeset
   151
02bb8761fcce Initial load
duke
parents:
diff changeset
   152
                String startupDelay = System.getProperty(
02bb8761fcce Initial load
duke
parents:
diff changeset
   153
                    ORBConstants.SERVER_STARTUP_DELAY);
02bb8761fcce Initial load
duke
parents:
diff changeset
   154
                if( startupDelay == null ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   155
                    startupDelay = Integer.toString(
02bb8761fcce Initial load
duke
parents:
diff changeset
   156
                        ORBConstants.DEFAULT_SERVER_STARTUP_DELAY );
02bb8761fcce Initial load
duke
parents:
diff changeset
   157
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   158
                System.out.println("activation Server Startup Delay: " +
02bb8761fcce Initial load
duke
parents:
diff changeset
   159
                        startupDelay + " milli-seconds " );
02bb8761fcce Initial load
duke
parents:
diff changeset
   160
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   161
02bb8761fcce Initial load
duke
parents:
diff changeset
   162
            // The following two lines start the Persistent NameService
02bb8761fcce Initial load
duke
parents:
diff changeset
   163
            NameServiceStartThread theThread =
02bb8761fcce Initial load
duke
parents:
diff changeset
   164
                new NameServiceStartThread( orb, dbDir );
02bb8761fcce Initial load
duke
parents:
diff changeset
   165
            theThread.start( );
02bb8761fcce Initial load
duke
parents:
diff changeset
   166
02bb8761fcce Initial load
duke
parents:
diff changeset
   167
            orb.run();
02bb8761fcce Initial load
duke
parents:
diff changeset
   168
        } catch( org.omg.CORBA.COMM_FAILURE cex ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   169
            System.out.println( CorbaResourceUtil.getText("orbd.commfailure"));
02bb8761fcce Initial load
duke
parents:
diff changeset
   170
            System.out.println( cex );
02bb8761fcce Initial load
duke
parents:
diff changeset
   171
            cex.printStackTrace();
02bb8761fcce Initial load
duke
parents:
diff changeset
   172
        } catch( org.omg.CORBA.INTERNAL iex ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   173
            System.out.println( CorbaResourceUtil.getText(
02bb8761fcce Initial load
duke
parents:
diff changeset
   174
                "orbd.internalexception"));
02bb8761fcce Initial load
duke
parents:
diff changeset
   175
            System.out.println( iex );
02bb8761fcce Initial load
duke
parents:
diff changeset
   176
            iex.printStackTrace();
02bb8761fcce Initial load
duke
parents:
diff changeset
   177
        } catch (Exception ex) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   178
            System.out.println(CorbaResourceUtil.getText(
02bb8761fcce Initial load
duke
parents:
diff changeset
   179
                "orbd.usage", "orbd"));
02bb8761fcce Initial load
duke
parents:
diff changeset
   180
            System.out.println( ex );
02bb8761fcce Initial load
duke
parents:
diff changeset
   181
            ex.printStackTrace();
02bb8761fcce Initial load
duke
parents:
diff changeset
   182
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   183
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   184
02bb8761fcce Initial load
duke
parents:
diff changeset
   185
    private void processArgs(String[] args)
02bb8761fcce Initial load
duke
parents:
diff changeset
   186
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   187
        Properties props = System.getProperties();
02bb8761fcce Initial load
duke
parents:
diff changeset
   188
        for (int i=0; i < args.length; i++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   189
            if (args[i].equals("-port")) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   190
                if ((i+1) < args.length) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   191
                    props.put(ORBConstants.ORBD_PORT_PROPERTY, args[++i]);
02bb8761fcce Initial load
duke
parents:
diff changeset
   192
                } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   193
                    System.out.println(CorbaResourceUtil.getText(
02bb8761fcce Initial load
duke
parents:
diff changeset
   194
                        "orbd.usage", "orbd"));
02bb8761fcce Initial load
duke
parents:
diff changeset
   195
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   196
            } else if (args[i].equals("-defaultdb")) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   197
                if ((i+1) < args.length) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   198
                    props.put(ORBConstants.DB_DIR_PROPERTY, args[++i]);
02bb8761fcce Initial load
duke
parents:
diff changeset
   199
                } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   200
                    System.out.println(CorbaResourceUtil.getText(
02bb8761fcce Initial load
duke
parents:
diff changeset
   201
                        "orbd.usage", "orbd"));
02bb8761fcce Initial load
duke
parents:
diff changeset
   202
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   203
            } else if (args[i].equals("-serverid")) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   204
                if ((i+1) < args.length) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   205
                    props.put(ORBConstants.SERVER_ID_PROPERTY, args[++i]);
02bb8761fcce Initial load
duke
parents:
diff changeset
   206
                } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   207
                    System.out.println(CorbaResourceUtil.getText(
02bb8761fcce Initial load
duke
parents:
diff changeset
   208
                        "orbd.usage", "orbd"));
02bb8761fcce Initial load
duke
parents:
diff changeset
   209
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   210
            } else if (args[i].equals("-serverPollingTime")) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   211
                if ((i+1) < args.length) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   212
                    props.put(ORBConstants.SERVER_POLLING_TIME, args[++i]);
02bb8761fcce Initial load
duke
parents:
diff changeset
   213
                } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   214
                    System.out.println(CorbaResourceUtil.getText(
02bb8761fcce Initial load
duke
parents:
diff changeset
   215
                        "orbd.usage", "orbd"));
02bb8761fcce Initial load
duke
parents:
diff changeset
   216
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   217
            } else if (args[i].equals("-serverStartupDelay")) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   218
                if ((i+1) < args.length) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   219
                    props.put(ORBConstants.SERVER_STARTUP_DELAY, args[++i]);
02bb8761fcce Initial load
duke
parents:
diff changeset
   220
                } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   221
                    System.out.println(CorbaResourceUtil.getText(
02bb8761fcce Initial load
duke
parents:
diff changeset
   222
                        "orbd.usage", "orbd"));
02bb8761fcce Initial load
duke
parents:
diff changeset
   223
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   224
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   225
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   226
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   227
02bb8761fcce Initial load
duke
parents:
diff changeset
   228
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   229
     * Ensure that the Db directory exists. If not, create the Db
02bb8761fcce Initial load
duke
parents:
diff changeset
   230
     * and the log directory and return true. Otherwise return false.
02bb8761fcce Initial load
duke
parents:
diff changeset
   231
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   232
    protected boolean createSystemDirs(String defaultDbDir)
02bb8761fcce Initial load
duke
parents:
diff changeset
   233
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   234
        boolean dirCreated = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   235
        Properties props = System.getProperties();
02bb8761fcce Initial load
duke
parents:
diff changeset
   236
        String fileSep = props.getProperty("file.separator");
02bb8761fcce Initial load
duke
parents:
diff changeset
   237
02bb8761fcce Initial load
duke
parents:
diff changeset
   238
        // determine the ORB db directory
02bb8761fcce Initial load
duke
parents:
diff changeset
   239
        dbDir = new File (props.getProperty( ORBConstants.DB_DIR_PROPERTY,
02bb8761fcce Initial load
duke
parents:
diff changeset
   240
            props.getProperty("user.dir") + fileSep + defaultDbDir));
02bb8761fcce Initial load
duke
parents:
diff changeset
   241
02bb8761fcce Initial load
duke
parents:
diff changeset
   242
        // create the db and the logs directories
02bb8761fcce Initial load
duke
parents:
diff changeset
   243
        dbDirName = dbDir.getAbsolutePath();
02bb8761fcce Initial load
duke
parents:
diff changeset
   244
        props.put(ORBConstants.DB_DIR_PROPERTY, dbDirName);
02bb8761fcce Initial load
duke
parents:
diff changeset
   245
        if (!dbDir.exists()) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   246
            dbDir.mkdir();
02bb8761fcce Initial load
duke
parents:
diff changeset
   247
            dirCreated = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   248
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   249
02bb8761fcce Initial load
duke
parents:
diff changeset
   250
        File logDir = new File (dbDir, ORBConstants.SERVER_LOG_DIR ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   251
        if (!logDir.exists()) logDir.mkdir();
02bb8761fcce Initial load
duke
parents:
diff changeset
   252
02bb8761fcce Initial load
duke
parents:
diff changeset
   253
        return dirCreated;
02bb8761fcce Initial load
duke
parents:
diff changeset
   254
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   255
02bb8761fcce Initial load
duke
parents:
diff changeset
   256
    protected File dbDir;
02bb8761fcce Initial load
duke
parents:
diff changeset
   257
    protected File getDbDir()
02bb8761fcce Initial load
duke
parents:
diff changeset
   258
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   259
        return dbDir;
02bb8761fcce Initial load
duke
parents:
diff changeset
   260
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   261
02bb8761fcce Initial load
duke
parents:
diff changeset
   262
    private String dbDirName;
02bb8761fcce Initial load
duke
parents:
diff changeset
   263
    protected String getDbDirName()
02bb8761fcce Initial load
duke
parents:
diff changeset
   264
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   265
        return dbDirName;
02bb8761fcce Initial load
duke
parents:
diff changeset
   266
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   267
02bb8761fcce Initial load
duke
parents:
diff changeset
   268
    protected void startActivationObjects(ORB orb) throws Exception
02bb8761fcce Initial load
duke
parents:
diff changeset
   269
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   270
        // create Initial Name Service object
02bb8761fcce Initial load
duke
parents:
diff changeset
   271
        initializeBootNaming(orb);
02bb8761fcce Initial load
duke
parents:
diff changeset
   272
02bb8761fcce Initial load
duke
parents:
diff changeset
   273
        // create Repository object
02bb8761fcce Initial load
duke
parents:
diff changeset
   274
        repository = new RepositoryImpl(orb, dbDir, orb.orbdDebugFlag );
02bb8761fcce Initial load
duke
parents:
diff changeset
   275
        orb.register_initial_reference( ORBConstants.SERVER_REPOSITORY_NAME, repository );
02bb8761fcce Initial load
duke
parents:
diff changeset
   276
02bb8761fcce Initial load
duke
parents:
diff changeset
   277
        // create Locator and Activator objects
02bb8761fcce Initial load
duke
parents:
diff changeset
   278
        ServerManagerImpl serverMgr =
02bb8761fcce Initial load
duke
parents:
diff changeset
   279
            new ServerManagerImpl( orb,
02bb8761fcce Initial load
duke
parents:
diff changeset
   280
                                   orb.getCorbaTransportManager(),
02bb8761fcce Initial load
duke
parents:
diff changeset
   281
                                   repository,
02bb8761fcce Initial load
duke
parents:
diff changeset
   282
                                   getDbDirName(),
02bb8761fcce Initial load
duke
parents:
diff changeset
   283
                                   orb.orbdDebugFlag );
02bb8761fcce Initial load
duke
parents:
diff changeset
   284
02bb8761fcce Initial load
duke
parents:
diff changeset
   285
        locator = LocatorHelper.narrow(serverMgr);
02bb8761fcce Initial load
duke
parents:
diff changeset
   286
        orb.register_initial_reference( ORBConstants.SERVER_LOCATOR_NAME, locator );
02bb8761fcce Initial load
duke
parents:
diff changeset
   287
02bb8761fcce Initial load
duke
parents:
diff changeset
   288
        activator = ActivatorHelper.narrow(serverMgr);
02bb8761fcce Initial load
duke
parents:
diff changeset
   289
        orb.register_initial_reference( ORBConstants.SERVER_ACTIVATOR_NAME, activator );
02bb8761fcce Initial load
duke
parents:
diff changeset
   290
02bb8761fcce Initial load
duke
parents:
diff changeset
   291
        // start Name Service
02bb8761fcce Initial load
duke
parents:
diff changeset
   292
        TransientNameService nameService = new TransientNameService(orb,
02bb8761fcce Initial load
duke
parents:
diff changeset
   293
            ORBConstants.TRANSIENT_NAME_SERVICE_NAME);
02bb8761fcce Initial load
duke
parents:
diff changeset
   294
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   295
02bb8761fcce Initial load
duke
parents:
diff changeset
   296
    protected Locator locator;
02bb8761fcce Initial load
duke
parents:
diff changeset
   297
    protected Locator getLocator()
02bb8761fcce Initial load
duke
parents:
diff changeset
   298
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   299
        return locator;
02bb8761fcce Initial load
duke
parents:
diff changeset
   300
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   301
02bb8761fcce Initial load
duke
parents:
diff changeset
   302
    protected Activator activator;
02bb8761fcce Initial load
duke
parents:
diff changeset
   303
    protected Activator getActivator()
02bb8761fcce Initial load
duke
parents:
diff changeset
   304
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   305
        return activator;
02bb8761fcce Initial load
duke
parents:
diff changeset
   306
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   307
02bb8761fcce Initial load
duke
parents:
diff changeset
   308
    protected RepositoryImpl repository;
02bb8761fcce Initial load
duke
parents:
diff changeset
   309
    protected RepositoryImpl getRepository()
02bb8761fcce Initial load
duke
parents:
diff changeset
   310
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   311
        return repository;
02bb8761fcce Initial load
duke
parents:
diff changeset
   312
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   313
02bb8761fcce Initial load
duke
parents:
diff changeset
   314
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   315
     * Go through the list of ORB Servers and initialize and start
02bb8761fcce Initial load
duke
parents:
diff changeset
   316
     * them up.
02bb8761fcce Initial load
duke
parents:
diff changeset
   317
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   318
    protected void installOrbServers(RepositoryImpl repository,
02bb8761fcce Initial load
duke
parents:
diff changeset
   319
                                     Activator activator)
02bb8761fcce Initial load
duke
parents:
diff changeset
   320
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   321
        int serverId;
02bb8761fcce Initial load
duke
parents:
diff changeset
   322
        String[] server;
02bb8761fcce Initial load
duke
parents:
diff changeset
   323
        ServerDef serverDef;
02bb8761fcce Initial load
duke
parents:
diff changeset
   324
02bb8761fcce Initial load
duke
parents:
diff changeset
   325
        for (int i=0; i < orbServers.length; i++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   326
            try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   327
                server = orbServers[i];
02bb8761fcce Initial load
duke
parents:
diff changeset
   328
                serverDef = new ServerDef(server[1], server[2],
02bb8761fcce Initial load
duke
parents:
diff changeset
   329
                                          server[3], server[4], server[5] );
02bb8761fcce Initial load
duke
parents:
diff changeset
   330
02bb8761fcce Initial load
duke
parents:
diff changeset
   331
                serverId = Integer.valueOf(orbServers[i][0]).intValue();
02bb8761fcce Initial load
duke
parents:
diff changeset
   332
02bb8761fcce Initial load
duke
parents:
diff changeset
   333
                repository.registerServer(serverDef, serverId);
02bb8761fcce Initial load
duke
parents:
diff changeset
   334
02bb8761fcce Initial load
duke
parents:
diff changeset
   335
                activator.activate(serverId);
02bb8761fcce Initial load
duke
parents:
diff changeset
   336
02bb8761fcce Initial load
duke
parents:
diff changeset
   337
            } catch (Exception ex) {}
02bb8761fcce Initial load
duke
parents:
diff changeset
   338
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   339
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   340
02bb8761fcce Initial load
duke
parents:
diff changeset
   341
    public static void main(String[] args) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   342
        ORBD orbd = new ORBD();
02bb8761fcce Initial load
duke
parents:
diff changeset
   343
        orbd.run(args);
02bb8761fcce Initial load
duke
parents:
diff changeset
   344
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   345
02bb8761fcce Initial load
duke
parents:
diff changeset
   346
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   347
     * List of servers to be auto registered and started by the ORBd.
02bb8761fcce Initial load
duke
parents:
diff changeset
   348
     *
02bb8761fcce Initial load
duke
parents:
diff changeset
   349
     * Each server entry is of the form {id, name, path, args, vmargs}.
02bb8761fcce Initial load
duke
parents:
diff changeset
   350
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   351
    private static String[][] orbServers = {
02bb8761fcce Initial load
duke
parents:
diff changeset
   352
        {""}
02bb8761fcce Initial load
duke
parents:
diff changeset
   353
    };
02bb8761fcce Initial load
duke
parents:
diff changeset
   354
}