org.springframework.oxm.jaxb
Class Jaxb2Marshaller

java.lang.Object
  extended by org.springframework.oxm.jaxb.AbstractJaxbMarshaller
      extended by org.springframework.oxm.jaxb.Jaxb2Marshaller
All Implemented Interfaces:
org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.InitializingBean, GenericMarshaller, GenericUnmarshaller, org.springframework.oxm.Marshaller, org.springframework.oxm.mime.MimeMarshaller, org.springframework.oxm.mime.MimeUnmarshaller, org.springframework.oxm.Unmarshaller

public class Jaxb2Marshaller
extends org.springframework.oxm.jaxb.AbstractJaxbMarshaller
implements org.springframework.oxm.mime.MimeMarshaller, org.springframework.oxm.mime.MimeUnmarshaller, GenericMarshaller, GenericUnmarshaller, org.springframework.beans.factory.BeanClassLoaderAware

Implementation of the Marshaller interface for JAXB 2.0.

The typical usage will be to set either the contextPath or the classesToBeBound property on this bean, possibly customize the marshaller and unmarshaller by setting properties, schemas, adapters, and listeners, and to refer to it.

Since:
1.0.0
Author:
Arjen Poutsma
See Also:
AbstractJaxbMarshaller.setContextPath(String), setClassesToBeBound(Class[]), setJaxbContextProperties(java.util.Map), AbstractJaxbMarshaller.setMarshallerProperties(java.util.Map), AbstractJaxbMarshaller.setUnmarshallerProperties(java.util.Map), setSchema(org.springframework.core.io.Resource), setSchemas(org.springframework.core.io.Resource[]), setMarshallerListener(javax.xml.bind.Marshaller.Listener), setUnmarshallerListener(javax.xml.bind.Unmarshaller.Listener), setAdapters(javax.xml.bind.annotation.adapters.XmlAdapter[])

Field Summary
 
Fields inherited from class org.springframework.oxm.jaxb.AbstractJaxbMarshaller
logger
 
Constructor Summary
Jaxb2Marshaller()
           
 
Method Summary
protected  javax.xml.bind.JAXBContext createJaxbContext()
           
protected  void initJaxbMarshaller(javax.xml.bind.Marshaller marshaller)
           
protected  void initJaxbUnmarshaller(javax.xml.bind.Unmarshaller unmarshaller)
           
 void marshal(java.lang.Object graph, javax.xml.transform.Result result)
           
 void marshal(java.lang.Object graph, javax.xml.transform.Result result, org.springframework.oxm.mime.MimeContainer mimeContainer)
           
 void setAdapters(javax.xml.bind.annotation.adapters.XmlAdapter[] adapters)
          Sets the XmlAdapters to be registered with the JAXB Marshaller and Unmarshaller
 void setBeanClassLoader(java.lang.ClassLoader classLoader)
           
 void setClassesToBeBound(java.lang.Class[] classesToBeBound)
          Sets the list of java classes to be recognized by a newly created JAXBContext.
 void setJaxbContextProperties(java.util.Map<java.lang.String,?> jaxbContextProperties)
          Sets the JAXBContext properties.
 void setMarshallerListener(javax.xml.bind.Marshaller.Listener marshallerListener)
          Sets the Marshaller.Listener to be registered with the JAXB Marshaller.
 void setMtomEnabled(boolean mtomEnabled)
          Indicates whether MTOM support should be enabled or not.
 void setSchema(org.springframework.core.io.Resource schemaResource)
          Sets the schema resource to use for validation.
 void setSchemaLanguage(java.lang.String schemaLanguage)
          Sets the schema language.
 void setSchemas(org.springframework.core.io.Resource[] schemaResources)
          Sets the schema resources to use for validation.
 void setUnmarshallerListener(javax.xml.bind.Unmarshaller.Listener unmarshallerListener)
          Sets the Unmarshaller.Listener to be registered with the JAXB Unmarshaller.
 boolean supports(java.lang.Class clazz)
           
 boolean supports(java.lang.reflect.Type type)
          Indicates whether this marshaller can marshal instances of the supplied type.
 java.lang.Object unmarshal(javax.xml.transform.Source source)
           
 java.lang.Object unmarshal(javax.xml.transform.Source source, org.springframework.oxm.mime.MimeContainer mimeContainer)
           
 
Methods inherited from class org.springframework.oxm.jaxb.AbstractJaxbMarshaller
afterPropertiesSet, convertJaxbException, createMarshaller, createUnmarshaller, getContextPath, getJaxbContext, setContextPath, setContextPaths, setMarshallerProperties, setUnmarshallerProperties, setValidationEventHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Jaxb2Marshaller

public Jaxb2Marshaller()
Method Detail

setBeanClassLoader

public void setBeanClassLoader(java.lang.ClassLoader classLoader)
Specified by:
setBeanClassLoader in interface org.springframework.beans.factory.BeanClassLoaderAware

setAdapters

public void setAdapters(javax.xml.bind.annotation.adapters.XmlAdapter[] adapters)
Sets the XmlAdapters to be registered with the JAXB Marshaller and Unmarshaller


setClassesToBeBound

public void setClassesToBeBound(java.lang.Class[] classesToBeBound)
Sets the list of java classes to be recognized by a newly created JAXBContext. Setting this property or contextPath is required.

See Also:
AbstractJaxbMarshaller.setContextPath(String)

setJaxbContextProperties

public void setJaxbContextProperties(java.util.Map<java.lang.String,?> jaxbContextProperties)
Sets the JAXBContext properties. These implementation-specific properties will be set on the JAXBContext.


setMarshallerListener

public void setMarshallerListener(javax.xml.bind.Marshaller.Listener marshallerListener)
Sets the Marshaller.Listener to be registered with the JAXB Marshaller.


setMtomEnabled

public void setMtomEnabled(boolean mtomEnabled)
Indicates whether MTOM support should be enabled or not. Default is false, marshalling using XOP/MTOM is not enabled.


setSchemaLanguage

public void setSchemaLanguage(java.lang.String schemaLanguage)
Sets the schema language. Default is the W3C XML Schema: http://www.w3.org/2001/XMLSchema".

See Also:
XMLConstants.W3C_XML_SCHEMA_NS_URI, XMLConstants.RELAXNG_NS_URI

setSchema

public void setSchema(org.springframework.core.io.Resource schemaResource)
Sets the schema resource to use for validation.


setSchemas

public void setSchemas(org.springframework.core.io.Resource[] schemaResources)
Sets the schema resources to use for validation.


setUnmarshallerListener

public void setUnmarshallerListener(javax.xml.bind.Unmarshaller.Listener unmarshallerListener)
Sets the Unmarshaller.Listener to be registered with the JAXB Unmarshaller.


supports

public boolean supports(java.lang.reflect.Type type)
Description copied from interface: GenericMarshaller
Indicates whether this marshaller can marshal instances of the supplied type.

Specified by:
supports in interface GenericMarshaller
Specified by:
supports in interface GenericUnmarshaller
Parameters:
type - the type that this marshaller is being asked if it can marshal
Returns:
true if this marshaller can indeed marshal instances of the supplied type; false otherwise

supports

public boolean supports(java.lang.Class clazz)
Specified by:
supports in interface org.springframework.oxm.Marshaller
Specified by:
supports in interface org.springframework.oxm.Unmarshaller

createJaxbContext

protected javax.xml.bind.JAXBContext createJaxbContext()
                                                throws java.lang.Exception
Specified by:
createJaxbContext in class org.springframework.oxm.jaxb.AbstractJaxbMarshaller
Throws:
java.lang.Exception

initJaxbMarshaller

protected void initJaxbMarshaller(javax.xml.bind.Marshaller marshaller)
                           throws javax.xml.bind.JAXBException
Overrides:
initJaxbMarshaller in class org.springframework.oxm.jaxb.AbstractJaxbMarshaller
Throws:
javax.xml.bind.JAXBException

initJaxbUnmarshaller

protected void initJaxbUnmarshaller(javax.xml.bind.Unmarshaller unmarshaller)
                             throws javax.xml.bind.JAXBException
Overrides:
initJaxbUnmarshaller in class org.springframework.oxm.jaxb.AbstractJaxbMarshaller
Throws:
javax.xml.bind.JAXBException

marshal

public void marshal(java.lang.Object graph,
                    javax.xml.transform.Result result)
             throws org.springframework.oxm.XmlMappingException
Specified by:
marshal in interface org.springframework.oxm.Marshaller
Throws:
org.springframework.oxm.XmlMappingException

marshal

public void marshal(java.lang.Object graph,
                    javax.xml.transform.Result result,
                    org.springframework.oxm.mime.MimeContainer mimeContainer)
             throws org.springframework.oxm.XmlMappingException
Specified by:
marshal in interface org.springframework.oxm.mime.MimeMarshaller
Throws:
org.springframework.oxm.XmlMappingException

unmarshal

public java.lang.Object unmarshal(javax.xml.transform.Source source)
                           throws org.springframework.oxm.XmlMappingException
Specified by:
unmarshal in interface org.springframework.oxm.Unmarshaller
Throws:
org.springframework.oxm.XmlMappingException

unmarshal

public java.lang.Object unmarshal(javax.xml.transform.Source source,
                                  org.springframework.oxm.mime.MimeContainer mimeContainer)
                           throws org.springframework.oxm.XmlMappingException
Specified by:
unmarshal in interface org.springframework.oxm.mime.MimeUnmarshaller
Throws:
org.springframework.oxm.XmlMappingException


Copyright © 2008. All Rights Reserved.