public static ContainerListenerMetaData parse(XMLStreamReader reader) throws XMLStreamException {
    ContainerListenerMetaData containerListener = new ContainerListenerMetaData();

    // Handle elements
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
      final Element element = Element.forName(reader.getLocalName());
      switch (element) {
        case CLASS_NAME:
          containerListener.setListenerClass(getElementText(reader));
          break;
        case MODULE:
          containerListener.setModule(getElementText(reader));
          break;
        case LISTENER_TYPE:
          containerListener.setListenerType(ContainerListenerType.valueOf(getElementText(reader)));
          break;
        case PARAM:
          List<ParamValueMetaData> params = containerListener.getParams();
          if (params == null) {
            params = new ArrayList<ParamValueMetaData>();
            containerListener.setParams(params);
          }
          params.add(ParamValueMetaDataParser.parse(reader));
          break;
        default:
          throw unexpectedElement(reader);
      }
    }

    return containerListener;
  }
  public static HttpHandlerMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer)
      throws XMLStreamException {
    HttpHandlerMetaData valve = new HttpHandlerMetaData();

    // Handle elements
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
      final Element element = Element.forName(reader.getLocalName());
      switch (element) {
        case CLASS_NAME:
          valve.setHandlerClass(getElementText(reader, propertyReplacer));
          break;
        case MODULE:
          valve.setModule(getElementText(reader, propertyReplacer));
          break;
        case PARAM:
          List<ParamValueMetaData> params = valve.getParams();
          if (params == null) {
            params = new ArrayList<ParamValueMetaData>();
            valve.setParams(params);
          }
          params.add(ParamValueMetaDataParser.parse(reader, propertyReplacer));
          break;
        default:
          throw unexpectedElement(reader);
      }
    }

    return valve;
  }