Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
2.  Interfaces for Writing XFN Applications The Base Context Interface  Previous   Contents   Next 
   
 

Names in Context Operations

In most of the operations of the base context interface, the caller supplies a context and a composite name argument. The supplied composite name is always interpreted relative to the supplied context.

The operation might eventually be effected on a different context called the operation's target context. Each operation has an initial resolution phase that conveys the operation to its target context, following which the operation is applied. The effect (but not necessarily the implementation) is that of:

  • Doing a lookup on that portion of the name that represents the target context

  • Invoking the operation on the target context

The contexts involved only in the resolution phase are called intermediate contexts. Normal resolution of names in context operations always follows XFN links, which are defined in "XFN Links".

Requirements for Supporting the Context Operations

The lookup operation fn_ctx_lookup() must be supported by all contexts. When contexts do not support other operations, they can return an FN_E_OPERATION_NOT_SUPPORTED status code (see codes in Table 2-3).

XFN contexts are required to support the resolution phase of every operation in the base context and attribute interface when involved in the operation as intermediate contexts. That is, each intermediate context must participate in the process of conveying the operation to the target context, even if it does not support that operation itself. For example, not all contexts need to allow binding and listing names. However, all contexts must fully support the resolution phase of these operations.

Composite names are passed to an XFN context implementation in a structural form as an ordered sequence of components. When resolving a name, the context implementation is responsible for:

  • Determining which set of leading components it must resolve

  • Resolving that portion to a reference

  • Returning a status object containing this reference and the portion of the name unresolved

Composite name resolution is further discussed in "Composite Name Resolution".

Status Objects

In each context operation, the caller supplies an FN_status_t parameter. The called function sets this status object as described in "Status Objects and Status Codes". All status objects are handled in this way for each operation in the base context interface (this is not restated in the individual operation descriptions).

Getting Context Handles

All operations on a context require a context handle. There are several ways of obtaining a context handle. If you have a reference, you can use it to construct a context handle. Otherwise, to get a handle to the initial context, you must call fn_ctx_handle_from_initial().
fn_ctx_handle_from_initial
fn_ctx_handle_from_ref

Construct Handle to Initial Context

This operation returns a handle to the callers initial context. On successful return, the context handle points to a context containing the bindings described in "Initial Context Bindings".

FN_ctx_t *fn_ctx_handle_from_initial(
    unsigned int authoritative,
    FN_status_t *status);

authoritative specifies whether the handle to the Initial Context returned should be authoritative, with respect to information the context obtains from the naming service. When the flag is non-zero, subsequent operations on this context handle can access the most authoritative information. When authoritative is zero, the handle to the Initial Context returned need not be authoritative. Authoritativeness is determined by specific naming services. In some, the authoritative source is a single "master" servers, while in others, the authoritative source is a quorum of servers.

Construct Context Handle From Reference

This operation returns a handle to an FN_ctx_t object given a reference, ref, for that context.

FN_ctx_t *fn_ctx_handle_from_ref(
    const   FN_ref_t *ref, 
    unsigned int authoritative,
    FN_status_t *status);      

authoritative specifies whether the handle to the context returned should be authoritative, with respect to information the context obtains from the naming service. When the flag is non-zero, subsequent operations on this context handle can access the most authoritative information. When authoritative is zero, the handle to the context returned need not be authoritative. Authoritativeness is determined by specific naming services. In some, the authoritative source is a single "master" server, while in others, the authoritative source is a quorum of servers.

Lookup and List Contexts

fn_ctx_lookup
fn_ctx_list_names
fn_namelist_next
fn_namelist_destroy
fn_ctx_list_bindings
fn_bindinglist_next
fn_bindlist_destroy
fn_ctx_lookup_link

Lookup

This operation returns the reference bound to name relative to the context ctx.
FN_ref_t *fn_ctx_lookup(
    FN_ctx_t *ctx,
    const FN_composite_name_t *name,
    FN_status_t *status);

List Names

This set of operations is used to list the set of names bound in the context named name relative to the context ctx. The name must name a context. If the intent is to list the contents of ctx, name should be an empty composite name.

FN_nameslist_t* fn_ctx_list_names(
    FN_ctx_t *ctx,
    const FN_composite_name_t *name,
    FN_status_t *status);
 
FN_string_t *fn_namelist_next(
    FN_namelist_t *nl,
    FN_status_t *status);
 
void fn_namelist_destroy(
    FN_namelist_t *nl);

The call to fn_ctx_list_names() initiates the enumeration process for the target context. It returns an FN_nameslist_t object that you can use for the enumeration.

The operation fn_namelist_next() returns the next name in the enumeration identified by nl and updates nl to indicate the state of the enumeration marker. Successive calls to fn_namelist_next() using nl return successive names and further update the state of the enumeration. fn_namelist_next() returns a NULL pointer when the enumeration has been completed.

fn_namelist_destroy() is used to release resources used during the enumeration. This call can be invoked at any time to terminate the enumeration.

The names enumerated using the list names operations are not in any order. There is no guaranteed relation between the order in which names are added to a context and the order in which names are obtained by enumeration. There is no guarantee that any two enumerations will return the names in the same order.

When a name is added to or removed from the context, this might not necessarily invalidate the enumeration handle that the client holds for that context. If the enumeration handle remains valid, the update might or might not be visible to the client.

List Bindings

This set of operations is used to list the set of names and bindings in the context named by name, relative to the context ctx. The name must name a context. If the intent is to list the contents of ctx, name should be an empty composite name.

FN_bindinglist_t* fn_ctx_list_bindings(
    FN_ctx_t *ctx,
    const FN_composite_name_t *name,
    FN_status_t *status);FN_string_t *fn_bindinglist_next(
FN_bindinglist_t *bl,
    FN_ref_t ** ref,
    FN_status_t *status);
void fn_bindinglist_destroy(
   FN_bindinglist_t *bl);

The semantics of these operations are similar to those for listing names. In addition to a name string being returned, fn_bindinglist_next() also returns the reference of the binding for each member of the enumeration.

 
 
 
  Previous   Contents   Next