tnameserv
NAMEJava IDL Transient Naming Service
Starting the Java IDL Transient Naming Service
Stopping the Java IDL Transient Naming Service
Sample Client: Adding Objects to the Namespace
Sample Client: Browsing the Namespace
NAME
Java IDL: Transient Naming Service − tnameserv
This document
discusses using the Java IDL Transient Naming Service,
tnameserv. Java IDL also includes the Object Request
Broker Daemon (ORBD). ORBD is a daemon process containing a
Bootstrap Service, a Transient Naming Service, a
Persistent Naming Service, and a Server Manager. The
Java IDL tutorials all use ORBD, however, you can substitute
tnameserv for orbd in any of the examples that
use a Transient Naming Service. For documentation on the
orbd tool, link to its man page or the Java IDL
Naming Service Included with ORBD @
http://java.sun.com/javase/6/docs/technotes/guides/idl/jidlNaming.html
topic.
Topics in this section include:
o |
Java IDL Transient Naming Service |
|||
o |
Starting the Java IDL Transient Naming Service |
|||
o |
Stopping the Java IDL Transient Naming Service |
|||
o |
Sample Client: Adding Objects to the Namespace |
|||
o |
Sample Client: Browsing the Namespace |
Java IDL Transient Naming Service
The CORBA COS (Common Object Services) Naming Service provides a tree−like directory for object references much like a filesystem 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 namespace by name and each object reference−name pair is called a name binding. Name bindings may be organized under naming contexts. Naming contexts are themselves 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 namespace; the rest of the namespace is lost if the Java IDL naming service process halts 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 a stringified initial naming context for that naming service. The naming service can either be the Java IDL naming service or another COS−compliant naming service.
Starting the Java IDL Transient 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 (Solaris: tnameserv) or executable file (Windows NT: 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, 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, port 900 is used by default. When running Solaris software, you must become root to start a process on a port under 1024. For this reason, we recommend 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:
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 creating the ORB object.
Running 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, it is likely
that the client and server will run on different host
machines than 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 The Hello World Example Using RMI−IIOP
@
http://java.sun.com/javase/6/docs/technotes/guides/rmi−iiop/rmiiiopexample.html.
You could also use the command line options
−ORBInitialPort nameserverport# and
−ORBInitialHost nameserverhostname to tell the
client and server where to find the Naming Service. Java
IDL: Running the Hello World Example on TWO Machines @
http://java.sun.com/javase/6/docs/technotes/guides/idl/tutorial/jidl2machines.html
shows one way of doing this using the command line
option.
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.
o |
Start tnameserv on the host nameserverhost, as follows: |
tnameserv −ORBInitialPort 1050
o |
Start the server on the serverhost, as follows: |
java Server −ORBInitialPort 1050 −ORBInitialHost nameserverhost
o |
Start the client on the clienthost, as follows: |
java Client −ORBInitialPort 1050 −ORBInitialHost nameserverhost
The −J
option
This command−line option is available for use with
tnameserve:
−Joption
Pass option to the Java
virtual machine, where option is one of the options
described on the reference page for the java application
launcher @
http://java.sun.com/javase/6/docs/technotes/tools/solaris/java.html.
For example, −J−Xms48m sets the startup
memory to 48 megabytes. It is a common convention for
−J to pass options to the underlying virtual
machine.
Stopping the Java IDL Transient Naming Service
To stop the Java IDL naming service, use the relevant operating system command, such as kill for a Unix process, or Ctrl−C for a Windows process. The naming service will continue to wait for invocations until it is explicitly shutdown. Note that names registered with the Java IDL naming service disappear when the service is terminated.
Sample Client: Adding Objects to the Namespace
The following sample program illustrates how to add names to the namespace. 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.
import
java.util.Properties;
import org.omg.CORBA.*;
import org.omg.CosNaming.*;
public class
NameClient
{
public static void main(String args[])
{
try {
In the above
section, Starting the Java IDL Transient Naming Service, the
nameserver was started on port 1050. The following code
ensures that the client program is aware of this port
number.
Properties props = new Properties();
props.put("org.omg.CORBA.ORBInitialPort",
"1050");
ORB orb = ORB.init(args, props);
This code
obtains the initial naming context and assigns it to
ctx. The second line copies ctx into a dummy
object reference objref that we’ll attach to
various names and add into the namespace.
NamingContext ctx =
NamingContextHelper.narrow(orb.resolve_initial_references("NameService"));
NamingContext objref = ctx;
This code
creates a name "plans" of type "text"
and binds it to our dummy object reference.
"plans" is then added under the initial naming
context using rebind. The rebind method allows
us to run this program over and over again without getting
the exceptions we’d get from using bind.
NameComponent nc1 = new NameComponent("plans",
"text");
NameComponent[] name1 = {nc1};
ctx.rebind(name1, objref);
System.out.println("plans rebind
sucessful!");
This code
creates a naming context called "Personal" of type
"directory". The resulting object reference,
ctx2, is bound to the name and added under the
initial naming context.
NameComponent nc2 = new NameComponent("Personal",
"directory");
NameComponent[] name2 = {nc2};
NamingContext ctx2 = ctx.bind_new_context(name2);
System.out.println("new naming context
added..");
The remainder
of the code binds the dummy object reference using the names
"schedule" and "calendar" under the
"Personal" naming context (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);
}
}
}
Sample Client: Browsing the Namespace
The following sample program illustrates how to browse the namespace.
import
java.util.Properties;
import org.omg.CORBA.*;
import org.omg.CosNaming.*;
public class
NameClientList
{
public static void main(String args[])
{
try {
In the above section, Starting the Java IDL Transient Naming Service, the nameserver was started on port 1050. The following code ensures that the client program is aware of this port number.
Properties
props = new Properties();
props.put("org.omg.CORBA.ORBInitialPort",
"1050");
ORB orb = ORB.init(args, props);
The following
code obtains the intial naming context.
NamingContext nc =
NamingContextHelper.narrow(orb.resolve_initial_references("NameService"));
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.
BindingListHolder bl = new BindingListHolder();
BindingIteratorHolder blIt= new BindingIteratorHolder();
nc.list(1000, bl, blIt);
This code gets
the array of bindings out of the returned BindingListHolder.
If there are no bindings, the program ends.
Binding bindings[] = bl.value;
if (bindings.length == 0) return;
The remainder
of the code loops through the bindings and prints the names
out.
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);
}
}
}
More Linux Commands
manpages/lgammal.3.html
lgammal(3) - log gamma function (Library - Linux man page)
For the definition of the Gamma function, see tgamma(3). The lgamma() function returns the natural logarithm of the absolute value of the Gamma function. The si
manpages/printenv.1.html
printenv(1) - print all or part of environment (Man Page)...
Print the values of the specified environment VARIABLE(s). If no VARIABLE is specified, print name and value pairs for them all. -0, --null end each output line
manpages/glNormal3dv.3gl.html
glNormal3dv(3gl) - set the current normal vector (Man Page)
The current normal is set to the given coordinates whenever glNormal is issued. Byte, short, or integer arguments are converted to floating-point with a linear
manpages/remquol.3.html
remquol(3) - remainder and part of quotient - Linux man page
These functions compute the remainder and part of the quotient upon division of x by y. A few bits of the quotient are stored via the quo pointer. The remainder
manpages/gzexe.1.html
gzexe(1) - compress executable files in place (Man Page)....
The gzexe utility allows you to compress executables in place and have them automatically uncompress and execute when you run them (at a penalty in performance)
manpages/gnutls_certificate_set_rsa_export_params.3.html
gnutls_certificate_set_rsa_export_params(3) - API function
This function will set the temporary RSA parameters for a certificate server to use. These parameters will be used in RSA-EXPORT cipher suites. REPORTING BUGS R
manpages/jnl.3.html
jnl(3) - Bessel functions of the first kind - Linux man page
The j0() and j1() functions return Bessel functions of x of the first kind of orders 0 and 1, respectively. The jn() function returns the Bessel function of x o
manpages/glMap2f.3gl.html
glMap2f(3gl) - define a two-dimensional evaluator (ManPage)
Evaluators provide a way to use polynomial or rational polynomial mapping to produce vertices, normals, texture coordinates, and colors. The values produced by
manpages/items.3menu.html
items(3menu) - make and break connections between items and
The function set_menu_items changes the item pointer array of the given menu. The array must be terminated by a NULL. The function menu_items returns the item a
manpages/fesetround.3.html
fesetround(3) - floating-point rounding and exception handli
These eleven functions were defined in C99, and describe the handling of floating-point rounding and exceptions (overflow, zero-divide, etc.). Exceptions The di
manpages/x25.7.html
x25(7) - ITU-T X.25 / ISO-8208 protocol interface. (ManPage)
X25 sockets provide an interface to the X.25 packet layer protocol. This allows applications to communicate over a public X.25 data network as standardized by I
manpages/Tk_FreeXId.3.html
Tk_FreeXId(3) - make X resource identifier available for reu
The default allocator for resource identifiers provided by Xlib is very simple-minded and does not allow resource identifiers to be re-used. If a long-running a
