SingleLineClient.java



/** RemoteDictionaryのクライアントのクラス */
import java.util.*;
import org.omg.CORBA.*;
import org.omg.CosNaming.*;
public class SingleLineClient {

  /** 最初に呼び出されるルーチン */
    public static void main( String argv[] ) {
        try {
        // 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 );
            org.omg.CORBA.Object service
               = orb.resolve_initial_references( "NameService" );
            NamingContext ncnt
               = NamingContextHelper.narrow( service );
            NameComponent ncmp = new NameComponent( "RemoteDictionary", "" );
            NameComponent path[] = { ncmp };

        // 分散オブジェクトの取得
            RemoteDictionary dictionary
               = RemoteDictionaryHelper.narrow( ncnt.resolve( path ) );

        // 分散オブジェクトのメソッドの呼び出し
            String value = dictionary.answer( argv[1] );
            System.out.println( value );
        }
        catch( Exception e ) {
            System.err.println( "Error:" + e.toString() );
            System.exit(-1);
        }
    }
}