1. /*
  2. * @(#)Context.java 1.15 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package org.omg.CORBA;
  8. /**
  9. * An object used in <code>Request</code> operations
  10. * to specify the context object in which context strings
  11. * must be resolved before being sent along with the request invocation.
  12. * A <code>Context</code> object
  13. * contains a list of properties in the form of <code>NamedValue</code>
  14. * objects. These properties represent information
  15. * about the client, the environment, or the circumstances of a request
  16. * and generally are properties that might be inconvenient
  17. * to pass as parameters.
  18. * <P>
  19. * A <code>Context</code> object is created by first calling the
  20. * <code>ORB</code> method <code>get_default_context</code>
  21. * and then calling the method <code>create_child</code> on the
  22. * default context.
  23. * <P>
  24. * Each property in a <code>Context</code> object is represented by
  25. * a <code>NamedValue</code> object. The property name is contained
  26. * in the <code>NamedValue</code> object's <code>name</code> field, and
  27. * the value associated with the name is contained in the <code>Any</code>
  28. * object that was assigned to the <code>NamedValue</code> object's
  29. * <code>value</code> field.
  30. * <P>
  31. * <code>Context</code> properties can represent a portion of a client's
  32. * or application's environment that is meant to be propagated to
  33. * (and made implicitly part of) a server's environment.
  34. * (Examples might be a window identifier or user preference information).
  35. * Once a server has been invoked (that is, after the properties are
  36. * propagated), the server may query its <code>Context</code> object
  37. * for these properties using the method <code>get_values</code>.
  38. *
  39. *<P>
  40. * When an operation declaration includes a context clause,
  41. * the stubs and skeletons will have an additional argument
  42. * added for the context. When an operation invocation occurs,
  43. * the ORB causes the properties that were named in the operation
  44. * definition in IDL and
  45. * that are present in the client's <code>Context</code> object
  46. * to be provided in the <code>Context</code> object parameter to
  47. * the invoked method.
  48. * <P>
  49. * <code>Context</code> property names (which are strings)
  50. * typically have the form of an OMG IDL identifier or
  51. * a series of OMG IDL identifiers separated by periods.
  52. * A context property name pattern is either a property name
  53. * or a property name followed by a single "*". A property
  54. * name pattern without a trailing "*" is said to match only
  55. * itself. A property name pattern of the form "<name>*" matches any
  56. * property name that starts with <name> and continues with zero
  57. * or more additional characters.
  58. * <P>
  59. * Property name patterns are used in the context clause of
  60. * an operation definition and as a parameter for the
  61. * method <code>Context.get_values</code>.
  62. * <P>
  63. * <code>Context</code> objects may be "chained" together to achieve a
  64. * particular defaulting behavior. A <code>Context</code>
  65. * object created with the method <code>create_child</code> will
  66. * be chained to its parent (the <code>Context</code> object
  67. * that created it), and that means that the parent will be searched
  68. * after the child in a search for property names.
  69. *<P>
  70. * Properties defined in a particular <code>Context</code> object
  71. * effectively override those properties in the next higher level.
  72. * The scope used in a search for properties may be restricted by specifying a
  73. * starting scope and by using the flag <code>CTX_RESTRICT_SCOPE</code>
  74. * when invoking the method <code>get_values</code>.
  75. * <P>
  76. * A <code>Context</code> object may be named for purposes of specifying
  77. * a starting search scope.
  78. *
  79. * @version 1.11, 09/09/97
  80. * @since JDK1.2
  81. */
  82. public abstract class Context {
  83. /**
  84. * Retrieves the name of this <code>Context</code> object.
  85. *
  86. * @return the name of this <code>Context</code> object
  87. */
  88. public abstract String context_name();
  89. /**
  90. * Retrieves the parent of this <code>Context</code> object.
  91. *
  92. * @return the <code>Context</code> object that is the
  93. * parent of this <code>Context</code> object
  94. */
  95. public abstract Context parent();
  96. /**
  97. * Creates a <code>Context</code> object with the given string as its
  98. * name and with this <code>Context</code> object set as its parent.
  99. * <P>
  100. * The new <code>Context</code> object is chained into its parent
  101. * <code>Context</code> object. This means that in a search for
  102. * matching property names, if a match is not found in this context,
  103. * the search will continue in the parent. If that is not successful,
  104. * the search will continue in the grandparent, if there is one, and
  105. * so on.
  106. *
  107. *
  108. * @param child_ctx_name the <code>String</code> object to be set as
  109. * the name of the new <code>Context</code> object
  110. * @return the newly-created child <code>Context</code> object
  111. * initialized with the specified name
  112. */
  113. public abstract Context create_child(String child_ctx_name);
  114. /**
  115. * Creates a <code>NamedValue</code> object and adds it to this
  116. * <code>Context</code> object. The <code>name</code> field of the
  117. * new <code>NamedValue</code> object is set to the given string,
  118. * the <code>value</code> field is set to the given <code>Any</code>
  119. * object, and the <code>flags</code> field is set to zero.
  120. *
  121. * @param propname the name of the property to be set
  122. * @param propvalue the <code>Any</code> object to which the
  123. * value of the property will be set. The
  124. * <code>Any</code> object's <code>value</code>
  125. * field contains the value to be associated
  126. * with the given propname; the
  127. * <code>kind</code> field must be set to
  128. * <code>TCKind.tk_string</code>.
  129. */
  130. public abstract void set_one_value(String propname, Any propvalue);
  131. /**
  132. I Sets one or more property values in this <code>Context</code>
  133. * object. The <code>NVList</code> supplied to this method
  134. * contains one or more <code>NamedValue</code> objects.
  135. * In each <code>NamedValue</code> object,
  136. * the <code>name</code> field holds the name of the property, and
  137. * the <code>flags</code> field must be set to zero.
  138. * The <code>NamedValue</code> object's <code>value</code> field
  139. * contains an <code>Any</code> object, which, in turn, contains the value
  140. * for the property. Since the value is always a string,
  141. * the <code>Any</code> object must have the <code>kind</code>
  142. * field of its <code>TypeCode</code> set to <code>TCKind.tk_string</code>.
  143. *
  144. * @param values an NVList containing the property
  145. * names and associated values to be set
  146. *
  147. * @see NamedValue
  148. * @see Any
  149. */
  150. public abstract void set_values(NVList values);
  151. /**
  152. * Deletes from this <code>Context</code> object the
  153. * <code>NamedValue</code> object(s) whose
  154. * <code>name</code> field matches the given property name.
  155. * If the <code>String</code> object supplied for
  156. * <code>propname</code> has a
  157. * trailing wildcard character ("*"), then
  158. * all <code>NamedValue</code> objects whose <code>name</code>
  159. * fields match will be deleted. The search scope is always
  160. * limited to this <code>Context</code> object.
  161. * <P>
  162. * If no matching property is found, an exception is returned.
  163. *
  164. * @param propname name of the property to be deleted
  165. */
  166. public abstract void delete_values(String propname);
  167. /**
  168. * Retrieves the <code>NamedValue</code> objects whose
  169. * <code>name</code> field matches the given name or name
  170. * pattern. This method allows for wildcard searches,
  171. * which means that there can be multiple matches and
  172. * therefore multiple values returned. If the
  173. * property is not found at the indicated level, the search
  174. * continues up the context object tree until a match is found or
  175. * all <code>Context</code> objects in the chain have been exhausted.
  176. * <P>
  177. * If no match is found, an error is returned and no property list
  178. * is returned.
  179. *
  180. * @param start_scope a <code>String</code> object indicating the
  181. * context object level at which to initiate the
  182. * search for the specified properties
  183. * (for example, "_USER", "_GROUP", "_SYSTEM"). Valid scope
  184. * names are implementation-specific. If a
  185. * scope name is omitted, the search
  186. * begins with the specified context
  187. * object. If the specified scope name is
  188. * not found, an exception is returned.
  189. * @param op_flags an operation flag. The one flag
  190. * that may be specified is <code>CTX_RESTRICT_SCOPE</code>.
  191. * If this flag is specified, searching is limited to the
  192. * specified <code>start_scope</code> or this
  193. * <code>Context</code> object.
  194. * @param pattern the property name whose values are to
  195. * be retrieved. <code>pattern</code> may be a
  196. * name or a name with a
  197. * trailing wildcard character ("*").
  198. *
  199. * @return an <code>NVList</code> containing all the property values
  200. * (in the form of <code>NamedValue</code> objects)
  201. * whose associated property name matches the given name or
  202. * name pattern
  203. */
  204. abstract public NVList get_values(String start_scope, int op_flags,
  205. String pattern);
  206. };