tnameserv

Synopsis

The initial port where the naming service listens for the bootstrap protocol used to implement the ORB resolve_initial_references and list_initial_references methods.

Description

Java IDL includes the Object Request Broker Daemon (ORBD). ORBD is a daemon process that contains a Bootstrap Service, a Transient Naming Service, a Persistent Naming Service, and a Server Manager. The Java IDL tutorials all use ORBD, but you can substitute the tnameserv command for the orbd command in any of the examples that use a Transient Naming Service.

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, tnameserv, 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.

Start the Naming Service

You must start the Java IDL naming service before an application or applet that uses its naming service. Installation of the Java IDL product creates a script (Oracle Solaris: tnameserv) or executable file (Windows: tnameserv.exe) that starts the Java IDL naming service. Start the naming service so it runs in the background.

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 resolve_initial_references and list_initial_references methods, as follows:

tnameserv -ORBInitialPort nameserverport&

If 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 Solaris, Linux, or OS X command shell, enter:

tnameserv -ORBInitialPort 1050&

From an MS-DOS system prompt (Windows), enter:

start tnameserv -ORBInitialPort 1050

Clients of the name server must be made aware of the new port number. Do this by setting the org.omg.CORBA.ORBInitialPort property to the new port number when you create the ORB object.

Run the Server and Client on Different Hosts

In most of the Java IDL and RMI-IIOP tutorials, the naming service, server, and client are all running on the development machine. In real-world deployment, the client and server probably run on different host machines from the Naming Service.

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 org.omg.CORBA.ORBInitialPort and org.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 athttp://docs.oracle.com/javase/8/docs/technotes/guides/rmi-iiop/rmiiiopexample.html

For example, suppose the Transient Naming Service, tnameserv is running on port 1050 on host nameserverhost. The client is running on host clienthost, and the server is running on host serverhost.

Start tnameserv on the host nameserverhost:

tnameserv -ORBInitialPort 1050

Start the server on the serverhost:

java Server -ORBInitialPort 1050 -ORBInitialHost nameserverhost

Start the client on the clienthost:

java Client -ORBInitialPort 1050 -ORBInitialHost nameserverhost

Stop the Naming Service

To stop the Java IDL naming service, use the relevant operating system command, such as kill for a Solaris, Linux, or OS X process or Ctrl+C for a Windows process. The naming service continues to wait for invocations until it is explicitly shut down. Note that names registered with the Java IDL naming service disappear when the service is terminated.

Options

-Joption

Passes option to the Java Virtual Machine, where option is one of the options described on the reference page for the Java application launcher. For example, -J-Xms48m sets the startup memory to 48 MB. See java(1).

Examples

Add Objects to the Name Space

The following example shows how to add names to the name space. It is a self-contained Transient Naming Service client that creates the following simple tree.

Initial Naming Context
plans
Personal
calendar
schedule

In this example, plans is an object reference and Personal is a naming context that contains two object references: calendar and schedule.

This code creates a name plans of type text and binds it to the dummy object reference. plans is then added under the initial naming context using the rebind method. The rebind method enables you to run this program over and over again without getting the exceptions from using the bind method.

The list 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 BindingListHolder; any remaining bindings are returned in the BindingIteratorHolder.