00001 /* -*- C++ -*- */ 00002 // $Id: CosNaming.idl 76869 2007-02-02 13:22:45Z johnnyw $ 00003 00004 // ============================================================================ 00005 // 00006 // = LIBRARY 00007 // cos 00008 // 00009 // = FILENAME 00010 // CosNaming.idl 00011 // 00012 // = AUTHOR 00013 // Marina Spivak <marina@cs.wustl.edu> 00014 // 00015 // ============================================================================ 00016 00017 #ifndef TAO_NAMING_IDL 00018 #define TAO_NAMING_IDL 00019 00020 #pragma prefix "omg.org" 00021 00022 /** 00023 * This module provides interface for using COS Naming Service. 00024 */ 00025 module CosNaming 00026 { 00027 /// Define a typedef for String. Maybe at some point, <Istring> will 00028 /// be different to support Internationalization. 00029 typedef string Istring; 00030 00031 /* 00032 * This is a 'simple' name. 00033 * 00034 * Both id and kind fields are used in resolving names. 00035 */ 00036 struct NameComponent 00037 { 00038 /// This is the name that is used to identify object references. 00039 Istring id; 00040 00041 /// Stores any additional info about the object reference. 00042 Istring kind; 00043 }; 00044 00045 /// This is a compound name: <c1; c2; c3; cn> where c1 to cn-1 are 00046 /// the names of the nested contexts, and cn is the name of the 00047 /// object bound in cn-1. 00048 typedef sequence <NameComponent> Name; 00049 00050 enum BindingType 00051 { 00052 /// object binding. 00053 nobject, 00054 00055 /// Naming context binding. 00056 ncontext 00057 }; 00058 00059 struct Binding 00060 { 00061 /// Simple name, under which an object is bound in a given context. 00062 Name binding_name; 00063 00064 /// Indicates whether the binding_name identifies a context, and, therefore, can 00065 /// participate in name resolution. 00066 BindingType binding_type; 00067 }; 00068 00069 typedef sequence <Binding> BindingList; 00070 00071 // Forward declaration. 00072 interface BindingIterator; 00073 00074 /// Interface for managing name bindings and naming contexts. 00075 interface NamingContext 00076 { 00077 // = Exceptions. 00078 00079 enum NotFoundReason 00080 { 00081 missing_node, 00082 not_context, 00083 not_object 00084 }; 00085 00086 /// Indicates that the name does not identify a binding. 00087 exception NotFound 00088 { 00089 00090 NotFoundReason why; 00091 Name rest_of_name; 00092 }; 00093 00094 /// Implementation may throw this exception if some reason it cannot 00095 /// complete the operation. This is currently not used in TAO. 00096 exception CannotProceed 00097 { 00098 00099 NamingContext cxt; 00100 Name rest_of_name; 00101 }; 00102 00103 /// A name of length 0 is invalid. Implementations may place 00104 /// further restrictions. 00105 exception InvalidName 00106 { 00107 }; 00108 00109 /// Indicates that the specified name is already bound to 00110 /// some object. Only one object can be bound to a 00111 /// particular name in an context. To change the binding, 00112 /// <rebind> and <rebind_context> can be used. 00113 exception AlreadyBound 00114 { 00115 }; 00116 00117 /// Indicates that the context is not empty. 00118 exception NotEmpty 00119 { 00120 }; 00121 00122 // = Binding operations. 00123 00124 /// Create a binding for name <n> and object <obj> in the naming 00125 /// context. Compound names are treated as follows: ctx->bind 00126 /// (<c1; c2; c3; cn>, obj) = (ctx->resolve (<c1; c2; 00127 /// cn-1>))->bind (<cn>, obj) if the there already exists a 00128 /// binding for the specified name, <AlreadyBound> exception is 00129 /// thrown. Naming contexts should be bound using <bind_context> 00130 /// and <rebind_context> in order to participate in name 00131 /// resolution later. 00132 void bind (in Name n, in Object obj) 00133 raises (NotFound, CannotProceed, InvalidName, AlreadyBound); 00134 00135 /// This is similar to <bind> operation above, except for when 00136 /// the binding for the specified name already exists in the 00137 /// specified context. In that case, the existing binding is 00138 /// replaced with the new one. 00139 void rebind (in Name n, in Object obj) 00140 raises (NotFound, CannotProceed, InvalidName); 00141 00142 /// This is the version of <bind> specifically for binding naming 00143 /// contexts, so that they will participate in name resolution 00144 /// when compound names are passed to be resolved. 00145 void bind_context (in Name n, in NamingContext nc) 00146 raises(NotFound, CannotProceed, InvalidName, AlreadyBound); 00147 00148 /// This is a version of <rebind> specifically for naming 00149 /// contexts, so that they can participate in name resolution 00150 /// when compound names are passed. 00151 void rebind_context (in Name n, in NamingContext nc) 00152 raises (NotFound, CannotProceed, InvalidName); 00153 00154 // = Resolving names. 00155 00156 /// Return object reference that is bound to the name. Compound 00157 /// name resolve is defined as follows: ctx->resolve (<c1; c2; 00158 /// cn>) = ctx->resolve (<c1; c2 cn-1>)->resolve (<cn>) The 00159 /// naming service does not return the type of the object. 00160 /// Clients are responsible for "narrowing" the object to the 00161 /// appropriate type. 00162 Object resolve (in Name n) 00163 raises (NotFound, CannotProceed, InvalidName); 00164 00165 // = Unbinding names. 00166 00167 /// Remove the name binding from the context. When compound 00168 /// names are used, unbind is defined as follows: ctx->unbind 00169 /// (<c1; c2; cn>) = (ctx->resolve (<c1; c2; cn-1>))->unbind 00170 /// (<cn>) 00171 void unbind (in Name n) 00172 raises (NotFound, CannotProceed, InvalidName); 00173 00174 // = Creating Naming Contexts. 00175 00176 /// This operation returns a new naming context implemented by 00177 /// the same naming server in which the operation was invoked. 00178 /// The context is not bound. 00179 NamingContext new_context (); 00180 00181 /// This operation creates a new context and binds it to the name 00182 /// supplied as an argument. The newly-created context is 00183 /// implemented by the same server as the context in which it was 00184 /// bound (the name argument excluding the last component). 00185 NamingContext bind_new_context (in Name n) 00186 raises (NotFound, AlreadyBound, CannotProceed, InvalidName); 00187 00188 // = Deleting contexts. 00189 00190 /// Delete the naming context. NOTE: the user should <unbind> 00191 /// any bindings in which the given context is bound to some 00192 /// names before invoking <destroy> operation on it. 00193 void destroy () 00194 raises (NotEmpty); 00195 00196 00197 // = Listing the naming context. 00198 00199 /// Returns at most the requested number of bindings @a how_many 00200 /// in @a bl. If the naming context contains additional bindings, 00201 /// they are returned with a BindingIterator. In the naming 00202 /// context does not contain any additional bindings @a bi 00203 /// returned as null. 00204 void list (in unsigned long how_many, 00205 out BindingList bl, 00206 out BindingIterator bi); 00207 }; 00208 00209 /// Interface for iterating over Bindings returned with the 00210 /// <list> operation. 00211 interface BindingIterator 00212 { 00213 /// This operation returns the next binding. If there are no 00214 /// more bindings false is returned. 00215 boolean next_one (out Binding b); 00216 00217 /// This operation returns at most the requested number of 00218 /// bindings. 00219 boolean next_n (in unsigned long how_many, 00220 out BindingList bl); 00221 00222 /// This operation destroys the iterator. 00223 void destroy (); 00224 }; 00225 00226 /// Interface for providing operations required to use URLs and 00227 /// stringified names. 00228 /// 00229 /// Reference to: Document orbos/98-10-11 (Interoperable Naming Joint Revised Submission) 00230 /// Joint Submission by BEA Systems, DSTC, IONA, and Inprise 00231 interface NamingContextExt : NamingContext 00232 { 00233 /// Stringified form of a Name. 00234 typedef string StringName; 00235 00236 /// URL address such as myhost.xyz.com. 00237 typedef string Address; 00238 00239 /// Stringified form of a URL address componoent. 00240 typedef string URLString; 00241 00242 /// This operation accepts a Name and returns a stringified 00243 /// name. If the name is invalid, an InvalidName exception is 00244 /// raised. 00245 StringName to_string (in Name n) 00246 raises (InvalidName); 00247 00248 /// This operation returns a Name. If the input stringified 00249 /// name is syntactically malformed or violates an 00250 /// implementation limit, an InvalidName exception is 00251 /// raised. 00252 Name to_name (in StringName sn) 00253 raises (InvalidName); 00254 00255 /// Indicates that the URL address is invalid. 00256 exception InvalidAddress { 00257 }; 00258 00259 /// It performs any escapes necessary on the stringified name 00260 /// and returns a fully formed URL string. An exception is 00261 /// raised if either the protocol or name parameters are invalid. 00262 URLString to_url (in Address addr, 00263 in StringName sn) 00264 raises (InvalidAddress, InvalidName); 00265 00266 /// This is similar to @c resolve as in the 00267 /// CosNaming::NamingContext interface, except that it accepts 00268 /// a stringified name as an argument instead of a Name. 00269 Object resolve_str (in StringName n) 00270 raises (NotFound, CannotProceed, InvalidName); 00271 }; 00272 }; 00273 00274 #endif /* TAO_NAMING_IDL */