Package org.glassfish.jersey.jettison
Class JettisonJaxbContext
java.lang.Object
jakarta.xml.bind.JAXBContext
org.glassfish.jersey.jettison.JettisonJaxbContext
- All Implemented Interfaces:
 JettisonConfigured
public final class JettisonJaxbContext
extends jakarta.xml.bind.JAXBContext
implements JettisonConfigured
An adaption of 
JAXBContext that supports marshalling
 and unmarshalling of JAXB beans using the JSON format.
 
 The JSON format may be configured by using a JettisonConfig object
 as a constructor parameter of this class.
- 
Field Summary
Fields inherited from class jakarta.xml.bind.JAXBContext
JAXB_CONTEXT_FACTORY - 
Constructor Summary
ConstructorsConstructorDescriptionJettisonJaxbContext(Class... classesToBeBound) Constructs a new instance with defaultJettisonConfig.JettisonJaxbContext(Class[] classesToBeBound, Map<String, Object> properties) Constructs a new instance with a custom set of properties.JettisonJaxbContext(String contextPath) Construct a new instance of using context class loader of the thread with defaultJettisonConfig.JettisonJaxbContext(String contextPath, ClassLoader classLoader) Construct a new instance using a specified class loader with defaultJettisonConfig.JettisonJaxbContext(String contextPath, ClassLoader classLoader, Map<String, Object> properties) Construct a new instance using a specified class loader and a custom set of properties.JettisonJaxbContext(JettisonConfig config, Class... classesToBeBound) Constructs a new instance with givenJettisonConfig.JettisonJaxbContext(JettisonConfig config, Class[] classesToBeBound, Map<String, Object> properties) Constructs a new instance with a custom set of properties.JettisonJaxbContext(JettisonConfig config, String contextPath) Construct a new instance of using context class loader of the thread with givenJettisonConfig.JettisonJaxbContext(JettisonConfig config, String contextPath, ClassLoader classLoader, Map<String, Object> properties) Construct a new instance using a specified class loader, set of properties andJettisonConfig. - 
Method Summary
Modifier and TypeMethodDescriptionCreate a JSON marshaller.Create a JSON unmarshaller.jakarta.xml.bind.MarshallerOverrides underlaying createMarshaller method and returns a marshaller which is capable of JSON serialization.jakarta.xml.bind.UnmarshallerOverrides underlying createUnmarshaller method and returns an unmarshaller which is capable of JSON deserialization.Get the JSON configuration.static JettisonMarshallergetJSONMarshaller(jakarta.xml.bind.Marshaller marshaller) Get aJettisonMarshallerfrom aMarshaller.static JettisonUnmarshallergetJSONUnmarshaller(jakarta.xml.bind.Unmarshaller unmarshaller) Get aJettisonUnmarshallerfrom aUnmarshaller.Methods inherited from class jakarta.xml.bind.JAXBContext
createBinder, createBinder, createJAXBIntrospector, generateSchema, newInstance, newInstance, newInstance, newInstance, newInstance 
- 
Constructor Details
- 
JettisonJaxbContext
Constructs a new instance with defaultJettisonConfig.- Parameters:
 classesToBeBound- list of java classes to be recognized by the new JsonJaxbContext. Can be empty, in which case a JsonJaxbContext that only knows about spec-defined classes will be returned.- Throws:
 jakarta.xml.bind.JAXBException- if an error was encountered while creating the underlying JAXBContext.
 - 
JettisonJaxbContext
public JettisonJaxbContext(JettisonConfig config, Class... classesToBeBound) throws jakarta.xml.bind.JAXBException Constructs a new instance with givenJettisonConfig.- Parameters:
 config-JettisonConfig, can not be nullclassesToBeBound- list of java classes to be recognized by the new JsonJaxbContext. Can be empty, in which case a JsonJaxbContext that only knows about spec-defined classes will be returned.- Throws:
 jakarta.xml.bind.JAXBException- if an error was encountered while creating the underlying JAXBContext.
 - 
JettisonJaxbContext
public JettisonJaxbContext(Class[] classesToBeBound, Map<String, Object> properties) throws jakarta.xml.bind.JAXBExceptionConstructs a new instance with a custom set of properties. The defaultJettisonConfigis used if no (now deprecated) JSON related properties are specified- Parameters:
 classesToBeBound- list of java classes to be recognized by the new JsonJaxbContext. Can be empty, in which case a JsonJaxbContext that only knows about spec-defined classes will be returned.properties- the custom set of properties. If it contains(now deprecated) JSON related properties, then a non-defaultJettisonConfigis used reflecting the JSON properties- Throws:
 jakarta.xml.bind.JAXBException- if an error was encountered while creating the underlying JAXBContext.
 - 
JettisonJaxbContext
public JettisonJaxbContext(JettisonConfig config, Class[] classesToBeBound, Map<String, Object> properties) throws jakarta.xml.bind.JAXBExceptionConstructs a new instance with a custom set of properties. If no (now deprecated) JSON related properties are specified, theJettisonConfig.DEFAULTis used asJettisonConfig- Parameters:
 config-JettisonConfig, can not be nullclassesToBeBound- list of java classes to be recognized by the new JsonJaxbContext. Can be empty, in which case a JsonJaxbContext that only knows about spec-defined classes will be returned.properties- the custom set of properties.- Throws:
 jakarta.xml.bind.JAXBException- if an error was encountered while creating the underlying JAXBContext.
 - 
JettisonJaxbContext
Construct a new instance of using context class loader of the thread with defaultJettisonConfig.- Parameters:
 contextPath- list of java package names that contain schema derived class and/or java to schema (JAXB-annotated) mapped classes- Throws:
 jakarta.xml.bind.JAXBException- if an error was encountered while creating the underlying JAXBContext.
 - 
JettisonJaxbContext
public JettisonJaxbContext(JettisonConfig config, String contextPath) throws jakarta.xml.bind.JAXBException Construct a new instance of using context class loader of the thread with givenJettisonConfig.- Parameters:
 config-JettisonConfig, can not be nullcontextPath- list of java package names that contain schema derived class and/or java to schema (JAXB-annotated) mapped classes- Throws:
 jakarta.xml.bind.JAXBException- if an error was encountered while creating the underlying JAXBContext.
 - 
JettisonJaxbContext
public JettisonJaxbContext(String contextPath, ClassLoader classLoader) throws jakarta.xml.bind.JAXBException Construct a new instance using a specified class loader with defaultJettisonConfig.- Parameters:
 contextPath- list of java package names that contain schema derived class and/or java to schema (JAXB-annotated) mapped classesclassLoader-- Throws:
 jakarta.xml.bind.JAXBException- if an error was encountered while creating the underlying JAXBContext.
 - 
JettisonJaxbContext
public JettisonJaxbContext(String contextPath, ClassLoader classLoader, Map<String, Object> properties) throws jakarta.xml.bind.JAXBExceptionConstruct a new instance using a specified class loader and a custom set of properties.JettisonConfigis set to default, if user does not specify any (now deprecated) JSON related properties- Parameters:
 contextPath- list of java package names that contain schema derived class and/or java to schema (JAXB-annotated) mapped classesclassLoader-properties- the custom set of properties.- Throws:
 jakarta.xml.bind.JAXBException- if an error was encountered while creating the underlying JAXBContext.
 - 
JettisonJaxbContext
public JettisonJaxbContext(JettisonConfig config, String contextPath, ClassLoader classLoader, Map<String, Object> properties) throws jakarta.xml.bind.JAXBExceptionConstruct a new instance using a specified class loader, set of properties andJettisonConfig.- Parameters:
 config-JettisonConfig, can not be nullcontextPath- list of java package names that contain schema derived class and/or java to schema (JAXB-annotated) mapped classesclassLoader-properties- the custom set of properties.- Throws:
 jakarta.xml.bind.JAXBException- if an error was encountered while creating the underlying JAXBContext.
 
 - 
 - 
Method Details
- 
getJSONMarshaller
Get aJettisonMarshallerfrom aMarshaller.- Parameters:
 marshaller- the JAXB marshaller.- Returns:
 - the JSON marshaller.
 
 - 
getJSONUnmarshaller
Get aJettisonUnmarshallerfrom aUnmarshaller.- Parameters:
 unmarshaller- the JAXB unmarshaller.- Returns:
 - the JSON unmarshaller.
 
 - 
getJSONConfiguration
Get the JSON configuration.- Specified by:
 getJSONConfigurationin interfaceJettisonConfigured- Returns:
 - the JSON configuration.
 
 - 
createJsonUnmarshaller
Create a JSON unmarshaller.- Returns:
 - the JSON unmarshaller
 - Throws:
 jakarta.xml.bind.JAXBException- if there is an error creating the unmarshaller.
 - 
createJsonMarshaller
Create a JSON marshaller.- Returns:
 - the JSON marshaller.
 - Throws:
 jakarta.xml.bind.JAXBException- if there is an error creating the marshaller.
 - 
createUnmarshaller
public jakarta.xml.bind.Unmarshaller createUnmarshaller() throws jakarta.xml.bind.JAXBExceptionOverrides underlying createUnmarshaller method and returns an unmarshaller which is capable of JSON deserialization.- Specified by:
 createUnmarshallerin classjakarta.xml.bind.JAXBContext- Returns:
 - unmarshaller instance with JSON capabilities
 - Throws:
 jakarta.xml.bind.JAXBException
 - 
createMarshaller
public jakarta.xml.bind.Marshaller createMarshaller() throws jakarta.xml.bind.JAXBExceptionOverrides underlaying createMarshaller method and returns a marshaller which is capable of JSON serialization.- Specified by:
 createMarshallerin classjakarta.xml.bind.JAXBContext- Returns:
 - marshaller instance with JSON capabilities
 - Throws:
 jakarta.xml.bind.JAXBException
 
 -