class XpathProduceDestination implements MessageDrivenDestination {

  @Override
  public String getDestination(AdaptrisMessage msg) {
    String result = defaultDestination;
    try {
      NamespaceContext ctx = SimpleNamespaceContext.create(getNamespaceContext(), msg);
      DocumentBuilderFactoryBuilder builder = documentFactoryBuilder();
      if (ctx != null) {
        builder.setNamespaceAware(true);
      }
      XmlUtils xml = createXmlUtils(msg, ctx, builder);
      String s = xml.getSingleTextItem(xpath);
      if (isBlank(s)) {
        logR.warn("[{}] returned no results", xpath);
      }
      else {
        result = s;
      }
    }
    catch (Exception e) {
      logR.warn("Exception caught attempting to parse message, using default destination");
    }
    logR.trace("Returning [{}]", result);
    return result;
  }

  public  XpathProduceDestination();
  public  XpathProduceDestination(String xpath);
  public  XpathProduceDestination(String xpath, String defaultDest);

}