com.ibm.websphere.fabric.da.plugin
Interface ContextExtractor


public interface ContextExtractor

Provides custom logic for extracting contextual information from a message.

An Instance of this plugin is invoked by Dynamic Assembler instances that have been wired to it.

Implementations should be thread safe.

Implementations should not maintain any state other than caches of stable results. State that has impact on subsequent usages' results should be persisted using J2EE principles.

A sample implementation:
 public class ExtractRequestorZipCode implements ContextExtractor {
   private static final String REQUESTOR_ZIPCODE_PROPERTY_URI = ...;
 
   public Context extractContext(PendingRequest request) throws UnexpectedContentException {
     DataObject message = request.getFirstBodyElement();
     // perform xpath search on message.
     com.ibm.websphere.fabric.da.util.XPathSearchResult zipCodeResult =
         com.ibm.websphere.fabric.da.util.SdoXPathUtil.getViaXpath("//zipCode");
     if (null == zipCodeResult) {
       return null; // null indicates no change to current context.
     }
     String zipCode = zipCodeResult.getValue();
     if (5 != zipCode.length() && 9 != zipCode.length()) {
       throw new UnexpectedContentException("Zip Code should be exactly 5 or 9 digits");
     }
     Context context = request.getContext();
     context.setSelectionProperty(REQUESTOR_ZIPCODE_PROPERTY_URI, zipCode);
     return context;
   }
 }
 

Note that Contexts are of type com.ibm.websphere.fabric.da.context.Context.

Version:
$Id: $
Author:
alvinr@us.ibm.com, dilumr@us.ibm.com
See Also:
Context.setSelectionProperty(String, com.ibm.websphere.fabric.da.types.TypedValue)

Method Summary
 Context extractContext(PendingRequest request)
          Invoked by Dynamic Assembler instances providing extractor opportunity to add data to current context.
 

Method Detail

extractContext

Context extractContext(PendingRequest request)
                       throws UnexpectedContentException
Invoked by Dynamic Assembler instances providing extractor opportunity to add data to current context.

Parameters:
request - non-null pending request containing non-null context and message body.
Returns:
the updated Context. Returning null has the same effect as returning the context from the request unmodified.
Throws:
UnexpectedContentException - if the extractor detects inconsistent, incomplete or incorrect data in the message. Any other (runtime) exception is considered a plugin failure, as opposed to a mistake in the request.
See Also:
Context


Copyright © 2002-2009 IBM. All Rights Reserved.