Skip to content

Commit d202573

Browse files
committed
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
1 parent b25876f commit d202573

File tree

5 files changed

+69
-63
lines changed

5 files changed

+69
-63
lines changed

spring-oxm/src/main/java/org/springframework/oxm/config/CastorMarshallerBeanDefinitionParser.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,10 +28,9 @@
2828
*/
2929
public class CastorMarshallerBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser {
3030

31-
private static final String CASTOR_MARSHALLER_CLASS_NAME = "org.springframework.oxm.castor.CastorMarshaller";
32-
3331
@Override
3432
protected String getBeanClassName(Element element) {
35-
return CASTOR_MARSHALLER_CLASS_NAME;
33+
return "org.springframework.oxm.castor.CastorMarshaller";
3634
}
35+
3736
}

spring-oxm/src/main/java/org/springframework/oxm/config/Jaxb2MarshallerBeanDefinitionParser.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.oxm.config;
1818

19-
import java.util.Iterator;
2019
import java.util.List;
2120

2221
import org.w3c.dom.Element;
@@ -36,24 +35,26 @@
3635
*/
3736
class Jaxb2MarshallerBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
3837

39-
private static final String JAXB2_MARSHALLER_CLASS_NAME = "org.springframework.oxm.jaxb.Jaxb2Marshaller";
40-
4138
@Override
4239
protected String getBeanClassName(Element element) {
43-
return JAXB2_MARSHALLER_CLASS_NAME;
40+
return "org.springframework.oxm.jaxb.Jaxb2Marshaller";
4441
}
4542

4643
@Override
4744
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) {
48-
String contextPath = element.getAttribute("contextPath");
45+
String contextPath = element.getAttribute("context-path");
46+
if (!StringUtils.hasText(contextPath)) {
47+
// Backwards compatibility with 3.x version of the xsd
48+
contextPath = element.getAttribute("contextPath");
49+
}
4950
if (StringUtils.hasText(contextPath)) {
5051
beanDefinitionBuilder.addPropertyValue("contextPath", contextPath);
5152
}
52-
List classes = DomUtils.getChildElementsByTagName(element, "class-to-be-bound");
53+
54+
List<Element> classes = DomUtils.getChildElementsByTagName(element, "class-to-be-bound");
5355
if (!classes.isEmpty()) {
54-
ManagedList classesToBeBound = new ManagedList(classes.size());
55-
for (Iterator iterator = classes.iterator(); iterator.hasNext();) {
56-
Element classToBeBound = (Element) iterator.next();
56+
ManagedList<String> classesToBeBound = new ManagedList<String>(classes.size());
57+
for (Element classToBeBound : classes) {
5758
String className = classToBeBound.getAttribute("name");
5859
classesToBeBound.add(className);
5960
}

spring-oxm/src/main/java/org/springframework/oxm/config/JibxMarshallerBeanDefinitionParser.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,11 +28,9 @@
2828
*/
2929
class JibxMarshallerBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser {
3030

31-
private static final String JIBX_MARSHALLER_CLASS_NAME = "org.springframework.oxm.jibx.JibxMarshaller";
32-
3331
@Override
3432
protected String getBeanClassName(Element element) {
35-
return JIBX_MARSHALLER_CLASS_NAME;
33+
return "org.springframework.oxm.jibx.JibxMarshaller";
3634
}
3735

3836
}

spring-oxm/src/main/java/org/springframework/oxm/config/XmlBeansMarshallerBeanDefinitionParser.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,11 +31,9 @@
3131
*/
3232
class XmlBeansMarshallerBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
3333

34-
public static final String XML_BEANS_MARSHALLER_CLASS_NAME = "org.springframework.oxm.xmlbeans.XmlBeansMarshaller";
35-
3634
@Override
3735
protected String getBeanClassName(Element element) {
38-
return XML_BEANS_MARSHALLER_CLASS_NAME;
36+
return "org.springframework.oxm.xmlbeans.XmlBeansMarshaller";
3937
}
4038

4139
@Override

spring-oxm/src/main/resources/org/springframework/oxm/config/spring-oxm-4.0.xsd

Lines changed: 51 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<xsd:schema xmlns="http://www.springframework.org/schema/oxm" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
3-
xmlns:beans="http://www.springframework.org/schema/beans"
4-
xmlns:tool="http://www.springframework.org/schema/tool"
5-
targetNamespace="http://www.springframework.org/schema/oxm" elementFormDefault="qualified"
6-
attributeFormDefault="unqualified">
3+
xmlns:beans="http://www.springframework.org/schema/beans"
4+
xmlns:tool="http://www.springframework.org/schema/tool"
5+
targetNamespace="http://www.springframework.org/schema/oxm"
6+
elementFormDefault="qualified"
7+
attributeFormDefault="unqualified">
78

89
<xsd:import namespace="http://www.springframework.org/schema/beans" schemaLocation="http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"/>
910
<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 @@
3536
</xsd:complexType>
3637
</xsd:element>
3738
</xsd:sequence>
38-
<xsd:attribute name="contextPath" type="xsd:string">
39+
<xsd:attribute name="context-path" type="xsd:string">
3940
<xsd:annotation>
40-
<xsd:documentation>The JAXB Context path</xsd:documentation>
41+
<xsd:documentation>The JAXB context path.</xsd:documentation>
4142
</xsd:annotation>
4243
</xsd:attribute>
4344
</xsd:extension>
@@ -59,42 +60,19 @@
5960
</xsd:annotation>
6061
<xsd:complexContent>
6162
<xsd:extension base="beans:identifiedType">
62-
<xsd:attribute name="target-class" type="classType" use="required"/>
63-
<xsd:attribute name="bindingName" type="xsd:string">
63+
<xsd:attribute name="target-class" type="classType">
6464
<xsd:annotation>
65-
<xsd:documentation>The binding name used by this marshaller.</xsd:documentation>
65+
<xsd:documentation>The target class to be bound with JiBX.</xsd:documentation>
6666
</xsd:annotation>
6767
</xsd:attribute>
68-
</xsd:extension>
69-
</xsd:complexContent>
70-
</xsd:complexType>
71-
</xsd:element>
72-
73-
<xsd:element name="xmlbeans-marshaller">
74-
<xsd:complexType>
75-
<xsd:annotation>
76-
<xsd:documentation source="java:org.springframework.oxm.xmlbeans.XmlBeansMarshaller">
77-
Defines a XMLBeans Marshaller.
78-
</xsd:documentation>
79-
<xsd:appinfo>
80-
<tool:annotation>
81-
<tool:exports type="org.springframework.oxm.xmlbeans.XmlBeansMarshaller"/>
82-
</tool:annotation>
83-
</xsd:appinfo>
84-
</xsd:annotation>
85-
<xsd:complexContent>
86-
<xsd:extension base="beans:identifiedType">
87-
<xsd:attribute name="options" type="xsd:string">
68+
<xsd:attribute name="target-package" type="xsd:string">
8869
<xsd:annotation>
89-
<xsd:documentation source="java:org.apache.xmlbeans.XmlOptions">
90-
The bean name of the XmlOptions that is to be used for this marshaller. Typically a
91-
XmlOptionsFactoryBean definition.
92-
</xsd:documentation>
93-
<xsd:appinfo>
94-
<tool:annotation kind="ref">
95-
<tool:expected-type type="org.apache.xmlbeans.XmlOptions"/>
96-
</tool:annotation>
97-
</xsd:appinfo>
70+
<xsd:documentation>The target package for the JiBX binding.</xsd:documentation>
71+
</xsd:annotation>
72+
</xsd:attribute>
73+
<xsd:attribute name="binding-name" type="xsd:string">
74+
<xsd:annotation>
75+
<xsd:documentation>The binding name used by this marshaller.</xsd:documentation>
9876
</xsd:annotation>
9977
</xsd:attribute>
10078
</xsd:extension>
@@ -124,7 +102,7 @@
124102
</xsd:attribute>
125103
<xsd:attribute name="target-class" type="classType">
126104
<xsd:annotation>
127-
<xsd:documentation>The target class to be bound with Castor marshaller.</xsd:documentation>
105+
<xsd:documentation>The target class to be bound with the Castor marshaller.</xsd:documentation>
128106
</xsd:annotation>
129107
</xsd:attribute>
130108
<xsd:attribute name="target-package" type="xsd:string">
@@ -134,7 +112,39 @@
134112
</xsd:attribute>
135113
<xsd:attribute name="mapping-location" type="xsd:string">
136114
<xsd:annotation>
137-
<xsd:documentation>The path to Castor mapping file.</xsd:documentation>
115+
<xsd:documentation>The path to the Castor mapping file.</xsd:documentation>
116+
</xsd:annotation>
117+
</xsd:attribute>
118+
</xsd:extension>
119+
</xsd:complexContent>
120+
</xsd:complexType>
121+
</xsd:element>
122+
123+
<xsd:element name="xmlbeans-marshaller">
124+
<xsd:complexType>
125+
<xsd:annotation>
126+
<xsd:documentation source="java:org.springframework.oxm.xmlbeans.XmlBeansMarshaller">
127+
Defines a XMLBeans Marshaller.
128+
</xsd:documentation>
129+
<xsd:appinfo>
130+
<tool:annotation>
131+
<tool:exports type="org.springframework.oxm.xmlbeans.XmlBeansMarshaller"/>
132+
</tool:annotation>
133+
</xsd:appinfo>
134+
</xsd:annotation>
135+
<xsd:complexContent>
136+
<xsd:extension base="beans:identifiedType">
137+
<xsd:attribute name="options" type="xsd:string">
138+
<xsd:annotation>
139+
<xsd:documentation source="java:org.apache.xmlbeans.XmlOptions">
140+
The bean name of the XmlOptions that is to be used for this marshaller. Typically a
141+
XmlOptionsFactoryBean definition.
142+
</xsd:documentation>
143+
<xsd:appinfo>
144+
<tool:annotation kind="ref">
145+
<tool:expected-type type="org.apache.xmlbeans.XmlOptions"/>
146+
</tool:annotation>
147+
</xsd:appinfo>
138148
</xsd:annotation>
139149
</xsd:attribute>
140150
</xsd:extension>
@@ -148,7 +158,7 @@
148158
<xsd:appinfo>
149159
<tool:annotation kind="direct">
150160
<tool:expected-type type="java.lang.Class"/>
151-
<tool:assignable-to restriction="class-only" />
161+
<tool:assignable-to restriction="class-only"/>
152162
</tool:annotation>
153163
</xsd:appinfo>
154164
</xsd:annotation>

0 commit comments

Comments
 (0)