Class JAXBContextProperties


  • public class JAXBContextProperties
    extends java.lang.Object
    These are properties that may be passed in to create a JAXBContext:
     Map properties = new HashMap<String, Object>(1);
     properties.put();
     JAXBContext jc = JAXBContext.newInstance(new Class[] {Foo.class}, properties);
     
    Since:
    2.4.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ANNOTATION_HELPER
      The name of the property used to specify an AnnotationHelper instance.
      static java.lang.String BEAN_VALIDATION_FACETS
      Enables or disables generation of XML Facets during schemagen process.
      static java.lang.String BEAN_VALIDATION_FACTORY
      Property for setting preferred or custom validator factory.
      static java.lang.String BEAN_VALIDATION_GROUPS
      Property for setting bean validation target groups.
      static java.lang.String BEAN_VALIDATION_MODE
      Property for setting bean validation mode.
      static java.lang.String BEAN_VALIDATION_NO_OPTIMISATION
      Property for disabling Bean Validation optimisations.
      static java.lang.String DEFAULT_TARGET_NAMESPACE
      The name of the property used to specify a default target namespace.
      static java.lang.String JSON_ATTRIBUTE_PREFIX
      ` The name of the property used to specify a value that will be prepended to all keys that are mapped to an XML attribute.
      static java.lang.String JSON_INCLUDE_ROOT
      The name of the property used to specify in the root node should be included in the message (default is true).
      static java.lang.String JSON_NAMESPACE_SEPARATOR
      The name of the property used to specify the character (default is '.')
      static java.lang.String JSON_TYPE_ATTRIBUTE_NAME
      Override default type property name for JSON as MOXy type discriminator.
      static java.lang.String JSON_TYPE_COMPATIBILITY
      If we should treat unqualified type property in JSON as MOXy type discriminator.
      static java.lang.String JSON_USE_XSD_TYPES_WITH_PREFIX
      If there should be xsd prefix when using simple types, e.g. xsd.int.
      static java.lang.String JSON_VALUE_WRAPPER
      The name of the property used to specify the key that will correspond to the property mapped with @XmlValue.
      static java.lang.String JSON_WRAPPER_AS_ARRAY_NAME
      The Constant JSON_WRAPPER_AS_ARRAY_NAME.
      static java.lang.String MEDIA_TYPE
      The name of the property used to specify the type of binding to be performed.
      static java.lang.String MOXY_LOG_PAYLOAD
      Property for logging Entities content during marshalling/unmarshalling operation in MOXy.
      static java.lang.String MOXY_LOGGING_LEVEL
      Property for MOXy logging level.
      static java.lang.String NAMESPACE_PREFIX_MAPPER
      The Constant NAMESPACE_PREFIX_MAPPER.
      static java.lang.String OBJECT_GRAPH
      The name of the property used to specify an ObjectGraph instance or name of an ObjectGraph to be used on Unmarshallers and Marshallers created by the context.
      static java.lang.String OXM_METADATA_SOURCE
      The name of the property used to specify one or more EclipseLink OXM metadata sources.
      static java.lang.String SESSION_EVENT_LISTENER
      The name of the property used to specify a SessionEventListener that can be used to customize the metadata before or after it has been initialized.
      static java.lang.String UNMARSHALLING_CASE_INSENSITIVE
      If set to Boolean.TRUE, JAXBUnmarshaller will match XML Elements and XML Attributes to Java fields case insensitively.
      static java.lang.String XML_ACCESSOR_FACTORY_SUPPORT
      The name of the boolean property used to enable custom XmlAccessorFactories.
    • Method Summary

      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • JSON_ATTRIBUTE_PREFIX

        public static final java.lang.String JSON_ATTRIBUTE_PREFIX
        ` The name of the property used to specify a value that will be prepended to all keys that are mapped to an XML attribute. By default there is no attribute prefix. There is no effect when media type is "application/xml". When this property is specified at the JAXBContext level all instances of Marshaller and Unmarshaller will default to this attribute prefix.
        See Also:
        MarshallerProperties.JSON_ATTRIBUTE_PREFIX, UnmarshallerProperties.JSON_ATTRIBUTE_PREFIX, Constant Field Values
        Since:
        2.4
      • JSON_INCLUDE_ROOT

        public static final java.lang.String JSON_INCLUDE_ROOT
        The name of the property used to specify in the root node should be included in the message (default is true). There is no effect when media type is "application/xml". When this property is specified at the JAXBContext level all instances of Marshaller and Unmarshaller will default to this setting.
        See Also:
        JSON_INCLUDE_ROOT, UnmarshallerProperties.JSON_INCLUDE_ROOT, Constant Field Values
        Since:
        2.4
      • JSON_NAMESPACE_SEPARATOR

        public static final java.lang.String JSON_NAMESPACE_SEPARATOR
        The name of the property used to specify the character (default is '.') that separates the prefix from the key name. It is only used if namespace qualification has been enabled be setting a namespace prefix mapper. When this property is specified at the JAXBContext level all instances of Marshaller and Unmarshaller will default to this setting.
        See Also:
        MarshallerProperties.JSON_NAMESPACE_SEPARATOR, UnmarshallerProperties.JSON_NAMESPACE_SEPARATOR, Constant Field Values
        Since:
        2.4
      • JSON_VALUE_WRAPPER

        public static final java.lang.String JSON_VALUE_WRAPPER
        The name of the property used to specify the key that will correspond to the property mapped with @XmlValue. This key will only be used if there are other mapped properties. When this property is specified at the JAXBContext level all instances of Marshaller and Unmarshaller will default to this setting.
        See Also:
        MarshallerProperties.JSON_VALUE_WRAPPER, UnmarshallerProperties.JSON_VALUE_WRAPPER, Constant Field Values
        Since:
        2.4
      • MEDIA_TYPE

        public static final java.lang.String MEDIA_TYPE
        The name of the property used to specify the type of binding to be performed. When this property is specified at the JAXBContext level all instances of Marshaller and Unmarshaller will default to this media type. Supported values are:
        • MediaType.APPLICATION_XML (default)
        • MediaType.APPLICATION_JSON
        • "application/xml"
        • "application/json"
        See Also:
        MarshallerProperties.MEDIA_TYPE, UnmarshallerProperties.MEDIA_TYPE, MediaType, Constant Field Values
        Since:
        2.4
      • NAMESPACE_PREFIX_MAPPER

        public static final java.lang.String NAMESPACE_PREFIX_MAPPER
        The Constant NAMESPACE_PREFIX_MAPPER. Provides a means to customize the namespace prefixes used while marshalling to XML. Used for both marshal and unmarshal when mediaType is set to "application/json". Value is either a Map of URIs to prefixes, or an implementation of org.eclipse.persistence.oxm.NamespacePrefixMapper.
        See Also:
        NamespacePrefixMapper, Constant Field Values
        Since:
        2.4
      • SESSION_EVENT_LISTENER

        public static final java.lang.String SESSION_EVENT_LISTENER
        The name of the property used to specify a SessionEventListener that can be used to customize the metadata before or after it has been initialized. Value is either an implementation of org.eclipse.persistence.sessions.SessionEventListener or a List<org.eclipse.persistence.sessions.SessionEventListener>.
        See Also:
        SessionEventListener, Constant Field Values
        Since:
        2.4
      • OXM_METADATA_SOURCE

        public static final java.lang.String OXM_METADATA_SOURCE
        The name of the property used to specify one or more EclipseLink OXM metadata sources. The metadata source can be one of the following:
        • java.io.File
        • java.io.InputStream
        • java.io.Reader
        • java.lang.String
        • java.net.URL
        • javax.xml.stream.XMLEventReader
        • javax.xml.stream.XMLStreamReader
        • javax.xml.transform.Source
        • org.eclipse.persistence.jaxb.metadata.MetadataSource
        • org.w3c.dom.Node
        • org.xml.sax.InputSource
        To specify multiple metadata sources, the following can be used:
        • java.util.Map
        • java.util.List<Object>
        See Also:
        Constant Field Values
        Since:
        2.4, replaces JAXBContextFactory.ECLIPSELINK_OXM_XML_KEY
      • DEFAULT_TARGET_NAMESPACE

        public static final java.lang.String DEFAULT_TARGET_NAMESPACE
        The name of the property used to specify a default target namespace.
        See Also:
        Constant Field Values
        Since:
        2.4, replaces JAXBContextFactory.DEFAULT_TARGET_NAMESPACE_KEY
      • ANNOTATION_HELPER

        public static final java.lang.String ANNOTATION_HELPER
        The name of the property used to specify an AnnotationHelper instance. An AnnotationHelper is responsible for returning Annotations from AnnotatedElements.
        See Also:
        AnnotationHelper, Annotation, AnnotatedElement, Constant Field Values
        Since:
        2.4, replaces JAXBContextFactory.ANNOTATION_HELPER_KEY
      • XML_ACCESSOR_FACTORY_SUPPORT

        public static final java.lang.String XML_ACCESSOR_FACTORY_SUPPORT
        The name of the boolean property used to enable custom XmlAccessorFactories.
        See Also:
        com.sun.xml.internal.bind.XmlAccessorFactory, Constant Field Values
        Since:
        2.4.2
      • OBJECT_GRAPH

        public static final java.lang.String OBJECT_GRAPH
        The name of the property used to specify an ObjectGraph instance or name of an ObjectGraph to be used on Unmarshallers and Marshallers created by the context.
        See Also:
        Constant Field Values
      • JSON_WRAPPER_AS_ARRAY_NAME

        public static final java.lang.String JSON_WRAPPER_AS_ARRAY_NAME
        The Constant JSON_WRAPPER_AS_ARRAY_NAME. If true the grouping element will be used as the JSON key. There is no effect when media type is "application/xml". When this property is specified at the JAXBContext level all instances of Marshaller and Unmarshaller will default to this.

        Example

        Given the following class:

         @XmlAccessorType(XmlAccessType.FIELD)
         public class Customer {
        
             @XmlElementWrapper(name="phone-numbers")
             @XmlElement(name="phone-number")
             private List<PhoneNumber> phoneNumbers;
        
         }
         

        If the property is set to false (the default) the JSON output will be:

         {
             "phone-numbers" : {
                 "phone-number" : [ {
                     ...
                 }, {
                     ...
                 }]
             }
         }
         

        And if the property is set to true, then the JSON output will be:

         {
             "phone-numbers" : [ {
                 ...
             }, {
                 ...
             }]
         }
         
        See Also:
        MarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, Constant Field Values
        Since:
        2.4.2
      • JSON_TYPE_ATTRIBUTE_NAME

        public static final java.lang.String JSON_TYPE_ATTRIBUTE_NAME
        Override default type property name for JSON as MOXy type discriminator. Settings from binding file have higher priority.

        Example

        Given the following property

         conf.put(JAXBContextProperties.JSON_TYPE_ATTRIBUTE_NAME, "mytype");
         

        If the property is set the JSON output will be:

         ...
         {
              "mytype": "phone",
              "contactId": 3,
              "number": "987654321"
         }
         ...
         

        for following object model

         @XmlSeeAlso({Address.class, Phone.class})
         public class Contact {
        
              public int contactId;
              ...
         
         public class Phone extends Contact{
        
              public String number;
              ...
         

        If the property is not set (default value) the JSON output will be:

         ...
         {
              "type": "phone",
              "contactId": 3,
              "number": "987654321"
         }
         ...
         
        Unmarshaller will use it as type discriminator to select right child class.
        See Also:
        MarshallerProperties.JSON_TYPE_ATTRIBUTE_NAME, UnmarshallerProperties.JSON_TYPE_ATTRIBUTE_NAME, Constant Field Values
        Since:
        2.7.4
      • UNMARSHALLING_CASE_INSENSITIVE

        public static final java.lang.String UNMARSHALLING_CASE_INSENSITIVE
        If set to Boolean.TRUE, JAXBUnmarshaller will match XML Elements and XML Attributes to Java fields case insensitively.

        Example

        Given the following class:

         @XmlAccessorType(XmlAccessType.FIELD)
         public class Customer {
        
             @XmlElement
             private String name;
             @XmlAttribute
             private int id;
        
         }
         

        If the property is set to true, the following XML object will match the class and will be unmarshaled.

         <customer iD="007">
           <nAMe>cafeBabe</nAMe>
         </customer>
         

        By default, case-insensitive unmarshalling is turned off.

        The property must be passed to the JAXBContextFactory, when creating JAXBContext. It will affect only unmarshaller created from that context.

        Specifying this flag may impose a slight performance penalty.

        See Also:
        EclipseLink Forum, Bug 331241., UnmarshallerProperties.UNMARSHALLING_CASE_INSENSITIVE, Constant Field Values
        Since:
        2.6.0
      • BEAN_VALIDATION_FACETS

        public static final java.lang.String BEAN_VALIDATION_FACETS
        Enables or disables generation of XML Facets during schemagen process. Allowed values are Boolean.TRUE or Boolean.FALSE, effectively stating that facets (based on the BV annotations) will be generated, or that the BV annotations processing will be skipped during schemagen with no facets being generated, respectively. Default value is false, i.e. facets are not generated by default.
        See Also:
        Constant Field Values
        Since:
        2.6
      • BEAN_VALIDATION_NO_OPTIMISATION

        public static final java.lang.String BEAN_VALIDATION_NO_OPTIMISATION
        Property for disabling Bean Validation optimisations. Bean Validation in MOXy features optimisations, which are used to skip BV processes on non-constrained objects. This is to make maintenance easier and to allow for debugging in case that some object is not validated, but should be. Usage: set to Boolean.TRUE to disable optimisations, set to Boolean.FALSE to re-enable them again.
        See Also:
        MarshallerProperties.BEAN_VALIDATION_NO_OPTIMISATION, UnmarshallerProperties.BEAN_VALIDATION_NO_OPTIMISATION, Constant Field Values
        Since:
        2.6
      • MOXY_LOG_PAYLOAD

        public static final java.lang.String MOXY_LOG_PAYLOAD
        Property for logging Entities content during marshalling/unmarshalling operation in MOXy. It calls toString() method from entity. This is to make maintenance easier and to allow for debugging to check marshalled/unmarshalled content. Use it carefully. It can produce high amount of data in the log files. Usage: set to Boolean.TRUE to enable payload logging, set to Boolean.FALSE to disable it. It can be set via system property with name "eclipselink.logging.payload.moxy" too. By default it is disabled.
        See Also:
        MarshallerProperties.MOXY_LOG_PAYLOAD, UnmarshallerProperties.MOXY_LOG_PAYLOAD, Constant Field Values
        Since:
        3.0
    • Constructor Detail

      • JAXBContextProperties

        public JAXBContextProperties()