Documentation Contents

Java IDL:??????????????????????????? - tnameserv


?????????????????????????????????Java IDL ??????????????????????????? tnameserv ?????????????????????????????????????????????Java IDL ?????????Object Request Broker Daemon (ORBD) ???????????????????????????ORBD ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????Java IDL ?????????????????????????????????????????? ORBD ????????????????????????????????????????????????????????????????????????????????????orbd ??????????????? tnameserv ????????????????????????orbd ????????????????????????????????????orbd ??? ?????????????????????????????????ORBD ??????????????? Java IDL ???????????????????????????????????????????????????????????????????????????

????????????????????????????????????????????????????????????

Java IDL ???????????????????????????

CORBA ??? COS (Common Object Services) ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????Java IDL ??????????????????????????????????????? tnameserv ??????COS ???????????????????????????????????????????????????????????????????????????

??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ??????????????????????????????????????????????????????Java IDL ????????????????????????????????????????????????????????????????????????????????????????????????

?????????????????????????????????????????????????????? COS ????????????????????????????????????????????????????????? ORB ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????Java IDL ?????????????????????????????????????????? COS ?????????????????????????????????????????????????????????

Java IDL ????????????????????????????????????

Java IDL ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????Java IDL ???????????????????????????????????????Java IDL ??????????????????????????????????????????????????? (Solaris: tnameserv) ?????????????????????????????? (Windows NT: tnameserv.exe) ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

??????????????????????????????Java IDL ???????????????????????????ORB ??? resolve_initial_references() ??????????????? list_initial_references() ???????????????????????????????????????????????????????????????????????????????????????????????? 900 ?????????????????????

	tnameserv -ORBInitialPort nameserverport&

???????????????????????????????????????????????????????????????????????????????????? 900 ????????????????????????Solaris ????????????????????????????????????1024 ???????????????????????????????????????????????????????????????root ????????????????????????????????????????????? ???????????????1024 ????????? 1024 ????????????????????????????????????????????????????????????????????? 1050 ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????UNIX ?????????????????????????????????????????????????????????

	tnameserv -ORBInitialPort 1050&

Windows ??? MS-DOS ?????????????????????????????????????????????????????????????????????

	start tnameserv -ORBInitialPort 1050

?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????ORB ????????????????????????????????? org.omg.CORBA.ORBInitialPort ??????????????????????????????????????????????????????????????????

?????????????????????????????????????????????????????????????????????

Java IDL ??? RMI-IIOP ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? org.omg.CORBA.ORBInitialPort ????????????????????? org.omg.CORBA.ORBInitialHost ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????RMI-IIOP ???????????? Hello World ?????????????????????????????????????????????????????????????????? -ORBInitialPort nameserverport# ??? -ORBInitialHost nameserverhostname ?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????Java IDL: 2 ????????????????????????????????? Hello World ?????????????????? ???????????????????????????????????????????????????????????????????????????????????????????????????

?????????????????????????????????????????? tnameserv ??????????????? nameserverhost ???????????? 1050 ???????????????????????????????????????????????????????????????????????????????????? clienthost ????????????????????????????????????????????? serverhost ??????????????????????????????????????????

-J ???????????????

??????????????????????????????????????????tnameserve ?????????????????????????????????
-Joption
Java ?????????????????? option ?????????????????? option ????????????Java ?????????????????????????????????????????????????????????????????????????????????????????????????????????????????? 1 ????????????????????????????????????-J-Xms48m ????????????????????????????????????????????????????????? 48M ?????????????????????????????????-J ???????????????????????????????????????????????????????????????????????????????????????????????????

Java IDL ????????????????????????????????????

Java IDL ?????????????????????????????????????????????Unix ???????????????kill ????????????????????????????????????????????????????????????????????????Windows ???????????????Ctrl-C ?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????Java IDL ????????????????????????????????????????????????????????????????????????

??????????????????????????????:?????????????????????????????????????????????

?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????


                  ??????
               ?????????????????????????????????
                  /      \
                 /        \
              plans     Personal
                         /   \
                        /     \
                   calendar  schedule

???????????????plans ??????????????????????????????Personal ??? calendar ??? schedule ??? 2 ?????????????????????????????????????????????????????????????????????????????????

import java.util.Properties;
import org.omg.CORBA.*;
import org.omg.CosNaming.*;

public class NameClient
{
   public static void main(String args[])
   {
      try {
????????????Java IDL ?????????????????????????????????????????????????????????????????????????????? 1050 ???????????????????????????????????? ???????????????????????????????????????????????????????????????????????????????????????????????????
        Properties props = new Properties();
        props.put("org.omg.CORBA.ORBInitialPort", "1050");
        ORB orb = ORB.init(args, props);

??????????????????????????????????????????????????????????????????????????????????????? ctx ?????????????????????2 ???????????????ctx ??????????????????????????????????????? objref ???????????????????????? ?????? objref ??????????????????????????????????????????????????????????????????????????????????????????
        NamingContext ctx =
NamingContextHelper.narrow(orb.resolve_initial_references("NameService"));
        NamingContext objref = ctx;

????????????????????????text ???????????? plans ???????????????????????????????????????????????????????????????????????????????????????????????????rebind ??????????????????????????????????????????????????????????????? "plans" ???????????????????????????rebind ?????????????????????????????????bind ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
        NameComponent nc1 = new NameComponent("plans", "text");
        NameComponent[] name1 = {nc1};
        ctx.rebind(name1, objref);
        System.out.println("plans rebind sucessful!");

????????????????????????directory ?????? Personal ??????????????????????????????????????????????????????????????????????????????????????????????????????????????? ctx2 ????????????????????????????????????????????????????????????????????????????????????????????????
        NameComponent nc2 = new NameComponent("Personal", "directory");
        NameComponent[] name2 = {nc2};
        NamingContext ctx2 = ctx.bind_new_context(name2);
        System.out.println("new naming context added..");

?????????????????????????????????????????????????????????????????? schedule ??? calendar ??????????????????????????????????????????????????? "Personal" (ctx2) ???????????????????????????
        NameComponent nc3 = new NameComponent("schedule", "text");
        NameComponent[] name3 = {nc3};
        ctx2.rebind(name3, objref);
        System.out.println("schedule rebind sucessful!");

        NameComponent nc4 = new NameComponent("calender", "text");
        NameComponent[] name4 = {nc4};
        ctx2.rebind(name4, objref);
        System.out.println("calender rebind sucessful!");


    } catch (Exception e) {
        e.printStackTrace(System.err);
    }
  }
}

??????????????????????????????:???????????????????????????

???????????????????????????????????????????????????????????????????????????????????????????????????

import java.util.Properties;
import org.omg.CORBA.*;
import org.omg.CosNaming.*;

public class NameClientList
{
   public static void main(String args[])
   {
      try {
????????????Java IDL ?????????????????????????????????????????????????????????????????????????????? 1050 ???????????????????????????????????? ???????????????????????????????????????????????????????????????????????????????????????????????????

        Properties props = new Properties();
        props.put("org.omg.CORBA.ORBInitialPort", "1050");
        ORB orb = ORB.init(args, props);


??????????????????????????????????????????????????????????????????????????????????????????
        NamingContext nc =
NamingContextHelper.narrow(orb.resolve_initial_references("NameService"));

list ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? 1000 ????????????????????????????????????????????????????????????????????????????????? BindingListHolder ????????????????????? ????????????????????????????????????BindingIteratorHolder ?????????????????????
        BindingListHolder bl = new BindingListHolder();
        BindingIteratorHolder blIt= new BindingIteratorHolder();
        nc.list(1000, bl, blIt);

???????????????????????????????????? BindingListHolder ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
        Binding bindings[] = bl.value;
        if (bindings.length == 0) return;

??????????????????????????????????????????????????????????????????????????????????????????????????????????????????
        for (int i=0; i < bindings.length; i++) {

            // get the object reference for each binding
            org.omg.CORBA.Object obj = nc.resolve(bindings[i].binding_name);
            String objStr = orb.object_to_string(obj);
            int lastIx = bindings[i].binding_name.length-1;

            // check to see if this is a naming context
            if (bindings[i].binding_type == BindingType.ncontext) {
              System.out.println( "Context: " +
bindings[i].binding_name[lastIx].id);
            } else {
                System.out.println("Object: " +
bindings[i].binding_name[lastIx].id);
            }
        }

       } catch (Exception e) {
        e.printStackTrace(System.err);
       }
   }
}

Copyright © 1995-2010 Sun Microsystems, Inc. All Rights Reserved.

Please send comments using this Feedback page.
Sun Microsystems, Inc.
Java Technology