- java.lang.Object
-
- org.omg.CORBA.Context
-
public abstract class Context extends Object
An object used inRequestoperations to specify the context object in which context strings must be resolved before being sent along with the request invocation. AContextobject contains a list of properties in the form ofNamedValueobjects. These properties represent information about the client, the environment, or the circumstances of a request and generally are properties that might be inconvenient to pass as parameters.A
Contextobject is created by first calling theORBmethodget_default_contextand then calling the methodcreate_childon the default context.Each property in a
Contextobject is represented by aNamedValueobject. The property name is contained in theNamedValueobject'snamefield, and the value associated with the name is contained in theAnyobject that was assigned to theNamedValueobject'svaluefield.Contextproperties can represent a portion of a client's or application's environment that is meant to be propagated to (and made implicitly part of) a server's environment. (Examples might be a window identifier or user preference information). Once a server has been invoked (that is, after the properties are propagated), the server may query itsContextobject for these properties using the methodget_values.When an operation declaration includes a context clause, the stubs and skeletons will have an additional argument added for the context. When an operation invocation occurs, the ORB causes the properties that were named in the operation definition in IDL and that are present in the client's
Contextobject to be provided in theContextobject parameter to the invoked method.Contextproperty names (which are strings) typically have the form of an OMG IDL identifier or a series of OMG IDL identifiers separated by periods. A context property name pattern is either a property name or a property name followed by a single "*". A property name pattern without a trailing "*" is said to match only itself. A property name pattern of the form "<name>*" matches any property name that starts with <name> and continues with zero or more additional characters.Property name patterns are used in the context clause of an operation definition and as a parameter for the method
Context.get_values.Contextobjects may be "chained" together to achieve a particular defaulting behavior. AContextobject created with the methodcreate_childwill be chained to its parent (theContextobject that created it), and that means that the parent will be searched after the child in a search for property names.Properties defined in a particular
Contextobject effectively override those properties in the next higher level. The scope used in a search for properties may be restricted by specifying a starting scope and by using the flagCTX_RESTRICT_SCOPEwhen invoking the methodget_values.A
Contextobject may be named for purposes of specifying a starting search scope.- Since:
- JDK1.2
-
-
Constructor Summary
Constructors Constructor Description Context()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract Stringcontext_name()Retrieves the name of thisContextobject.abstract Contextcreate_child(String child_ctx_name)Creates aContextobject with the given string as its name and with thisContextobject set as its parent.abstract voiddelete_values(String propname)Deletes from thisContextobject theNamedValueobject(s) whosenamefield matches the given property name.abstract NVListget_values(String start_scope, int op_flags, String pattern)Retrieves theNamedValueobjects whosenamefield matches the given name or name pattern.abstract Contextparent()Retrieves the parent of thisContextobject.abstract voidset_one_value(String propname, Any propvalue)Creates aNamedValueobject and adds it to thisContextobject.abstract voidset_values(NVList values)I Sets one or more property values in thisContextobject.
-
-
-
Method Detail
-
context_name
public abstract String context_name()
Retrieves the name of thisContextobject.- Returns:
- the name of this
Contextobject
-
parent
public abstract Context parent()
Retrieves the parent of thisContextobject.- Returns:
- the
Contextobject that is the parent of thisContextobject
-
create_child
public abstract Context create_child(String child_ctx_name)
Creates aContextobject with the given string as its name and with thisContextobject set as its parent.The new
Contextobject is chained into its parentContextobject. This means that in a search for matching property names, if a match is not found in this context, the search will continue in the parent. If that is not successful, the search will continue in the grandparent, if there is one, and so on.- Parameters:
child_ctx_name- theStringobject to be set as the name of the newContextobject- Returns:
- the newly-created child
Contextobject initialized with the specified name
-
set_one_value
public abstract void set_one_value(String propname, Any propvalue)
Creates aNamedValueobject and adds it to thisContextobject. Thenamefield of the newNamedValueobject is set to the given string, thevaluefield is set to the givenAnyobject, and theflagsfield is set to zero.- Parameters:
propname- the name of the property to be setpropvalue- theAnyobject to which the value of the property will be set. TheAnyobject'svaluefield contains the value to be associated with the given propname; thekindfield must be set toTCKind.tk_string.
-
set_values
public abstract void set_values(NVList values)
I Sets one or more property values in thisContextobject. TheNVListsupplied to this method contains one or moreNamedValueobjects. In eachNamedValueobject, thenamefield holds the name of the property, and theflagsfield must be set to zero. TheNamedValueobject'svaluefield contains anAnyobject, which, in turn, contains the value for the property. Since the value is always a string, theAnyobject must have thekindfield of itsTypeCodeset toTCKind.tk_string.- Parameters:
values- an NVList containing the property names and associated values to be set- See Also:
get_values(java.lang.String, int, java.lang.String),NamedValue,Any
-
delete_values
public abstract void delete_values(String propname)
Deletes from thisContextobject theNamedValueobject(s) whosenamefield matches the given property name. If theStringobject supplied forpropnamehas a trailing wildcard character ("*"), then allNamedValueobjects whosenamefields match will be deleted. The search scope is always limited to thisContextobject.If no matching property is found, an exception is returned.
- Parameters:
propname- name of the property to be deleted
-
get_values
public abstract NVList get_values(String start_scope, int op_flags, String pattern)
Retrieves theNamedValueobjects whosenamefield matches the given name or name pattern. This method allows for wildcard searches, which means that there can be multiple matches and therefore multiple values returned. If the property is not found at the indicated level, the search continues up the context object tree until a match is found or allContextobjects in the chain have been exhausted.If no match is found, an error is returned and no property list is returned.
- Parameters:
start_scope- aStringobject indicating the context object level at which to initiate the search for the specified properties (for example, "_USER", "_GROUP", "_SYSTEM"). Valid scope names are implementation-specific. If a scope name is omitted, the search begins with the specified context object. If the specified scope name is not found, an exception is returned.op_flags- an operation flag. The one flag that may be specified isCTX_RESTRICT_SCOPE. If this flag is specified, searching is limited to the specifiedstart_scopeor thisContextobject.pattern- the property name whose values are to be retrieved.patternmay be a name or a name with a trailing wildcard character ("*").- Returns:
- an
NVListcontaining all the property values (in the form ofNamedValueobjects) whose associated property name matches the given name or name pattern - See Also:
set_values(org.omg.CORBA.NVList),NamedValue
-
-