public XmlProjectDescriptorSerializer(boolean postProcess) {
    xstream = new XStream(new DomDriver());
    xstream.ignoreUnknownElements();
    xstream.omitField(ProjectDescriptor.class, "id"); // This field was deprecated
    xstream.omitField(ProjectDescriptor.class, "log");
    xstream.omitField(ProjectDescriptor.class, "classLoader");
    xstream.omitField(ProjectDescriptor.class, "projectFolder");
    xstream.omitField(Module.class, "properties"); // properties doesn't supported by rules.xml
    xstream.omitField(Module.class, "wildcardName"); // runtime properties
    xstream.omitField(Module.class, "wildcardRulesRootPath"); // runtime properties
    xstream.omitField(Module.class, "project"); // runtime properties

    xstream.setMode(XStream.NO_REFERENCES);

    xstream.aliasType(PROJECT_DESCRIPTOR_TAG, ProjectDescriptor.class);
    xstream.aliasType(MODULE_TAG, Module.class);
    xstream.aliasType(DEPENDENCY_TAG, ProjectDependencyDescriptor.class);
    xstream.aliasType(PATH_TAG, PathEntry.class);
    xstream.aliasType(PROPERTY_TAG, Property.class);
    xstream.aliasField(
        PROPERTIES_FILE_NAME_PATTERN, ProjectDescriptor.class, "propertiesFileNamePattern");
    xstream.aliasField(
        PROPERTIES_FILE_NAME_PROCESSOR, ProjectDescriptor.class, "propertiesFileNameProcessor");
    xstream.addDefaultImplementation(HashSet.class, Collection.class);
    xstream.alias("value", String.class);

    xstream.useAttributeFor(PathEntry.class, "path");
    xstream.aliasField("rules-root", Module.class, "rulesRootPath");
    xstream.aliasField(METHOD_FILTER_TAG, Module.class, "methodFilter");
    xstream.registerConverter(new StringValueConverter());

    this.postProcess = postProcess;
  }
  public static XStream init() {
    xstream = new XStream(new DomDriver());
    xstream.aliasType("config", Config.class);
    xstream.useAttributeFor(Config.class, "updateVersion");

    xstream.aliasType("global", Global.class);
    xstream.aliasType("geoserver", Geoserver.class);
    xstream.aliasType("db", DB.class);
    xstream.aliasType("Intersections", List.class);
    xstream.aliasType("intersection", Intersection.class);
    xstream.useAttributeFor(Intersection.class, "mask");
    xstream.useAttributeFor(Intersection.class, "force");
    xstream.useAttributeFor(Intersection.class, "preserveTrgGeom");

    return xstream;
  }
 /* (non-Javadoc)
  * @see org.deckfour.xes.xstream.XConverter#registerAliases(com.thoughtworks.xstream.XStream)
  */
 @Override
 public void registerAliases(XStream stream) {
   stream.aliasType("XExtension", XExtension.class);
 }
  /**
   * Configure the XStream instance with this marshaller's bean properties.
   *
   * @param xstream the {@code XStream} instance
   */
  protected void configureXStream(XStream xstream) {
    if (this.converters != null) {
      for (int i = 0; i < this.converters.length; i++) {
        if (this.converters[i] instanceof Converter) {
          xstream.registerConverter((Converter) this.converters[i], i);
        } else if (this.converters[i] instanceof SingleValueConverter) {
          xstream.registerConverter((SingleValueConverter) this.converters[i], i);
        } else {
          throw new IllegalArgumentException(
              "Invalid ConverterMatcher [" + this.converters[i] + "]");
        }
      }
    }

    if (this.marshallingStrategy != null) {
      xstream.setMarshallingStrategy(this.marshallingStrategy);
    }
    if (this.mode != null) {
      xstream.setMode(this.mode);
    }

    try {
      if (this.aliases != null) {
        Map<String, Class<?>> classMap = toClassMap(this.aliases);
        for (Map.Entry<String, Class<?>> entry : classMap.entrySet()) {
          xstream.alias(entry.getKey(), entry.getValue());
        }
      }
      if (this.aliasesByType != null) {
        Map<String, Class<?>> classMap = toClassMap(this.aliasesByType);
        for (Map.Entry<String, Class<?>> entry : classMap.entrySet()) {
          xstream.aliasType(entry.getKey(), entry.getValue());
        }
      }
      if (this.fieldAliases != null) {
        for (Map.Entry<String, String> entry : this.fieldAliases.entrySet()) {
          String alias = entry.getValue();
          String field = entry.getKey();
          int idx = field.lastIndexOf('.');
          if (idx != -1) {
            String className = field.substring(0, idx);
            Class<?> clazz = ClassUtils.forName(className, this.beanClassLoader);
            String fieldName = field.substring(idx + 1);
            xstream.aliasField(alias, clazz, fieldName);
          } else {
            throw new IllegalArgumentException("Field name [" + field + "] does not contain '.'");
          }
        }
      }
    } catch (ClassNotFoundException ex) {
      throw new IllegalStateException("Failed to load specified alias class", ex);
    }

    if (this.useAttributeForTypes != null) {
      for (Class<?> type : this.useAttributeForTypes) {
        xstream.useAttributeFor(type);
      }
    }
    if (this.useAttributeFor != null) {
      for (Map.Entry<?, ?> entry : this.useAttributeFor.entrySet()) {
        if (entry.getKey() instanceof String) {
          if (entry.getValue() instanceof Class) {
            xstream.useAttributeFor((String) entry.getKey(), (Class<?>) entry.getValue());
          } else {
            throw new IllegalArgumentException(
                "'useAttributesFor' takes Map<String, Class> when using a map key of type String");
          }
        } else if (entry.getKey() instanceof Class) {
          Class<?> key = (Class<?>) entry.getKey();
          if (entry.getValue() instanceof String) {
            xstream.useAttributeFor(key, (String) entry.getValue());
          } else if (entry.getValue() instanceof List) {
            @SuppressWarnings("unchecked")
            List<Object> listValue = (List<Object>) entry.getValue();
            for (Object element : listValue) {
              if (element instanceof String) {
                xstream.useAttributeFor(key, (String) element);
              }
            }
          } else {
            throw new IllegalArgumentException(
                "'useAttributesFor' property takes either Map<Class, String> "
                    + "or Map<Class, List<String>> when using a map key of type Class");
          }
        } else {
          throw new IllegalArgumentException(
              "'useAttributesFor' property takes either a map key of type String or Class");
        }
      }
    }

    if (this.implicitCollections != null) {
      for (Map.Entry<Class<?>, String> entry : this.implicitCollections.entrySet()) {
        String[] collectionFields = StringUtils.commaDelimitedListToStringArray(entry.getValue());
        for (String collectionField : collectionFields) {
          xstream.addImplicitCollection(entry.getKey(), collectionField);
        }
      }
    }
    if (this.omittedFields != null) {
      for (Map.Entry<Class<?>, String> entry : this.omittedFields.entrySet()) {
        String[] fields = StringUtils.commaDelimitedListToStringArray(entry.getValue());
        for (String field : fields) {
          xstream.omitField(entry.getKey(), field);
        }
      }
    }

    if (this.annotatedClasses != null) {
      xstream.processAnnotations(this.annotatedClasses);
    }
    if (this.autodetectAnnotations) {
      xstream.autodetectAnnotations(true);
    }
  }