public static OMElement serializeHandlerConfiguration(HandlerConfigurationBean bean) {
   OMFactory factory = OMAbstractFactory.getOMFactory();
   OMElement handler = factory.createOMElement("handler", null);
   handler.addAttribute(factory.createOMAttribute("class", null, bean.getHandlerClass()));
   if (bean.getTenant() != null) {
     handler.addAttribute(factory.createOMAttribute("tenant", null, bean.getTenant()));
   }
   StringBuilder sb = new StringBuilder();
   for (String method : bean.getMethods()) {
     if (method != null && method.length() > 0) {
       sb.append(method).append(",");
     }
   }
   // Remove last ","
   if (sb.length() > 0) {
     sb.deleteCharAt(sb.length() - 1);
     handler.addAttribute(factory.createOMAttribute("methods", null, sb.toString()));
   }
   for (String property : bean.getPropertyList()) {
     OMElement temp = factory.createOMElement("property", null);
     temp.addAttribute(factory.createOMAttribute("name", null, property));
     OMElement xmlProperty = bean.getXmlProperties().get(property);
     if (xmlProperty != null) {
       //                The serialization happens by adding the whole XML property value to the
       // bean.
       //                Therefore if it is a XML property, we take that whole element.
       handler.addChild(xmlProperty);
     } else {
       String nonXMLProperty = bean.getNonXmlProperties().get(property);
       if (nonXMLProperty != null) {
         temp.setText(nonXMLProperty);
         handler.addChild(temp);
       }
     }
   }
   OMElement filter = factory.createOMElement("filter", null);
   filter.addAttribute(
       factory.createOMAttribute("class", null, bean.getFilter().getFilterClass()));
   for (String property : bean.getFilter().getPropertyList()) {
     OMElement temp = factory.createOMElement("property", null);
     temp.addAttribute(factory.createOMAttribute("name", null, property));
     OMElement xmlProperty = bean.getFilter().getXmlProperties().get(property);
     if (xmlProperty != null) {
       temp.addAttribute(factory.createOMAttribute("type", null, "xml"));
       temp.addChild(xmlProperty);
       filter.addChild(temp);
     } else {
       String nonXMLProperty = bean.getFilter().getNonXmlProperties().get(property);
       if (nonXMLProperty != null) {
         temp.setText(nonXMLProperty);
         filter.addChild(temp);
       }
     }
   }
   handler.addChild(filter);
   return handler;
 }
  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;
  }