Creating and Mapping Context Parameters

You can add context parameters to REST bindings in the Context Parameters section of the General tab.

Procedure

  1. Navigate to the General tab > Context Parameters section of a Promoted Service or Reference.
  2. Add a new Context Parameter; select the Operation(s) it applies to, the Direction (Input, Output or Fault), and the Type (Basic or Bag). For Basic Context Parameters, select a Definition, to describe the data type of the parameter.

    For instance, bookNameCP is a Basic string context parameter that applies to the input flow of the getBookList operation. The name bookNameCP is used for context parameter mapping in the next step, and is also referred to by IT Implementation.

  3. Navigate to the Bindings tab, in the REST Binding Context Parameter Mapping section and specify the HTTP header name in the Header Name column.
  4. If the selected type is Basic, specify the HTTP header name in the Header Name column.
    The specified Header Name appears as a HTTP Header on the wire and the context Parameter name is used by Java IT for the Get and Set methods. For instance, the Basic string context parameter bookNameCP is mapped to HTTP Header Name bookName. That is, when REST service binding intercepts a request, it retrieves the value of the HTTP Header bookName and makes it available to IT Implementation as a value of context parameter bookNameCP.
  5. Generate Java IT Implementation and add the following declaration to the Implementation class:
    //org.osoa.sca.annotations.Context
    @Context
    //com.tibco.amf.platform.runtime.extension.context.ComponentContext
    public ComponentContext componentContext;