List of usage examples for org.springframework.oxm.jaxb Jaxb2Marshaller setValidationEventHandler
public void setValidationEventHandler(ValidationEventHandler validationEventHandler)
From source file:com.neiljbrown.brighttalk.channels.reportingapi.client.spring.AppConfig.java
/** * Creates and configures a {@link Marshaller} to be used for both marshalling and unmarshalling HTTP request and * response bodies./* w w w . j av a2 s. c om*/ * <p> * The created Marshaller is configured with a custom JAXB {@link javax.xml.bind.ValidationEventHandler} which * supports logging not fatal validation errors that occur on unmarshalling, and optionally classifying them as fatal * errors depending on the class of causal ('linked') exception. * * @return The created {@link Marshaller}. */ @Bean public Marshaller marshaller() { Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller(); CustomValidationEventHandler eventHandler = new CustomValidationEventHandler(); eventHandler.setFatalLinkedExceptions(this.marshallingErrorFatalExceptions); jaxb2Marshaller.setValidationEventHandler(eventHandler); Package apiResourcesRootPackage = ChannelResource.class.getPackage(); jaxb2Marshaller.setPackagesToScan(new String[] { apiResourcesRootPackage.getName() }); return jaxb2Marshaller; }