Revised spring-oxm for 4.0

Added "target-package" to the jibx-marshaller element. Also fixed "context-path" and "binding-name" to follow Spring's usual attribute naming convention.

Issue: SPR-10882
This commit is contained in:
Juergen Hoeller
2013-09-02 22:02:11 +02:00
parent b25876fd0f
commit d202573e1a
5 changed files with 77 additions and 71 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,10 +28,9 @@ import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
*/
public class CastorMarshallerBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser {
private static final String CASTOR_MARSHALLER_CLASS_NAME = "org.springframework.oxm.castor.CastorMarshaller";
@Override
protected String getBeanClassName(Element element) {
return CASTOR_MARSHALLER_CLASS_NAME;
return "org.springframework.oxm.castor.CastorMarshaller";
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
package org.springframework.oxm.config;
import java.util.Iterator;
import java.util.List;
import org.w3c.dom.Element;
@@ -36,24 +35,26 @@ import org.springframework.util.xml.DomUtils;
*/
class Jaxb2MarshallerBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
private static final String JAXB2_MARSHALLER_CLASS_NAME = "org.springframework.oxm.jaxb.Jaxb2Marshaller";
@Override
protected String getBeanClassName(Element element) {
return JAXB2_MARSHALLER_CLASS_NAME;
return "org.springframework.oxm.jaxb.Jaxb2Marshaller";
}
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) {
String contextPath = element.getAttribute("contextPath");
String contextPath = element.getAttribute("context-path");
if (!StringUtils.hasText(contextPath)) {
// Backwards compatibility with 3.x version of the xsd
contextPath = element.getAttribute("contextPath");
}
if (StringUtils.hasText(contextPath)) {
beanDefinitionBuilder.addPropertyValue("contextPath", contextPath);
}
List classes = DomUtils.getChildElementsByTagName(element, "class-to-be-bound");
List<Element> classes = DomUtils.getChildElementsByTagName(element, "class-to-be-bound");
if (!classes.isEmpty()) {
ManagedList classesToBeBound = new ManagedList(classes.size());
for (Iterator iterator = classes.iterator(); iterator.hasNext();) {
Element classToBeBound = (Element) iterator.next();
ManagedList<String> classesToBeBound = new ManagedList<String>(classes.size());
for (Element classToBeBound : classes) {
String className = classToBeBound.getAttribute("name");
classesToBeBound.add(className);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,11 +28,9 @@ import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
*/
class JibxMarshallerBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser {
private static final String JIBX_MARSHALLER_CLASS_NAME = "org.springframework.oxm.jibx.JibxMarshaller";
@Override
protected String getBeanClassName(Element element) {
return JIBX_MARSHALLER_CLASS_NAME;
return "org.springframework.oxm.jibx.JibxMarshaller";
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,11 +31,9 @@ import org.springframework.util.StringUtils;
*/
class XmlBeansMarshallerBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
public static final String XML_BEANS_MARSHALLER_CLASS_NAME = "org.springframework.oxm.xmlbeans.XmlBeansMarshaller";
@Override
protected String getBeanClassName(Element element) {
return XML_BEANS_MARSHALLER_CLASS_NAME;
return "org.springframework.oxm.xmlbeans.XmlBeansMarshaller";
}
@Override

View File

@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsd:schema xmlns="http://www.springframework.org/schema/oxm" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:tool="http://www.springframework.org/schema/tool"
targetNamespace="http://www.springframework.org/schema/oxm" elementFormDefault="qualified"
attributeFormDefault="unqualified">
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:tool="http://www.springframework.org/schema/tool"
targetNamespace="http://www.springframework.org/schema/oxm"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:import namespace="http://www.springframework.org/schema/beans" schemaLocation="http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"/>
<xsd:import namespace="http://www.springframework.org/schema/tool" schemaLocation="http://www.springframework.org/schema/tool/spring-tool-4.0.xsd"/>
@@ -35,9 +36,9 @@
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="contextPath" type="xsd:string">
<xsd:attribute name="context-path" type="xsd:string">
<xsd:annotation>
<xsd:documentation>The JAXB Context path</xsd:documentation>
<xsd:documentation>The JAXB context path.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
@@ -59,8 +60,17 @@
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="beans:identifiedType">
<xsd:attribute name="target-class" type="classType" use="required"/>
<xsd:attribute name="bindingName" type="xsd:string">
<xsd:attribute name="target-class" type="classType">
<xsd:annotation>
<xsd:documentation>The target class to be bound with JiBX.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="target-package" type="xsd:string">
<xsd:annotation>
<xsd:documentation>The target package for the JiBX binding.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="binding-name" type="xsd:string">
<xsd:annotation>
<xsd:documentation>The binding name used by this marshaller.</xsd:documentation>
</xsd:annotation>
@@ -70,6 +80,46 @@
</xsd:complexType>
</xsd:element>
<xsd:element name="castor-marshaller">
<xsd:complexType>
<xsd:annotation>
<xsd:documentation
source="java:org.springframework.oxm.castor.CastorMarshaller">
Defines a Castor Marshaller.
</xsd:documentation>
<xsd:appinfo>
<tool:annotation>
<tool:exports type="org.springframework.oxm.castor.CastorMarshaller" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="beans:identifiedType">
<xsd:attribute name="encoding" type="xsd:string">
<xsd:annotation>
<xsd:documentation>The encoding to use for stream reading.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="target-class" type="classType">
<xsd:annotation>
<xsd:documentation>The target class to be bound with the Castor marshaller.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="target-package" type="xsd:string">
<xsd:annotation>
<xsd:documentation>The target package that contains Castor descriptor classes.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="mapping-location" type="xsd:string">
<xsd:annotation>
<xsd:documentation>The path to the Castor mapping file.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="xmlbeans-marshaller">
<xsd:complexType>
<xsd:annotation>
@@ -102,53 +152,13 @@
</xsd:complexType>
</xsd:element>
<xsd:element name="castor-marshaller">
<xsd:complexType>
<xsd:annotation>
<xsd:documentation
source="java:org.springframework.oxm.castor.CastorMarshaller">
Defines a Castor Marshaller.
</xsd:documentation>
<xsd:appinfo>
<tool:annotation>
<tool:exports type="org.springframework.oxm.castor.CastorMarshaller" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="beans:identifiedType">
<xsd:attribute name="encoding" type="xsd:string">
<xsd:annotation>
<xsd:documentation>The encoding to use for stream reading.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="target-class" type="classType">
<xsd:annotation>
<xsd:documentation>The target class to be bound with Castor marshaller.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="target-package" type="xsd:string">
<xsd:annotation>
<xsd:documentation>The target package that contains Castor descriptor classes.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="mapping-location" type="xsd:string">
<xsd:annotation>
<xsd:documentation>The path to Castor mapping file.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
<xsd:simpleType name="classType">
<xsd:annotation>
<xsd:documentation source="java:java.lang.Class">A class supported by a marshaller.</xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="direct">
<tool:expected-type type="java.lang.Class"/>
<tool:assignable-to restriction="class-only" />
<tool:assignable-to restriction="class-only"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>