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