/** * Convert the given <code>JAXBException</code> to an appropriate exception from the * <code>org.springframework.oxm</code> hierarchy. * <p/> * The default implementation delegates to <code>JaxbUtils</code>. Can be overridden in subclasses. * * @param ex <code>JAXBException</code> that occured * @return the corresponding <code>XmlMappingException</code> instance * @see JaxbUtils#convertJaxbException */ protected XmlMappingException convertJaxbException(JAXBException ex) { return JaxbUtils.convertJaxbException(ex); }
@Override protected JAXBContext createJaxbContext() throws Exception { if (JaxbUtils.getJaxbVersion(classLoader) < JaxbUtils.JAXB_2) { throw new IllegalStateException( "Cannot use Jaxb2Marshaller in combination with JAXB 1.0. Use Jaxb1Marshaller instead."); } if (StringUtils.hasLength(getContextPath()) && !ObjectUtils.isEmpty(classesToBeBound)) { throw new IllegalArgumentException("specify either contextPath or classesToBeBound property; not both"); } if (!ObjectUtils.isEmpty(schemaResources)) { if (logger.isDebugEnabled()) { logger.debug( "Setting validation schema to " + StringUtils.arrayToCommaDelimitedString(schemaResources)); } schema = SchemaLoaderUtils.loadSchema(schemaResources, schemaLanguage); } if (StringUtils.hasLength(getContextPath())) { return createJaxbContextFromContextPath(); } else if (!ObjectUtils.isEmpty(classesToBeBound)) { return createJaxbContextFromClasses(); } else { throw new IllegalArgumentException("setting either contextPath or classesToBeBound is required"); } }