Example #1
0
  public static HandlerConfigurationBean deserializeHandlerConfiguration(
      OMElement configurationElement) {
    if (configurationElement == null || !"handler".equals(configurationElement.getLocalName())) {
      return null;
    }
    HandlerConfigurationBean handlerConfigurationBean = new HandlerConfigurationBean();
    handlerConfigurationBean.setHandlerClass(
        configurationElement.getAttributeValue(new QName("class")));
    handlerConfigurationBean.setTenant(configurationElement.getAttributeValue(new QName("tenant")));
    String methodsAttribute = configurationElement.getAttributeValue(new QName("methods"));
    if (methodsAttribute != null && methodsAttribute.length() != 0) {
      handlerConfigurationBean.setMethods(methodsAttribute.split(","));
    }
    @SuppressWarnings("unchecked")
    Iterator<OMElement> handlerProps =
        configurationElement.getChildrenWithName(new QName("property"));
    while (handlerProps.hasNext()) {
      OMElement propElement = handlerProps.next();
      String propName = propElement.getAttributeValue(new QName("name"));
      String propType = propElement.getAttributeValue(new QName("type"));

      if (propType != null && "xml".equals(propType)) {
        handlerConfigurationBean.getXmlProperties().put(propName, propElement);
      } else {
        handlerConfigurationBean.getNonXmlProperties().put(propName, propElement.getText());
      }
      handlerConfigurationBean.getPropertyList().add(propName);
    }
    FilterConfigurationBean filterConfigurationBean = new FilterConfigurationBean();
    OMElement filterElement = configurationElement.getFirstChildWithName(new QName("filter"));
    filterConfigurationBean.setFilterClass(filterElement.getAttributeValue(new QName("class")));
    @SuppressWarnings("unchecked")
    Iterator<OMElement> filterProps = filterElement.getChildrenWithName(new QName("property"));
    while (filterProps.hasNext()) {
      OMElement propElement = filterProps.next();
      String propName = propElement.getAttributeValue(new QName("name"));
      String propType = propElement.getAttributeValue(new QName("type"));

      if (propType != null && "xml".equals(propType)) {
        filterConfigurationBean.getXmlProperties().put(propName, propElement);
      } else {
        filterConfigurationBean.getNonXmlProperties().put(propName, propElement.getText());
      }
      filterConfigurationBean.getPropertyList().add(propName);
    }
    handlerConfigurationBean.setFilter(filterConfigurationBean);
    return handlerConfigurationBean;
  }