use of grails.converters.XML in project grails-core by grails.
the class ConvertersConfigurationInitializer method initXMLConfiguration.
private void initXMLConfiguration() {
LOG.debug("Initializing default XML Converters Configuration...");
List<ObjectMarshaller<XML>> marshallers = new ArrayList<ObjectMarshaller<XML>>();
marshallers.addAll(getPreviouslyConfiguredMarshallers(XML.class));
marshallers.add(new org.grails.web.converters.marshaller.xml.Base64ByteArrayMarshaller());
marshallers.add(new org.grails.web.converters.marshaller.xml.ArrayMarshaller());
marshallers.add(new org.grails.web.converters.marshaller.xml.CollectionMarshaller());
marshallers.add(new org.grails.web.converters.marshaller.xml.MapMarshaller());
marshallers.add(new org.grails.web.converters.marshaller.xml.EnumMarshaller());
marshallers.add(new org.grails.web.converters.marshaller.xml.DateMarshaller());
marshallers.add(new ProxyUnwrappingMarshaller<XML>());
marshallers.add(new org.grails.web.converters.marshaller.xml.ToStringBeanMarshaller());
ProxyHandler proxyHandler = getProxyHandler();
Config grailsConfig = getGrailsConfig();
boolean includeDomainVersion = includeDomainVersionProperty(grailsConfig, "xml");
if (grailsConfig.getProperty(SETTING_CONVERTERS_XML_DEEP, Boolean.class, false)) {
marshallers.add(new org.grails.web.converters.marshaller.xml.DeepDomainClassMarshaller(includeDomainVersion, proxyHandler, grailsApplication));
} else {
marshallers.add(new org.grails.web.converters.marshaller.xml.DomainClassMarshaller(includeDomainVersion, proxyHandler, grailsApplication));
}
marshallers.add(new org.grails.web.converters.marshaller.xml.GroovyBeanMarshaller());
marshallers.add(new org.grails.web.converters.marshaller.xml.GenericJavaBeanMarshaller());
DefaultConverterConfiguration<XML> cfg = new DefaultConverterConfiguration<XML>(marshallers, proxyHandler);
cfg.setEncoding(grailsConfig.getProperty(SETTING_CONVERTERS_ENCODING, "UTF-8"));
String defaultCirRefBehaviour = grailsConfig.getProperty(SETTING_CONVERTERS_CIRCULAR_REFERENCE_BEHAVIOUR, "DEFAULT");
cfg.setCircularReferenceBehaviour(Converter.CircularReferenceBehaviour.valueOf(grailsConfig.getProperty("grails.converters.xml.circular.reference.behaviour", String.class, defaultCirRefBehaviour, Converter.CircularReferenceBehaviour.allowedValues())));
Boolean defaultPrettyPrint = grailsConfig.getProperty(SETTING_CONVERTERS_PRETTY_PRINT, Boolean.class, false);
Boolean prettyPrint = grailsConfig.getProperty("grails.converters.xml.pretty.print", Boolean.class, defaultPrettyPrint);
cfg.setPrettyPrint(prettyPrint);
cfg.setCacheObjectMarshallerByClass(grailsConfig.getProperty("grails.converters.xml.cacheObjectMarshallerSelectionByClass", Boolean.class, true));
registerObjectMarshallersFromApplicationContext(cfg, XML.class);
ConvertersConfigurationHolder.setDefaultConfiguration(XML.class, new ChainedConverterConfiguration<XML>(cfg, proxyHandler));
}
Aggregations