@@ -0,0 +1,2238 @@
+/*%0D%0A * Copyright 2009 the original author or authors.%0D%0A * %0D%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0D%0A * you may not use this file except in compliance with the License.%0D%0A * You may obtain a copy of the License at%0D%0A *%0D%0A *     http://www.apache.org/licenses/LICENSE-2.0%0D%0A *     %0D%0A * Unless required by applicable law or agreed to in writing, software%0D%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0D%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0D%0A * See the License for the specific language governing permissions and%0D%0A * limitations under the License.%0D%0A */%0D%0Apackage org.grails.jaxrs.provider;%0D%0A%0D%0Aimport grails.converters.XML;%0D%0A%0D%0Aimport java.io.IOException;%0D%0Aimport java.io.OutputStream;%0D%0Aimport java.io.OutputStreamWriter;%0D%0Aimport java.io.Writer;%0D%0A%0D%0Aimport javax.ws.rs.WebApplicationException;%0D%0Aimport javax.ws.rs.core.MultivaluedMap;%0D%0Aimport javax.ws.rs.ext.Provider;%0D%0A%0D%0Aimport org.codehaus.groovy.grails.web.converters.configuration.ConvertersConfigurationHolder;%0D%0Aimport org.grails.jaxrs.support.MessageBodyWriterSupport;%0D%0Aimport org.springframework.stereotype.Component;%0D%0A%0D%0A/**%0D%0A * Provider for Grails' %7B@link XML%7D converter class.%0D%0A * %0D%0A * @author Martin Krasser%0D%0A */%0D%0A@Component%0D%0A@Provider%0D%0Apublic class XMLWriter extends MessageBodyWriterSupport%3CXML%3E %7B%0D%0A%0D%0A    public static final String DEFAULT_CHARSET = %22UTF-8%22;%0D%0A%0D%0A    /**%0D%0A     * Renders the %3Ccode%3Exml%3C/code%3E object to the response's%0D%0A     * %3Ccode%3EentityStream%3C/code%3E.%0D%0A     * %0D%0A     * @param xml%0D%0A     *            XML converter object.%0D%0A     * @param httpHeaders%0D%0A     * @param entityStream%0D%0A     */%0D%0A    @Override%0D%0A    protected void writeTo(XML xml, MultivaluedMap%3CString, Object%3E httpHeaders, OutputStream entityStream) %0D%0A        throws IOException, WebApplicationException %7B%0D%0A        String charset = ConvertersConfigurationHolder.getConverterConfiguration(XML.class).getEncoding();%0D%0A        Writer writer = null;%0D%0A        if (charset == null) %7B%0D%0A            writer = new OutputStreamWriter(entityStream, DEFAULT_CHARSET);%0D%0A        %7D else %7B%0D%0A            writer = new OutputStreamWriter(entityStream, charset);%0D%0A        %7D%0D%0A        xml.render(writer);%0D%0A        writer.flush();%0D%0A%0D%0A    %7D%0D%0A    %0D%0A%7D%0D%0A

support for rendering via grails.converters.XML