Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License version 2 only, as
published by the Free Software Foundation.
This code is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
version 2 for more details (a copy is included in the LICENSE file that
accompanied this code).
You should have received a copy of the GNU General Public License version
2 along with this work; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
or visit www.oracle.com if you need additional information or have any
questions.
Arch: generic
Software: JDK 8
Date: 21 November 2013
SectDesc: Java IDL and RMI-IIOP Tools
Title: tnameserv.1
* Define some portability stuff
-----------------------------------------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://bugs.debian.org/507673
http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-----------------------------------------------------------------
* set default formatting
-----------------------------------------------------------------
disable hyphenation
disable justification (adjust text to left margin only)
-----------------------------------------------------------------
* MAIN CONTENT STARTS HERE *
-----------------------------------------------------------------
tnameserve -ORBInitialPort [ nameserverport ]
-ORBInitialPort nameserverport
The initial port where the naming service listens for the bootstrap protocol used to implement the ORB \f3resolve_initial_references and \f3list_initial_references methods.
See orbd(1) or Naming Service at http://docs.oracle.com/javase/8/docs/technotes/guides/idl/jidlNaming.html
The CORBA Common Object Services (COS) Naming Service provides a tree-structure directory for object references similar to a file system that provides a directory structure for files. The Transient Naming Service provided with Java IDL, \f3tnameserv, is a simple implementation of the COS Naming Service specification.
Object references are stored in the name space by name and each object reference-name pair is called a name binding. Name bindings can be organized under naming contexts. Naming contexts are name bindings and serve the same organizational function as a file system subdirectory. All bindings are stored under the initial naming context. The initial naming context is the only persistent binding in the name space. The rest of the name space is lost when the Java IDL naming service process stops and restarts.
For an applet or application to use COS naming, its ORB must know the port of a host running a naming service or have access to an initial naming context string for that naming service. The naming service can either be the Java IDL naming service or another COS-compliant naming service.
If you do not specify otherwise, then the Java IDL naming service listens on port 900 for the bootstrap protocol used to implement the ORB \f3resolve_initial_references and \f3list_initial_references methods, as follows:
\f3tnameserv -ORBInitialPort nameserverport&
\f3If you do not specify the name server port, then port 900 is used by default. When running Oracle Solaris software, you must become the root user to start a process on a port below 1024. For this reason, it is recommended that you use a port number greater than or equal to 1024. To specify a different port, for example, 1050, and to run the naming service in the background, from a UNIX command shell, enter:
\f3tnameserv -ORBInitialPort 1050&
\f3From an MS-DOS system prompt (Windows), enter:
\f3start tnameserv -ORBInitialPort 1050
\f3Clients of the name server must be made aware of the new port number. Do this by setting the \f3org.omg.CORBA.ORBInitialPort property to the new port number when you create the ORB object.
For the client and server to find the Naming Service, they must be made aware of the port number and host on which the naming service is running. Do this by setting the \f3org.omg.CORBA.ORBInitialPort and \f3org.omg.CORBA.ORBInitialHost properties in the client and server files to the machine name and port number on which the Naming Service is running. An example of this is shown in Getting Started Using RMI-IIOP at http://docs.oracle.com/javase/8/docs/technotes/guides/rmi-iiop/rmiiiopexample.html
You could also use the command-line options \f3-ORBInitialPort nameserverport# and \f3-ORBInitialHost nameserverhostname to tell the client and server where to find the naming service. For one example of doing this using the command-line option, see Java IDL: The Hello World Example on Two Machines at http://docs.oracle.com/javase/8/docs/technotes/guides/idl/tutorial/jidl2machines.html
For example, suppose the Transient Naming Service, \f3tnameserv is running on port 1050 on host \f3nameserverhost. The client is running on host \f3clienthost, and the server is running on host \f3serverhost.
Start \f3tnameserv on the host \f3nameserverhost:
\f3tnameserv -ORBInitialPort 1050
\f3Start the server on the \f3serverhost:
\f3java Server -ORBInitialPort 1050 -ORBInitialHost nameserverhost
\f3Start the client on the \f3clienthost:
\f3java Client -ORBInitialPort 1050 -ORBInitialHost nameserverhost
\f3
-Joption
Passes \f3option to the Java Virtual Machine, where \f3option is one of the options described on the reference page for the Java application launcher. For example, \f3-J-Xms48m sets the startup memory to 48 MB. See java(1).
\f3Initial Naming Context
\f3 plans
\f3 Personal
\f3 calendar
\f3 schedule
\f3In this example, \f3plans is an object reference and \f3Personal is a naming context that contains two object references: \f3calendar and \f3schedule.
\f3import java.util.Properties;
\f3import org.omg.CORBA.*;
\f3import org.omg.CosNaming.*;
\f3
\f3public class NameClient {
\f3
\f3 public static void main(String args[]) {
\f3
\f3 try {
\f3In Start the Naming Service, the \f3nameserver was started on port 1050. The following code ensures that the client program is aware of this port number.
\f3 Properties props = new Properties();
\f3 props.put("org.omg.CORBA.ORBInitialPort", "1050");
\f3 ORB orb = ORB.init(args, props);
\f3This code obtains the initial naming context and assigns it to \f3ctx. The second line copies \f3ctx into a dummy object reference \f3objref that is attached to various names and added into the name space.
\f3 NamingContext ctx =
\f3 NamingContextHelper.narrow(
\f3 orb.resolve_initial_references("NameService"));
\f3 NamingContext objref = ctx;
\f3This code creates a name \f3plans of type \f3text and binds it to the dummy object reference. \f3plans is then added under the initial naming context using the \f3rebind method. The \f3rebind method enables you to run this program over and over again without getting the exceptions from using the \f3bind method.
\f3 NameComponent nc1 = new NameComponent("plans", "text");
\f3 NameComponent[] name1 = {nc1};
\f3 ctx.rebind(name1, objref);
\f3 System.out.println("plans rebind successful!");
\f3This code creates a naming context called \f3Personal of type \f3directory. The resulting object reference, \f3ctx2, is bound to the \f3name and added under the initial naming context.
\f3 NameComponent nc2 = new NameComponent("Personal", "directory");
\f3 NameComponent[] name2 = {nc2};
\f3 NamingContext ctx2 = ctx.bind_new_context(name2);
\f3 System.out.println("new naming context added..");
\f3The remainder of the code binds the dummy object reference using the names \f3schedule and \f3calendar under the \f3Personal naming context (\f3ctx2).
\f3 NameComponent nc3 = new NameComponent("schedule", "text");
\f3 NameComponent[] name3 = {nc3};
\f3 ctx2.rebind(name3, objref);
\f3 System.out.println("schedule rebind successful!");
\f3
\f3 NameComponent nc4 = new NameComponent("calender", "text");
\f3 NameComponent[] name4 = {nc4};
\f3 ctx2.rebind(name4, objref);
\f3 System.out.println("calender rebind successful!");
\f3 } catch (Exception e) {
\f3 e.printStackTrace(System.err);
\f3 }
\f3 }
\f3}
\f3
\f3import java.util.Properties;
\f3import org.omg.CORBA.*;
\f3import org.omg.CosNaming.*;
\f3
\f3public class NameClientList {
\f3
\f3 public static void main(String args[]) {
\f3
\f3 try {
\f3In Start the Naming Service, the \f3nameserver was started on port 1050. The following code ensures that the client program is aware of this port number.
\f3 Properties props = new Properties();
\f3 props.put("org.omg.CORBA.ORBInitialPort", "1050");
\f3 ORB orb = ORB.init(args, props);
\f3The following code obtains the initial naming context.
\f3 NamingContext nc =
\f3 NamingContextHelper.narrow(
\f3 orb.resolve_initial_references("NameService"));
\f3The \f3list method lists the bindings in the naming context. In this case, up to 1000 bindings from the initial naming context will be returned in the \f3BindingListHolder; any remaining bindings are returned in the \f3BindingIteratorHolder.
\f3 BindingListHolder bl = new BindingListHolder();
\f3 BindingIteratorHolder blIt= new BindingIteratorHolder();
\f3 nc.list(1000, bl, blIt);
\f3This code gets the array of bindings out of the returned \f3BindingListHolder. If there are no bindings, then the program ends.
\f3 Binding bindings[] = bl.value;
\f3 if (bindings.length == 0) return;
\f3The remainder of the code loops through the bindings and prints outs the names.
\f3 for (int i=0; i < bindings.length; i++) {
\f3
\f3 // get the object reference for each binding
\f3 org.omg.CORBA.Object obj = nc.resolve(bindings[i].binding_name);
\f3 String objStr = orb.object_to_string(obj);
\f3 int lastIx = bindings[i].binding_name.length-1;
\f3
\f3 // check to see if this is a naming context
\f3 if (bindings[i].binding_type == BindingType.ncontext) {
\f3 System.out.println("Context: " +
\f3 bindings[i].binding_name[lastIx].id);
\f3 } else {
\f3 System.out.println("Object: " +
\f3 bindings[i].binding_name[lastIx].id);
\f3 }
\f3 }
\f3 } catch (Exception e) {
\f3 e.printStackTrace(System.err)
\f3 }
\f3 }
\f3}
\f3
0.2i orbd(1)
'pl 8.5i 'bp