org.glassfish.jersey.jaxb.internal.AbstractRootElementJaxbProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jersey-media-jaxb Show documentation
Show all versions of jersey-media-jaxb Show documentation
JAX-RS features based upon JAX-B.
/*
* Copyright (c) 2010, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package org.glassfish.jersey.jaxb.internal;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import javax.ws.rs.BadRequestException;
import javax.ws.rs.InternalServerErrorException;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Configuration;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.NoContentException;
import javax.ws.rs.ext.Providers;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.UnmarshalException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.transform.stream.StreamSource;
import org.glassfish.jersey.internal.LocalizationMessages;
import org.glassfish.jersey.message.internal.EntityInputStream;
import org.glassfish.jersey.message.internal.ReaderWriter;
/**
* An abstract provider for JAXB types that are annotated with
* {@link XmlRootElement} or {@link XmlType}.
*
* Implementing classes may extend this class to provide specific marshalling
* and unmarshalling behaviour.
*
* When unmarshalling a {@link UnmarshalException} will result in a
* {@link WebApplicationException} being thrown with a status of 400
* (Client error), and a {@link JAXBException} will result in a
* {@link WebApplicationException} being thrown with a status of 500
* (Internal Server error).
*
* When marshalling a {@link JAXBException} will result in a
* {@link WebApplicationException} being thrown with a status of 500
* (Internal Server error).
*
* @author Paul Sandoz
* @author Marek Potociar
*/
public abstract class AbstractRootElementJaxbProvider extends AbstractJaxbProvider