private void parseAuthentication(
     XMLExtendedStreamReader reader, MongoDBCacheStoreConfigurationBuilder builder)
     throws XMLStreamException {
   for (int i = 0; i < reader.getAttributeCount(); i++) {
     ParseUtils.requireNoNamespaceAttribute(reader, i);
     String value = replaceProperties(reader.getAttributeValue(i));
     Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
     switch (attribute) {
       case USERNAME:
         {
           builder.username(value);
           break;
         }
       case PASSWORD:
         {
           builder.password(value);
           break;
         }
       default:
         {
           throw ParseUtils.unexpectedAttribute(reader, i);
         }
     }
   }
   ParseUtils.requireNoContent(reader);
 }
  private void parseMongoDBStore(
      XMLExtendedStreamReader reader,
      LoadersConfigurationBuilder loadersBuilder,
      ClassLoader classLoader)
      throws XMLStreamException {
    MongoDBCacheStoreConfigurationBuilder builder =
        new MongoDBCacheStoreConfigurationBuilder(loadersBuilder);

    while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
      Element element = Element.forName(reader.getLocalName());
      switch (element) {
        case CONNECTION:
          {
            this.parseConnection(reader, builder);
            break;
          }
        case AUTHENTICATION:
          {
            this.parseAuthentication(reader, builder);
            break;
          }
        case STORAGE:
          {
            this.parseStorage(reader, builder);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedElement(reader);
          }
      }
    }
    loadersBuilder.addStore(builder);
  }
 private void parseStorage(
     XMLExtendedStreamReader reader, MongoDBCacheStoreConfigurationBuilder builder)
     throws XMLStreamException {
   for (int i = 0; i < reader.getAttributeCount(); i++) {
     ParseUtils.requireNoNamespaceAttribute(reader, i);
     String value = replaceProperties(reader.getAttributeValue(i));
     Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
     switch (attribute) {
       case DATABASE:
         {
           builder.database(value);
           break;
         }
       case COLLECTION:
         {
           builder.collection(value);
           break;
         }
       default:
         {
           throw ParseUtils.unexpectedElement(reader);
         }
     }
   }
   ParseUtils.requireNoContent(reader);
 }
 private void parseConnection(
     XMLExtendedStreamReader reader, MongoDBCacheStoreConfigurationBuilder builder)
     throws XMLStreamException {
   for (int i = 0; i < reader.getAttributeCount(); i++) {
     ParseUtils.requireNoNamespaceAttribute(reader, i);
     String value = replaceProperties(reader.getAttributeValue(i));
     Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
     switch (attribute) {
       case HOST:
         {
           builder.host(value);
           break;
         }
       case PORT:
         {
           builder.port(Integer.valueOf(value));
           break;
         }
       case TIMEOUT:
         {
           builder.timeout(Integer.valueOf(value));
           break;
         }
       case ACKNOWLEDGMENT:
         {
           builder.acknowledgment(Integer.valueOf(value));
           break;
         }
       default:
         {
           throw ParseUtils.unexpectedAttribute(reader, i);
         }
     }
   }
   ParseUtils.requireNoContent(reader);
 }
 @Override
 public void readElement(XMLExtendedStreamReader reader, ConfigurationBuilderHolder holder)
     throws XMLStreamException {
   ConfigurationBuilder builder = holder.getCurrentConfigurationBuilder();
   Element element = Element.forName(reader.getLocalName());
   switch (element) {
     case LEVELDB_STORE:
       {
         parseLevelDBCacheStore(
             reader, builder.persistence().addStore(LevelDBStoreConfigurationBuilder.class));
         break;
       }
     default:
       {
         throw ParseUtils.unexpectedElement(reader);
       }
   }
 }
  @Override
  public void readElement(
      XMLExtendedStreamReader xmlExtendedStreamReader,
      ConfigurationBuilderHolder configurationBuilderHolder)
      throws XMLStreamException {
    ConfigurationBuilder builder = configurationBuilderHolder.getCurrentConfigurationBuilder();

    Element element = Element.forName(xmlExtendedStreamReader.getLocalName());
    switch (element) {
      case MONGODB_STORE:
        {
          parseMongoDBStore(
              xmlExtendedStreamReader,
              builder.loaders(),
              configurationBuilderHolder.getClassLoader());
          break;
        }
      default:
        {
          throw ParseUtils.unexpectedElement(xmlExtendedStreamReader);
        }
    }
  }
  private void parseLevelDBCacheStore(
      XMLExtendedStreamReader reader, LevelDBStoreConfigurationBuilder builder)
      throws XMLStreamException {
    for (int i = 0; i < reader.getAttributeCount(); i++) {
      ParseUtils.requireNoNamespaceAttribute(reader, i);
      String attributeValue = reader.getAttributeValue(i);
      String value = StringPropertyReplacer.replaceProperties(attributeValue);
      String attrName = reader.getAttributeLocalName(i);
      Attribute attribute = Attribute.forName(attrName);

      switch (attribute) {
        case LOCATION:
          {
            builder.location(value);
            break;
          }
        case EXPIRED_LOCATION:
          {
            builder.expiredLocation(value);
            break;
          }
        case IMPLEMENTATION_TYPE:
          {
            builder.implementationType(LevelDBStoreConfiguration.ImplementationType.valueOf(value));
            break;
          }
        case CLEAR_THRESHOLD:
          {
            builder.clearThreshold(Integer.valueOf(value));
            break;
          }
        case EXPIRY_QUEUE_SIZE:
          {
            builder.expiryQueueSize(Integer.valueOf(value));
          }
        case BLOCK_SIZE:
          {
            builder.blockSize(Integer.valueOf(value));
            break;
          }
        case CACHE_SIZE:
          {
            builder.cacheSize(Long.valueOf(value));
            break;
          }
        case COMPRESSION_TYPE:
          {
            builder.compressionType(CompressionType.valueOf(value));
            break;
          }
        default:
          {
            Parser60.parseCommonStoreAttributes(reader, builder, attrName, attributeValue, i);
          }
      }
    }

    if (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
      ParseUtils.unexpectedElement(reader);
    }
  }