private void writeTransport(
     XMLExtendedStreamWriter writer, GlobalConfiguration globalConfiguration)
     throws XMLStreamException {
   TransportConfiguration transport = globalConfiguration.transport();
   AttributeSet attributes = transport.attributes();
   if (attributes.isModified()) {
     writer.writeStartElement(Element.TRANSPORT);
     attributes.write(writer, TransportConfiguration.CLUSTER_NAME, Attribute.CLUSTER);
     attributes.write(writer, TransportConfiguration.MACHINE_ID, Attribute.MACHINE_ID);
     attributes.write(writer, TransportConfiguration.RACK_ID, Attribute.RACK_ID);
     if (transport.siteId() != null) {
       attributes.write(writer, TransportConfiguration.SITE_ID, Attribute.SITE);
     } else if (globalConfiguration.sites().localSite() != null) {
       writer.writeAttribute(Attribute.SITE, globalConfiguration.sites().localSite());
     }
     attributes.write(writer, TransportConfiguration.NODE_NAME, Attribute.NODE_NAME);
     TypedProperties properties = globalConfiguration.transport().properties();
     if (properties.containsKey("stack")) {
       writer.writeAttribute(Attribute.STACK, properties.getProperty("stack"));
     }
     if (transport.remoteCommandThreadPool().threadPoolFactory() != null) {
       writer.writeAttribute(Attribute.REMOTE_COMMAND_EXECUTOR, "remote-command-pool");
     }
     if (transport.transportThreadPool().threadPoolFactory() != null) {
       writer.writeAttribute(Attribute.EXECUTOR, "transport-pool");
     }
     writer.writeEndElement();
   }
 }
 @Override
 public TypedProperties unmarshal(PropertiesType props) throws Exception {
   TypedProperties tp = new TypedProperties();
   if (props != null && props.properties != null) {
     for (Property p : props.properties) {
       tp.put(p.name, p.value);
     }
   }
   return tp;
 }
 @Override
 public PropertiesType marshal(TypedProperties tp) throws Exception {
   PropertiesType pxml = new PropertiesType();
   Property[] pa = new Property[tp.size()];
   Set<Entry<Object, Object>> set = tp.entrySet();
   int index = 0;
   for (Entry<Object, Object> entry : set) {
     pa[index] = new Property();
     pa[index].name = (String) entry.getKey();
     pa[index].value = (String) entry.getValue();
     index++;
   }
   pxml.properties = pa;
   return pxml;
 }
 @Override
 public CassandraCacheStoreConfiguration create() {
   List<CassandraServerConfiguration> remoteServers =
       new ArrayList<CassandraServerConfiguration>();
   for (CassandraServerConfigurationBuilder server : servers) {
     remoteServers.add(server.create());
   }
   return new CassandraCacheStoreConfiguration(
       autoCreateKeyspace,
       configurationPropertiesFile,
       entryColumnFamily,
       expirationColumnFamily,
       framed,
       remoteServers,
       keyMapper,
       keySpace,
       password,
       sharedKeyspace,
       username,
       readConsistencyLevel,
       writeConsistencyLevel,
       autoCreateKeyspace,
       sharedKeyspace,
       purgerThreads,
       framed,
       autoCreateKeyspace,
       TypedProperties.toTypedProperties(properties),
       async.create(),
       singletonStore.create());
 }
 private void writeJGroups(XMLExtendedStreamWriter writer, GlobalConfiguration globalConfiguration)
     throws XMLStreamException {
   if (globalConfiguration.isClustered()) {
     writer.writeStartElement(Element.JGROUPS);
     writer.writeAttribute(
         Attribute.TRANSPORT, globalConfiguration.transport().transport().getClass().getName());
     TypedProperties properties = globalConfiguration.transport().properties();
     for (String property : properties.stringPropertyNames()) {
       if (property.startsWith("stack-")) {
         String stackName = properties.getProperty(property);
         String path = properties.getProperty("stackFilePath-" + stackName);
         writer.writeStartElement(Element.STACK_FILE);
         writer.writeAttribute(Attribute.NAME, stackName);
         writer.writeAttribute(Attribute.PATH, path);
         writer.writeEndElement();
       }
     }
     writer.writeEndElement();
   }
 }
 @Override
 public CountingCacheStoreConfiguration create() {
   return new CountingCacheStoreConfiguration(
       purgeOnStartup,
       purgeSynchronously,
       purgerThreads,
       fetchPersistentState,
       ignoreModifications,
       TypedProperties.toTypedProperties(properties),
       async.create(),
       singletonStore.create());
 }
  public static Properties extractProperties(Element source) {
    TypedProperties p = new TypedProperties();
    NodeList list = source.getElementsByTagName("property");
    if (list == null) return null;
    // loop through attributes
    for (int loop = 0; loop < list.getLength(); loop++) {
      Node node = list.item(loop);
      if (node.getNodeType() != Node.ELEMENT_NODE) continue;

      // for each element (attribute) ...
      Element element = (Element) node;
      String name = element.getAttribute("name");
      String valueStr = element.getAttribute("value");

      if (valueStr.length() > 0) {
        valueStr = valueStr.trim();
        valueStr = StringPropertyReplacer.replaceProperties(valueStr);
        p.put(name, valueStr);
      }
    }
    return p.isEmpty() ? null : p;
  }
 @Override
 public LevelDBCacheStoreConfiguration create() {
   return new LevelDBCacheStoreConfiguration(
       location,
       expiredLocation,
       implementationType,
       compressionType,
       blockSize,
       cacheSize,
       expiryQueueSize,
       clearThreshold,
       lockAcquistionTimeout,
       lockConcurrencyLevel,
       purgeOnStartup,
       purgeSynchronously,
       purgerThreads,
       fetchPersistentState,
       ignoreModifications,
       TypedProperties.toTypedProperties(properties),
       async.create(),
       singletonStore.create());
 }
 public InterceptorConfigurationBuilder removeProperty(String key) {
   TypedProperties properties = attributes.attribute(PROPERTIES).get();
   properties.remove(key);
   attributes.attribute(PROPERTIES).set(TypedProperties.toTypedProperties(properties));
   return this;
 }
 public InterceptorConfigurationBuilder addProperty(String key, String value) {
   TypedProperties properties = attributes.attribute(PROPERTIES).get();
   properties.put(key, value);
   attributes.attribute(PROPERTIES).set(TypedProperties.toTypedProperties(properties));
   return this;
 }
 /**
  * Clears the interceptor properties
  *
  * @return this InterceptorConfigurationBuilder
  */
 public InterceptorConfigurationBuilder clearProperties() {
   TypedProperties properties = attributes.attribute(PROPERTIES).get();
   properties.clear();
   attributes.attribute(PROPERTIES).set(TypedProperties.toTypedProperties(properties));
   return this;
 }
 /**
  * Sets interceptor properties
  *
  * @return this InterceptorConfigurationBuilder
  */
 public InterceptorConfigurationBuilder withProperties(Properties properties) {
   attributes.attribute(PROPERTIES).set(TypedProperties.toTypedProperties(properties));
   return this;
 }