Rework body formatting wiring
[netconf.git] / restconf / restconf-nb / src / main / java / org / opendaylight / restconf / nb / jaxrs / XmlJaxRsFormattableBodyWriter.java
1 /*
2  * Copyright (c) 2024 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.restconf.nb.jaxrs;
9
10 import java.io.IOException;
11 import java.io.OutputStream;
12 import javax.ws.rs.Produces;
13 import javax.ws.rs.core.MediaType;
14 import javax.ws.rs.ext.Provider;
15 import org.opendaylight.restconf.api.FormatParameters;
16 import org.opendaylight.restconf.api.FormattableBody;
17 import org.opendaylight.restconf.api.MediaTypes;
18
19 @Provider
20 @Produces({ MediaTypes.APPLICATION_YANG_DATA_XML, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
21 public final class XmlJaxRsFormattableBodyWriter extends JaxRsFormattableBodyWriter {
22     @Override
23     void writeTo(final FormattableBody body, final FormatParameters format, final OutputStream out) throws IOException {
24         body.formatToXML(format, out);
25     }
26 }