The org.omg.CosNaming package is a Java mapping of the IDL interfaces defined by the CORBA Naming Service. The principal interface in the service is the NamingContext, which represents a directory of named object references. The package also contains various support classes that allow you to iterate through an NamingContext and query its contents. Figure 35-1 shows the class hierarchy of this package.
Figure 35-1. The org.omg.CosNaming package
_BindingIteratorImplBase
Java 1.2
org.omg.CosNaming
serializable
The IDL-generated skeleton class for the BindingIterator interface.
public abstract class _BindingIteratorImplBase extends org.omg.CORBA.DynamicImplementationimplements BindingIterator {
//
Public Constructors
public _BindingIteratorImplBase ();
//
Methods implementing BindingIterator
public abstract void destroy ();
public abstract boolean next_n (int how_many, BindingListHolder bl);
public abstract boolean next_one (BindingHolder b);
//
Public methods overriding DynamicImplementation
public void invoke (org.omg.CORBA.ServerRequest r);
A Binding describes a name binding within a naming context. It contains a NameComponent array, which represents the name associated with the binding, and a BindingType, which indicates whether the bound object is a regular object or a NamingContext.
public final class Binding implements org.omg.CORBA.portable.IDLEntity {
//
Public Constructors
public Binding ();
public Binding (NameComponent[ ] __binding_name, BindingType __binding_type);
Passed To: _BindingIteratorImplBase.next_one(), _BindingIteratorStub.next_one(), BindingIterator.next_one()
BindingIterator
Java 1.2
org.omg.CosNaming
serializable
If you request a set of name/object bindings from a NamingContext using its list() method, the BindingListHolder you pass in is filled with any results, up to its maximum capacity. If the NamingContext contains more bound objects than the binding array you provide can hold, the BindingIteratorHolder argument is initialized to contain a BindingIterator that allows you to iterate through the rest of the bindings in the context. You can iterate through the remainder of the bindings one at a time, using the next_one() method, or in sets, using the next_n() method.
public abstract interface BindingIterator extends org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity {
//
Public Instance Methods
public abstract void destroy ();
public abstract boolean next_n (int how_many, BindingListHolder bl);
public abstract boolean next_one (BindingHolder b);
Passed To: _BindingIteratorImplBase.next_n(), _BindingIteratorStub.next_n(), _NamingContextImplBase.list(), _NamingContextStub.list(), BindingIterator.next_n(), NamingContext.list()
BindingType
Java 1.2
org.omg.CosNaming
serializable
A BindingType indicates what type of object is involved in a given binding, a regular object or a NamingContext. Its value() method returns an int value that can be compared to the two static int values on the class, to differentiate between these two cases.
public final class BindingType implements org.omg.CORBA.portable.IDLEntity {
//
No Constructor
//
Public Constants
public static final int _ncontext ;
=1
public static final int _nobject ;
=0
public static final BindingType ncontext ;
public static final BindingType nobject ;
//
Public Class Methods
public static final BindingType from_int (int i) throws org.omg.CORBA.BAD_PARAM;
The helper class for the Istring class. The Istring class is used in the Naming Service as a placeholder for an internationalized string type. (Note that IString is just a typedef in the CORBA specification at this point; the OMG hasn't defined an internationalized string interface yet. That's why you cannot find a definition for IString anywhere in Java IDL.)
public class IstringHelper {
//
No Constructor
//
Public Class Methods
public static String extract (org.omg.CORBA.Any a);
public static String id ();
public static void insert (org.omg.CORBA.Any a, String that);
public static String read (org.omg.CORBA.portable.InputStream in);
public static org.omg.CORBA.TypeCode type ();
synchronized
public static void write (org.omg.CORBA.portable.OutputStream out, String that);
}
NameComponent
Java 1.2
org.omg.CosNaming
serializable
A
NameComponent represents one element in a name binding for an object. The name of an object in a NamingContext is composed of a sequence of NameComponent objects. Each NameComponent represents a subcontext that the object falls within, and the last NameComponent is the object's name within its closest context. Consider an object bound to the name apple-146 within a context bound to the name fruit within the root context. This object has two NameComponent objects in its fully qualified name within the root context: fruit, apple-146.
A NameComponent contains an id member, which represents the name associated with the component, and a kind member, which can optionally be used to further differentiate branches in a naming directory. The Naming Service does not consider the kind field on NameComponent objects when determining the uniqueness of name bindings, so each ordered list of id fields extracted from a fully qualified name binding must be unique.
public final class NameComponent implements org.omg.CORBA.portable.IDLEntity {
//
Public Constructors
public NameComponent ();
public NameComponent (String __id, String __kind);
The helper class generated for the Name typedef declared in the IDL module for the Naming Service specification. The IDL typedef associates the type Name to a sequence of NameComponent objects.
public class NameHelper {
//
No Constructor
//
Public Class Methods
public static NameComponent[ ] extract (org.omg.CORBA.Any a);
public static String id ();
public static void insert (org.omg.CORBA.Any a, NameComponent[ ] that);
public static NameComponent[ ] read (org.omg.CORBA.portable.InputStream in);
public static org.omg.CORBA.TypeCode type ();
synchronized
public static void write (org.omg.CORBA.portable.OutputStream out, NameComponent[ ] that);
}
NameHolder
Java 1.2
org.omg.CosNaming
The holder class for out and inout IDL method arguments that are typed as an IDL Name. An IDL typedef in the Naming Service specification associates the type Name to a sequence of NameComponent objects, so any in arguments using this type are mapped to NameComponent arrays in Java, and any out or inout arguments are mapped to NameHolder objects.
public final class NameHolder implements org.omg.CORBA.portable.Streamable {
//
Public Constructors
public NameHolder ();
public NameHolder (NameComponent[ ] __arg);
//
Methods implementing Streamable
public void _read (org.omg.CORBA.portable.InputStream in);
public org.omg.CORBA.TypeCode _type ();
public void _write (org.omg.CORBA.portable.OutputStream out);
A NamingContext represents a naming directory structure, where objects are bound to unique branches, or names, in the naming directory. The full name each object is given in the NamingContext must be unique. New branches in the naming directory are created by binding a NamingContext to a name within another, root NamingContext. The child context represents a subdirectory, or subcontext, within the parent context.
Objects are bound to names in a context using the bind() and rebind() methods. The rebind() method allows you to reassign a name to a new object, if the name has already been bound. You can bind contexts using the bind_context(), bind_new_context(), and rebind_context() methods. If you want to simply create a new context without binding it to a name, use the new_context() method. Bound objects in the context can be found using the resolve() (for singular objects) and list() methods. The unbind() method lets you remove objects from their bindings in the context.
Objects can be bound to names in multiple NamingContext objects at the same time. Their names within each context are independent. The same object can also be bound to multiple, different names in a single context.
public abstract interface NamingContext extends org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity {
//
Public Instance Methods
public abstract void bind (NameComponent[ ] n, org.omg.CORBA.Object obj) throws NotFound, CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName, AlreadyBound;
public abstract void bind_context (NameComponent[ ] n, NamingContext nc) throws NotFound, CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName, AlreadyBound;