DictionaryServer.java



/** メッセージを送信するクラス */
import java.util.*;
import org.omg.CORBA.*;
import org.omg.CosNaming.*;
public class DictionaryServer {

  /** 起動時に呼び出されるメソッド */
    public static void main( String argv[] ) {
        try {
        // 分散オブジェクトの生成
            RemoteDictionaryImpl dictionary
                = new RemoteDictionaryImpl();

        // ORBへの登録
            Properties props = new Properties();
            props.put( "org.omg.CORBA.ORBInitialHost", argv[0] );
            props.put( "org.omg.CORBA.ORBInitialPort", "10005" );
            ORB orb = ORB.init( argv, props );
            orb.connect( dictionary );
            org.omg.CORBA.Object service
                = orb.resolve_initial_references( "NameService" );
            NamingContext ncnt = NamingContextHelper.narrow( service );
            NameComponent ncmp
                = new NameComponent( "RemoteDictionary", "" );
            NameComponent path[] = { ncmp };
            ncnt.rebind( path, dictionary );

        // スレッドの処理を終了させないため
            java.lang.Object sync = new java.lang.Object();
            synchronized( sync ) {
                sync.wait();
            }
        }
        catch( Exception e ) {
              System.err.println( "Error:" + e.toString() );
        }
    }
}