[Previous] [Contents] [Next] [IONA Technologies]


Chapter 15
Contexts


Contents

15.1 Creating a Context
15.2 Retrieving Property Values from a Context



As explained inChapter 5, "IDL to Java Mapping", an operation that specifies a context clause is mapped to a Java method which takes an extra parameter, of type Context. For example:

is mapped to:

The full definition of class Context is given in the OrbixWeb Reference Guide.

15.1 Creating a Context

Instances of Context are pseudo-objects. A client can create a Context as follows:

This creates an initially empty Context object, to which identifier:value mappings can be added, and which can be passed to a function that takes a Context parameter.

The default context for a process can be obtained by calling get_default_context():

on the _CORBA.Orbix object. For example:

This context provides a useful mechanism for sharing context changes between different parts of a program. Currently, it is initially empty.

Note that Context objects can be nested, by specifying the parent parameter when creating a (child) Context, or by using the create_child() method.

Figure 15.1 illustrates a context hierarchy. A hierarchy may be set up by specifying the parent context in the constructor; a name can also be given to a context:

15.2 Retrieving Property Values from a Context


Figure 15.1: Hierarchy of contexts

Context provides a method get_values() to retrieve the property values in a Context; it is defined as:

The start_scope parameter to get_values() can be used to specify that the search for the values requested is to be made in a (direct or indirect) parent context of the context on which the call is made. The call searches backwards for a context with the specified name, and if this is found then it will search for the specified Identifiers in that context. For example, the following code specifies that the search for identifiers beginning with "sys_" should begin in the context named middle:

If zero is passed as the first parameter to get_values(), the search begins in the context which is the target of the call.

get_values() has a parameter of type Flags. When the null flag is passed to get_values(), searching of identifier(s) will propagate upwards to parent contexts. If the Flags parameter passed to get_values() is _CORBA.CTX_RESTRICT_SCOPE, then searching is restricted to the specified scope or Context object.



[Roadmap] [Introduction] [GS: Applications] [GS: Applets]
[IDL] [Mapping] [Programming OrbixWeb] [Publishing Objects] [Retrieving Objects] [IIOP]
[Running Clients] [Running Servers] [Exceptions] [Inheritance] [Callbacks] [Contexts]
[API Configuration] [TypeCode] [Any] [DII] [IR] [Filters] [Smart Proxies] [Loaders] [Locators]
[Index]