类 Jaxb2Marshaller

    • 字段详细资料

      • logger

        protected final Log logger
        Logger available to subclasses
    • 方法详细资料

      • setContextPaths

        public void setContextPaths​(String... contextPaths)
        Set multiple JAXB context paths. The given array of context paths gets converted to a colon-delimited string, as supported by JAXB.
      • getClassesToBeBound

        public Class<?>[] getClassesToBeBound()
        Return the list of Java classes to be recognized by a newly created JAXBContext.
      • setJaxbContextProperties

        public void setJaxbContextProperties​(Map<String,​?> jaxbContextProperties)
        Set the JAXBContext properties. These implementation-specific properties will be set on the underlying JAXBContext.
      • setMarshallerProperties

        public void setMarshallerProperties​(Map<String,​?> properties)
        Set the JAXB Marshaller properties.

        These properties will be set on the underlying JAXB Marshaller, and allow for features such as indentation.

        参数:
        properties - the properties
        另请参阅:
        javax.xml.bind.Marshaller#setProperty(String, Object), javax.xml.bind.Marshaller#JAXB_ENCODING, javax.xml.bind.Marshaller#JAXB_FORMATTED_OUTPUT, javax.xml.bind.Marshaller#JAXB_NO_NAMESPACE_SCHEMA_LOCATION, javax.xml.bind.Marshaller#JAXB_SCHEMA_LOCATION
      • setUnmarshallerProperties

        public void setUnmarshallerProperties​(Map<String,​?> properties)
        Set the JAXB Unmarshaller properties.

        These properties will be set on the underlying JAXB Unmarshaller.

        参数:
        properties - the properties
        另请参阅:
        javax.xml.bind.Unmarshaller#setProperty(String, Object)
      • setMarshallerListener

        public void setMarshallerListener​(Marshaller.Listener marshallerListener)
        Specify the Marshaller.Listener to be registered with the JAXB Marshaller.
      • setUnmarshallerListener

        public void setUnmarshallerListener​(Unmarshaller.Listener unmarshallerListener)
        Set the Unmarshaller.Listener to be registered with the JAXB Unmarshaller.
      • setValidationEventHandler

        public void setValidationEventHandler​(ValidationEventHandler validationEventHandler)
        Set the JAXB validation event handler. This event handler will be called by JAXB if any validation errors are encountered during calls to any of the marshal APIs.
      • setAdapters

        public void setAdapters​(<any>... adapters)
        Specify the XmlAdapters to be registered with the JAXB Marshaller and Unmarshaller.
      • setSchema

        public void setSchema​(Resource schemaResource)
        Set the schema resource to use for validation.
      • setSchemas

        public void setSchemas​(Resource... schemaResources)
        Set the schema resources to use for validation.
      • setLazyInit

        public void setLazyInit​(boolean lazyInit)
        Set whether to lazily initialize the JAXBContext for this marshaller. Default is false to initialize on startup; can be switched to true.

        Early initialization just applies if afterPropertiesSet() is called.

      • setMtomEnabled

        public void setMtomEnabled​(boolean mtomEnabled)
        Specify whether MTOM support should be enabled or not. Default is false: marshalling using XOP/MTOM not being enabled.
      • setSupportJaxbElementClass

        public void setSupportJaxbElementClass​(boolean supportJaxbElementClass)
        Specify whether the supports(Class) returns true for the JAXBElement class.

        Default is false, meaning that supports(Class) always returns false for JAXBElement classes (though supports(Type) can return true, since it can obtain the type parameters of JAXBElement).

        This property is typically enabled in combination with usage of classes like MarshallingView, since the ModelAndView does not offer type parameter information at runtime.

        另请参阅:
        supports(Class), supports(Type)
      • setCheckForXmlRootElement

        public void setCheckForXmlRootElement​(boolean checkForXmlRootElement)
        Specify whether the supports(Class) should check for @XmlRootElement annotations.

        Default is true, meaning that supports(Class) will check for this annotation. However, some JAXB implementations (i.e. EclipseLink MOXy) allow for defining the bindings in an external definition file, thus keeping the classes annotations free. Setting this property to false supports these JAXB implementations.

        另请参阅:
        supports(Class), supports(Type)
      • setMappedClass

        public void setMappedClass​(Class<?> mappedClass)
        Specify a JAXB mapped class for partial unmarshalling.
        另请参阅:
        javax.xml.bind.Unmarshaller#unmarshal(javax.xml.transform.Source, Class)
      • setSupportDtd

        public void setSupportDtd​(boolean supportDtd)
        Indicate whether DTD parsing should be supported.

        Default is false meaning that DTD is disabled.

      • isSupportDtd

        public boolean isSupportDtd()
        Return whether DTD parsing is supported.
      • setProcessExternalEntities

        public void setProcessExternalEntities​(boolean processExternalEntities)
        Indicate whether external XML entities are processed when unmarshalling.

        Default is false, meaning that external entities are not resolved. Note that processing of external entities will only be enabled/disabled when the Source passed to unmarshal(Source) is a SAXSource or StreamSource. It has no effect for DOMSource or StAXSource instances.

        Note: setting this option to true also automatically sets setSupportDtd(boolean) to true.

      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws Exception
        从接口复制的说明: InitializingBean
        Invoked by the containing BeanFactory after it has set all bean properties and satisfied BeanFactoryAware, ApplicationContextAware etc.

        This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.

        指定者:
        afterPropertiesSet 在接口中 InitializingBean
        抛出:
        Exception - in the event of misconfiguration (such as failure to set an essential property) or if initialization fails for any other reason
      • getJaxbContext

        public JAXBContext getJaxbContext()
        Return the JAXBContext used by this marshaller, lazily building it if necessary.
      • supports

        public boolean supports​(Class<?> clazz)
        从接口复制的说明: Marshaller
        Indicate whether this marshaller can marshal instances of the supplied type.
        指定者:
        supports 在接口中 Marshaller
        指定者:
        supports 在接口中 Unmarshaller
        参数:
        clazz - the class that this marshaller is being asked if it can marshal
        返回:
        true if this marshaller can indeed marshal instances of the supplied class; false otherwise
      • supports

        public boolean supports​(Type genericType)
        从接口复制的说明: GenericMarshaller
        Indicates whether this marshaller can marshal instances of the supplied generic type.
        指定者:
        supports 在接口中 GenericMarshaller
        指定者:
        supports 在接口中 GenericUnmarshaller
        参数:
        genericType - the type that this marshaller is being asked if it can marshal
        返回:
        true if this marshaller can indeed marshal instances of the supplied type; false otherwise
      • createMarshaller

        protected Marshaller createMarshaller()
        Return a newly created JAXB marshaller.

        Note: JAXB marshallers are not necessarily thread-safe.

      • initJaxbMarshaller

        protected void initJaxbMarshaller​(Marshaller marshaller)
                                   throws JAXBException
        Template method that can be overridden by concrete JAXB marshallers for custom initialization behavior. Gets called after creation of JAXB Marshaller, and after the respective properties have been set.

        The default implementation sets the defined properties, the validation event handler, the schemas, listener, and adapters.

        抛出:
        JAXBException
      • createUnmarshaller

        protected Unmarshaller createUnmarshaller()
        Return a newly created JAXB unmarshaller.

        Note: JAXB unmarshallers are not necessarily thread-safe.

      • initJaxbUnmarshaller

        protected void initJaxbUnmarshaller​(Unmarshaller unmarshaller)
                                     throws JAXBException
        Template method that can be overridden by concrete JAXB marshallers for custom initialization behavior. Gets called after creation of JAXB Marshaller, and after the respective properties have been set.

        The default implementation sets the defined properties, the validation event handler, the schemas, listener, and adapters.

        抛出:
        JAXBException
      • convertJaxbException

        protected XmlMappingException convertJaxbException​(JAXBException ex)
        Convert the given JAXBException to an appropriate exception from the org.springframework.oxm hierarchy.
        参数:
        ex - JAXBException that occurred
        返回:
        the corresponding XmlMappingException