|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Interface Summary | |
BindingIterator | The BindingIterator interface allows a client to iterate through the bindings using the next_one or next_n operations. |
BindingIteratorOperations | org/omg/CosNaming/BindingIteratorOperations.java Generated by the IDL-to-Java compiler (portable), version "3.0" from nameservice.idl Wednesday, January 26, 2000 3:34:52 PM PST |
NamingContext | A naming context is an object that contains a set of name bindings in which each name is unique. |
NamingContextOperations | org/omg/CosNaming/NamingContextOperations.java Generated by the IDL-to-Java compiler (portable), version "3.0" from nameservice.idl Wednesday, January 26, 2000 3:34:53 PM PST |
Provides the naming service for Java IDL.
The package and all its classes and interfaces
were generated by running the tool idltojava
on the file
nameservice.idl
, which is a module written in OMG IDL.
The interfaces are:
These two interfaces provide the means to bind/unbind names and object
references, to retrieve bound object references, and
to iterate through a list of bindings. The NamingContext
interface supplies the main functionality for the naming service, and
BindingIterator
provides a means of iterating through a list
of name/object reference bindings.
NamingContext
and
BindingIterator
are included here.
NamingContext
and
BindingIterator
public final class NameComponent
--
a building block for names. (Names are bound to object references
in a naming context.)
A name is an array of one or more NameComponent
objects.
A name with a single NameComponent
is called
a simple name; a name with multiple NameComponent
objects is called a compound name.
A NameComponent
object consists of two fields:
id
-- a String
used as an identifier
kind
-- a String
that can be used for any
descriptive purpose. Its importance is that it
can be used to describe an object without affecting syntax.
The C programming language, for example, uses the the syntactic convention
of appending the extension ".c" to a file name to indicate that it is
a source code file. In a NameComponent
object,
the kind
field can be used to describe the type of object
rather than a file extension or some other syntactic convention.
Examples of the value of the kind
field include the strings
"c_source"
, "object_code"
,
"executable"
,
"postscript"
, and ""
. It is not unusual
for the kind
field to be the empty string.
In a name, each NameComponent
object except the last denotes
a NamingContext
object; the last NameComponent
object denotes the bound object reference.
This is similar to a path name, in which the last name is the
file name, and all names before it are directory names.
public final class Binding
--
an object that associates a name with an object reference or a
naming context.
A Binding
object has two fields:
binding_name
- an array of one or more
NameComponent
objects that represents the bound name
binding_type
- a BindingType
object
indicating whether the binding is between a name and an object
reference or between a name and a naming context
The interface NamingContext
has methods for
binding/unbinding names with object references or naming contexts,
for listing bindings,
and for resolving bindings (given a name, the method
resolve
returns the object reference bound to it).
public final class BindingType
--
an object that specifies whether the given Binding
object is a binding between a name and an object reference (that is,
not a naming context) or between a name and a naming context.
The classBindingType
consists of two methods and
four constants. Two of these constants are
BindingType
objects, and two are int
s.
The BindingType
objects
can be passed to the constructor for the class
Binding
or used as parameters or return values. These
BindingType
objects are:
public static final BindingType nobject
--
to indicate that the binding is with an object reference
public static final BindingType ncontext
--
to indicate that the binding is with a naming context
The int
constants can be supplied to the method
from_int
to create BindingType
objects,
or they can be return values for the method value
.
These constants are:
public static final int _nobject
public static final int _ncontext
from_int
is supplied with anything other
than _nobject
or _ncontext
, it will throw
the exception org.omg.CORBA.BAD_PARAM
.
Usage is as follows:
BindingType btObject = from_int(_nobject); BindingType btContext = from_int(_ncontext);The variable
btObject
refers to a BindingType
object initialized to represent a binding with an object reference.
The variable btContext
refers to a BindingType
object initialized to represent a binding with a
NamingContex
object.
The method value
returns either
_nobject
or _ncontext
, so
in the following line of code, the variable bt
will contain _nobject
or _ncontext
:
int bt = BindingType.value();
value
field. This allows
it to perform the function of an OUT or INOUT parameter.
The following holder classes are generated for the package
org.omg.CosNaming
:
NamingContextHolder
BindingIteratorHolder
BindingHolder
BindingListHolder
BindingTypeHolder
NameComponentHolder
NameHolder
Note that in the org.omg.CORBA
package,
there is a holder class for each of the basic Java types:
IntHolder
, ShortHolder
,
StringHolder
, and so on.
Note also that there is a NameHolder
class even though
there is no Name
class; similarly, there is a
BindingListHolder
class even though there is no
BindingList
class. This is true because in the OMG IDL
interface, Name
and BindingList
are
typedef
s. There is no mapping from an IDL
typedef
to a Java construct, but holder classes
are generated if the typedef
is for a sequence or
an array. As mapped to the
Java programming language, Name
is an array of
NameComponent
objects, and a BindingList
is an array of Binding
objects.
All holder classes have at least two constructors and one field:
value
field -- an instance of the type being used as
an OUT or INOUT parameter. For example, the value
field of a
NamingContextHolder
will be a NamingContext
object.
BindingHolder
object created with the default constructor
will have its value
field set to null
because
that is the default value for an object. Other defaults are
false
for boolean
,
0
for numeric and char types, and
null
for object references.
value
field is
initialized with the instance supplied
A holder class for a user-defined type (a Java class) has three more methods, but application developers do not use them directly.
There is only one method in a helper class that an
application programmer uses: the
method narrow
. Only Java interfaces mapped from IDL
interfaces will have a helper class that includes a narrow
method, so in the CosNaming
package, only the classes
NamingContextHelper
and BindingIteratorHelper
have a narrow
method.
public static NamingContext
narrow(org.omg.CORBA.Object obj)
-- converts the given
CORBA object to a NamingContext
object
public static BindingIterator
narrow(org.omg.CORBA.Object obj)
-- converts the given
CORBA object to a BindingIterator
object
org.omg.CosNaming.NamingContextPackage
org.omg.CosNaming
and also for the class
NotFoundReason
, which supplies a reason for the exception
NotFound
.
There are Helper and Holder classes for the following exceptions:
AlreadyBound
CannotProceed
InvalidName
NotEmpty
NotFound
CosNaming
package complies
with the OMG COSNaming
specification. In other words,
the APIs in Sun's naming service are implemented according to the
guidelines for a naming service provided by OMG. Therefore, if a
third-party vendor has implemented a naming service that is OMG
compliant, it is possible to switch between Sun's implementation of
CosNaming
and the third-party vendor's implementation.
However, it is important to understand that there can be minor
variations in the way different vendors implement the naming service,
such as differences in the exception strings.
COSNaming
implementation with Sun's RMI-IIOP ORB.
Here are the steps to follow:
/tmp/services
and put the following in it:
NameService,
.
This associates NameService
with the Root Naming
Context of the CosNaming
implementation that you
want to use.
java -classpath $(CLASSPATH)
com.sun.corba.ee.internal.CosNaming.BootstrapServer -InitialServicesFile
"/tmp/services" [-ORBInitialPort port]
Note that the square brackets at the end of the command indicate that specifying a port number is optional.
Now when an application calls the method
org.omg.CORBA.ORB.resolve_initial_references
, CORBA
processes will contact the Bootstrap Server to get the Root Naming
Context.
CosNaming
API, please see:
For an overview of Java IDL, please see:
|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-2001 Sun Microsystems, Inc. 901 San Antonio Road
Palo Alto, California, 94303, U.S.A. All Rights Reserved.