Sunday, September 5, 2010

Implementing Context Extractors

Websphere Business Services Fabric v7.0
Contact us...

Implementing Context Extractors

A Context Extractor is a Mediation Primitive located inside of a Mediation Flow Component. The Loan Origination Assembly contains three such components: one wired in front of the BPEL, and one each between the final two dynamic assemblers that are invoked in the process ()

Implementing an Initial Context Extractor

A Fabric Context can be established by using a Context Extractor. Dynamic Assembly components that occur later in the process will create sub-contexts from this initial Context. This pattern is useful if you need to establish some contextual data that will be used by all subsequent Dynamic Assemblers.

Do the following to an initial Context Extractor for the Loan Origination Assembly:
  1. Switch to the Business Integration perspective by selecting Window\Open Perspective\Other....  Select Business Integration (default).
  2. Open the Loan Origination\Assembly Diagram by double-clicking it.
  3. Add a Mediation Flow
    Rigth-click inside the Assembly Diagram (empty space) and select Add\Mediation Flow.  Rename it to  ContextExtractorMedFlow. The LoanOrigination Export should be wired to its left side, and the LoanOrigination Process should be wired to its right side. The editor will automatically add the appropriate interface to the Mediation Flow. The interface for the Export, the Mediation Flow, and the Process are all the same ().
  4. Double-click the ContextExtractorMedFlow to implement it. Click the Yes button when the dialog box appears (The selected component is not yet implemented ...etc...).

    The editor will ask you to select a location to store the generated implementation.  Select LoanOrigination\extractors\main or create a new folder.  Click OK button.
  5. The main implementation editor for this Mediation Flow will now appear (). The left side (LoanOrigination) shows the interface and operation with which the flow is invoked. The right side (LoanOriginationPartner) shows the Reference Partner process, which happens to have the same interface and operation.
    By clicking on the Criterion_loanApplication link on the left side interface, you will be presented with a mini wizard that will allow you to create an implementation. For this exercise, choose Blank Mediation Flow.
  6. The Blank Mediation Flow appears.  The first thing we need to do is to add a Context Extractor Mediation Primitive to the diagram. The existing primitive on the canvas represents the incoming request from the exposed interface.

    Expand the Fabric folder in the Palette. This reveals the Context Extractor. Drag the Context Extractor and drop it on the canvas. Wire the existing primitive to the Context Extractor, and rename the Context Extractor to CommonContextExtractor()
  7. Under the Service Invocation folder, on the Palette, click the Callout primitive and drop it on the canvas. You will be asked to select the Reference and the Operation. Since the Mediation Primitive is only wired to one Reference Partner, there is only one option for each. Click OK ().
  8. After you click OK, the callout to the Reference Partner will appear on the canvas ().

    Since the incoming request and the callout invocation use the same interface, there is no transformation of the message required in the Mediation Primitive.

    Wire the context extractor to the callout.
  9. Mapping Context Keys

    Now let's specify the details of the Context Extractor itself. Click the Context Extractor Mediation Primitive. Once it is active, click the Properties editor in the lower panel, and then the Details tab on the left. This will bring up an editor capable of mapping Context Keys (Business Vocabularies) to Context Value Paths (runtime data from the request).

    There are three main sections in the editor. The Context Operation specifies how the Context is to be altered. In this case, the default is fine: It will update the current Fabric Context if available, otherwise it will create a new one. The Context Mappings section is where extractions to be added to the Context are specified. The bottom section, Context Keys to Delete, allows you to specify items in the Context that should be removed by the primitive.

    Click the Add button in the Context Mappings section. This will open a dialog box allowing you to specify the Context Key and the Context Value Path.

    1. Click the Select button for the Context Key. Typically, this will pull up a listing of Vocabulary Terms from which you can select. (See Step ??.) However, if Business Space is not running or your project is not configured properly, you may see the following empty list of Vocabularies ().
    2. In the above case, it may be necessary to configure the Context Extractor primitive. Click on the “Window” menu and choose “Preferences”. In the Filter of the Preferences editor, type “context” ().

    3. Note: Ensure that the certificate of the runtime server has been imported into WID before updating this window. To import a certificate into WID please follow the steps in the topic: Connecting to the run-time server

    4. Select the Context Extractor item under Business Integration / Medation Flow Editor. Ensure that all of the settings are correct. The Context Root should be left as “rest”, however, the protocol will likely need to be changed to “https” (Note: http works in my case). The Host, Port, User Name, and Password fields should also all be verified.

    5. After the information has been verified, click the Update Vocabulary button. The editor will inform you if the update was successful or not (). In the case of it being successful, go to the next step. If the update fails, you may need to add the Context Keys manually. Instructions on how to do this start on Step ??.
    6. After successfully completing step 10 above (configure the Context Extractor primitive), click the Select button for the Context Key again (step 9 above). The available Vocabulary Terms will appear, grouped by project. Expand Loans Origination Vocabulary and select Amount of Loan. Click OK ().
    7. Next, click the Edit… button for the Context Value Path (). This will allow you to specify the XPath expression identifying the data in the request that should be associated with the Context Key. And XPath expression builder will appear.
    8. In the simple expression builder, navigate the hierarchy by expanding the sections. Select the amountOfLoan:double under the LoanInfo object. Click OK ().  In the Add/Edit Properties window that appears, click Finish ().  The Context Key (Amount of Loan) is added ().

  10. Follow the same procedure (Mapping Context Keys) for the Line of Business and New Customer Vocabularies. The values from the request should be lineOfBusiness from LoanInfo and newCustomer from CustomerInfo, respectively. You will end up with a Context Mapping that looks like the following ().
  11. Two more Context Extractor Mediation Flows () need to be created for the assembly, one between the LoanOrigination Process and the FinalReview Dynamic Assembler, and one between the LoanOrigination Process and the NotifyCustomer Dynamic Assembler () .  Follow the same procedure as above to create the Mediation Flows. Each extractor requires just one Context Mapping. The Context Key should be the Loan Status, and the Context Value Path should specify the loanStatus value in the LoanInfo object.
  12. In the case that Business Space is unavailable, the Context Keys can be specified manually using the appropriate URIs. Navigate to the Business Service perspective in WID, and open the Assertion Explorer view. Expand the Business Vocabulary folder, and then expand the Loans Origination Vocabulary.

    Double-clicking the desired Vocabulary will open that Vocabulary's editor. Its URI can be copied to the clipboard using the “Copy URI” button to the right of the ID field ().

    Note: The following applies when vocabulary is not available/configured correctly.  See above
    Once this is complete for each Vocabulary, the Context Mapping section will resemble the following diagram:

    Note that the URI of the Vocabulary is shown instead of its name. When Business Space is running again and/or your configuration is specified appropriately, these URIs will appear as names instead of URIs. The Context Extractor will continue to function in either case.

Related links

  1. Modeling, developing, assembling, deploying and managing an application
  2. Working with the Fabric templates in Business Space
  3. Business Space Information Center

No comments:

Post a Comment