Input Context

A process method can have an additional parameter, the InputContext. The input context provides information about the input object, such as its origin and the number of times the object has been retried. For example, this flowlet tokenizes text in a smart way and uses the input context to decide which tokenizer to use:

public void tokenize(String text, InputContext context) throws Exception {
  Tokenizer tokenizer;
  // If this failed before, fall back to simple white space
  if (context.getRetryCount() > 0) {
    tokenizer = new WhiteSpaceTokenizer();
  // Is this code? If its origin is named "code", then assume yes
  else if ("code".equals(context.getOrigin())) {
    tokenizer = new CodeTokenizer();
  else {
    // Use the smarter tokenizer
    tokenizer = new NaturalLanguageTokenizer();
  for (String token : tokenizer.tokenize(text)) {