tnameserv.1 16.4 KB
Newer Older
R
rgallard 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489
'\" t
.\"  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
.\"
.if n .pl 99999
.TH tnameserv 1 "21 November 2013" "JDK 8" "Java IDL and RMI-IIOP Tools"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------

.SH NAME    
tnameserv \- Interface Definition Language (IDL)\&.
.SH SYNOPSIS    
.sp     
.nf     

\fBtnameserve\fR \fB\-ORBInitialPort\fR [ \fInameserverport\fR ]
.fi     
.sp     
.TP
-ORBInitialPort \fInameserverport\fR
.br
The initial port where the naming service listens for the bootstrap protocol used to implement the ORB \f3resolve_initial_references\fR and \f3list_initial_references\fR methods\&.
.SH 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 \f3tnameserv\fR command for the \f3orbd\fR command in any of the examples that use a Transient Naming Service\&.
.PP
See orbd(1) or Naming Service at http://docs\&.oracle\&.com/javase/8/docs/technotes/guides/idl/jidlNaming\&.html
.PP
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\fR, is a simple implementation of the COS Naming Service specification\&.
.PP
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\&.
.PP
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\&.
.SS 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: \f3tnameserv\fR) or executable file (Windows: \f3tnameserv\&.exe\fR) that starts the Java IDL naming service\&. Start the naming service so it runs in the background\&.
.PP
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\fR and \f3list_initial_references methods\fR, as follows:
.sp     
.nf     
\f3tnameserv \-ORBInitialPort nameserverport&\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
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 UNIX command shell, enter:
.sp     
.nf     
\f3tnameserv \-ORBInitialPort 1050&\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
From an MS-DOS system prompt (Windows), enter:
.sp     
.nf     
\f3start tnameserv \-ORBInitialPort 1050\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
Clients of the name server must be made aware of the new port number\&. Do this by setting the \f3org\&.omg\&.CORBA\&.ORBInitialPort\fR property to the new port number when you create the ORB object\&.
.SS 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\&.
.PP
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\fR and \f3org\&.omg\&.CORBA\&.ORBInitialHost\fR 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
.PP
You could also use the command-line options \f3-ORBInitialPort nameserverport#\fR and \f3-ORBInitialHost nameserverhostname\fR 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
.PP
For example, suppose the Transient Naming Service, \f3tnameserv\fR is running on port 1050 on host \f3nameserverhost\fR\&. The client is running on host \f3clienthost,\fR and the server is running on host \f3serverhost\fR\&.
.PP
Start \f3tnameserv\fR on the host \f3nameserverhost\fR:
.sp     
.nf     
\f3tnameserv \-ORBInitialPort 1050\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
Start the server on the \f3serverhost\fR:
.sp     
.nf     
\f3java Server \-ORBInitialPort 1050 \-ORBInitialHost nameserverhost\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
Start the client on the \f3clienthost\fR:
.sp     
.nf     
\f3java Client \-ORBInitialPort 1050 \-ORBInitialHost nameserverhost\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
.SS STOP\ THE\ NAMING\ SERVICE    
To stop the Java IDL naming service, use the relevant operating system command, such as \f3kill\fR for a Unix process or \f3Ctrl+C\fR 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\&.
.SH OPTIONS    
.TP
-J\fIoption\fR
.br
Passes \f3option\fR to the Java Virtual Machine, where \f3option\fR is one of the options described on the reference page for the Java application launcher\&. For example, \f3-J-Xms48m\fR sets the startup memory to 48 MB\&. See java(1)\&.
.SH EXAMPLES    
.SS 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\&.
.sp     
.nf     
\f3Initial Naming Context\fP
.fi     
.nf     
\f3     plans\fP
.fi     
.nf     
\f3     Personal\fP
.fi     
.nf     
\f3          calendar\fP
.fi     
.nf     
\f3          schedule\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
In this example, \f3plans\fR is an object reference and \f3Personal\fR is a naming context that contains two object references: \f3calendar\fR and \f3schedule\fR\&.
.sp     
.nf     
\f3import java\&.util\&.Properties;\fP
.fi     
.nf     
\f3import org\&.omg\&.CORBA\&.*;\fP
.fi     
.nf     
\f3import org\&.omg\&.CosNaming\&.*;\fP
.fi     
.nf     
\f3\fP
.fi     
.nf     
\f3public class NameClient {\fP
.fi     
.nf     
\f3\fP
.fi     
.nf     
\f3    public static void main(String args[]) {\fP
.fi     
.nf     
\f3\fP
.fi     
.nf     
\f3        try {\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
In Start the Naming Service, the \f3nameserver\fR was started on port 1050\&. The following code ensures that the client program is aware of this port number\&.
.sp     
.nf     
\f3            Properties props = new Properties();\fP
.fi     
.nf     
\f3            props\&.put("org\&.omg\&.CORBA\&.ORBInitialPort", "1050");\fP
.fi     
.nf     
\f3            ORB orb = ORB\&.init(args, props);\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
This code obtains the initial naming context and assigns it to \f3ctx\fR\&. The second line copies \f3ctx\fR into a dummy object reference \f3objref\fR that is attached to various names and added into the name space\&.
.sp     
.nf     
\f3            NamingContext ctx =\fP
.fi     
.nf     
\f3                NamingContextHelper\&.narrow(\fP
.fi     
.nf     
\f3                    orb\&.resolve_initial_references("NameService"));\fP
.fi     
.nf     
\f3             NamingContext objref = ctx;\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
This code creates a name \f3plans\fR of type \f3text\fR and binds it to the dummy object reference\&. \f3plans\fR is then added under the initial naming context using the \f3rebind\fR method\&. The \f3rebind\fR method enables you to run this program over and over again without getting the exceptions from using the \f3bind\fR method\&.
.sp     
.nf     
\f3            NameComponent nc1 = new NameComponent("plans", "text");\fP
.fi     
.nf     
\f3            NameComponent[] name1 = {nc1};\fP
.fi     
.nf     
\f3            ctx\&.rebind(name1, objref);\fP
.fi     
.nf     
\f3            System\&.out\&.println("plans rebind successful!");\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
This code creates a naming context called \f3Personal\fR of type \f3directory\fR\&. The resulting object reference, \f3ctx2\fR, is bound to the \f3name\fR and added under the initial naming context\&.
.sp     
.nf     
\f3            NameComponent nc2 = new NameComponent("Personal", "directory");\fP
.fi     
.nf     
\f3            NameComponent[] name2 = {nc2};\fP
.fi     
.nf     
\f3            NamingContext ctx2 = ctx\&.bind_new_context(name2);\fP
.fi     
.nf     
\f3            System\&.out\&.println("new naming context added\&.\&.");\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
The remainder of the code binds the dummy object reference using the names \f3schedule\fR and \f3calendar\fR under the \f3Personal\fR naming context (\f3ctx2\fR)\&.
.sp     
.nf     
\f3            NameComponent nc3 = new NameComponent("schedule", "text");\fP
.fi     
.nf     
\f3            NameComponent[] name3 = {nc3};\fP
.fi     
.nf     
\f3            ctx2\&.rebind(name3, objref);\fP
.fi     
.nf     
\f3            System\&.out\&.println("schedule rebind successful!");\fP
.fi     
.nf     
\f3\fP
.fi     
.nf     
\f3            NameComponent nc4 = new NameComponent("calender", "text");\fP
.fi     
.nf     
\f3            NameComponent[] name4 = {nc4};\fP
.fi     
.nf     
\f3            ctx2\&.rebind(name4, objref);\fP
.fi     
.nf     
\f3            System\&.out\&.println("calender rebind successful!");\fP
.fi     
.nf     
\f3        } catch (Exception e) {\fP
.fi     
.nf     
\f3            e\&.printStackTrace(System\&.err);\fP
.fi     
.nf     
\f3        }\fP
.fi     
.nf     
\f3    }\fP
.fi     
.nf     
\f3}\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
.SS BROWSING\ THE\ NAME\ SPACE    
The following sample program shoes how to browse the name space\&.
.sp     
.nf     
\f3import java\&.util\&.Properties;\fP
.fi     
.nf     
\f3import org\&.omg\&.CORBA\&.*;\fP
.fi     
.nf     
\f3import org\&.omg\&.CosNaming\&.*;\fP
.fi     
.nf     
\f3\fP
.fi     
.nf     
\f3public class NameClientList {\fP
.fi     
.nf     
\f3\fP
.fi     
.nf     
\f3    public static void main(String args[]) {\fP
.fi     
.nf     
\f3\fP
.fi     
.nf     
\f3        try {\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
In Start the Naming Service, the \f3nameserver\fR was started on port 1050\&. The following code ensures that the client program is aware of this port number\&.
.sp     
.nf     
\f3            Properties props = new Properties();\fP
.fi     
.nf     
\f3            props\&.put("org\&.omg\&.CORBA\&.ORBInitialPort", "1050");\fP
.fi     
.nf     
\f3            ORB orb = ORB\&.init(args, props);\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
The following code obtains the initial naming context\&.
.sp     
.nf     
\f3            NamingContext nc =\fP
.fi     
.nf     
\f3            NamingContextHelper\&.narrow(\fP
.fi     
.nf     
\f3                orb\&.resolve_initial_references("NameService"));\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
The \f3list\fR 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\fR; any remaining bindings are returned in the \f3BindingIteratorHolder\fR\&.
.sp     
.nf     
\f3            BindingListHolder bl = new BindingListHolder();\fP
.fi     
.nf     
\f3            BindingIteratorHolder blIt= new BindingIteratorHolder();\fP
.fi     
.nf     
\f3            nc\&.list(1000, bl, blIt);\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
This code gets the array of bindings out of the returned \f3BindingListHolder\fR\&. If there are no bindings, then the program ends\&.
.sp     
.nf     
\f3            Binding bindings[] = bl\&.value;\fP
.fi     
.nf     
\f3            if (bindings\&.length == 0) return;\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
The remainder of the code loops through the bindings and prints outs the names\&.
.sp     
.nf     
\f3            for (int i=0; i < bindings\&.length; i++) {\fP
.fi     
.nf     
\f3\fP
.fi     
.nf     
\f3                // get the object reference for each binding\fP
.fi     
.nf     
\f3                org\&.omg\&.CORBA\&.Object obj = nc\&.resolve(bindings[i]\&.binding_name);\fP
.fi     
.nf     
\f3                String objStr = orb\&.object_to_string(obj);\fP
.fi     
.nf     
\f3                int lastIx = bindings[i]\&.binding_name\&.length\-1;\fP
.fi     
.nf     
\f3\fP
.fi     
.nf     
\f3                // check to see if this is a naming context\fP
.fi     
.nf     
\f3                if (bindings[i]\&.binding_type == BindingType\&.ncontext) {\fP
.fi     
.nf     
\f3                    System\&.out\&.println("Context: " +\fP
.fi     
.nf     
\f3                        bindings[i]\&.binding_name[lastIx]\&.id);\fP
.fi     
.nf     
\f3                } else {\fP
.fi     
.nf     
\f3                    System\&.out\&.println("Object: " +\fP
.fi     
.nf     
\f3                        bindings[i]\&.binding_name[lastIx]\&.id);\fP
.fi     
.nf     
\f3                }\fP
.fi     
.nf     
\f3            }\fP
.fi     
.nf     
\f3        } catch (Exception e) {\fP
.fi     
.nf     
\f3            e\&.printStackTrace(System\&.err)\fP
.fi     
.nf     
\f3        }\fP
.fi     
.nf     
\f3    }\fP
.fi     
.nf     
\f3}\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
.SH SEE\ ALSO    
.TP 0.2i    
\(bu
orbd(1)
.RE
.br
'pl 8.5i
'bp