Browse Source

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
pull/342/merge
Juergen Hoeller 11 years ago
parent
commit
d202573e1a
  1. 7
      spring-oxm/src/main/java/org/springframework/oxm/config/CastorMarshallerBeanDefinitionParser.java
  2. 21
      spring-oxm/src/main/java/org/springframework/oxm/config/Jaxb2MarshallerBeanDefinitionParser.java
  3. 6
      spring-oxm/src/main/java/org/springframework/oxm/config/JibxMarshallerBeanDefinitionParser.java
  4. 6
      spring-oxm/src/main/java/org/springframework/oxm/config/XmlBeansMarshallerBeanDefinitionParser.java
  5. 92
      spring-oxm/src/main/resources/org/springframework/oxm/config/spring-oxm-4.0.xsd

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

@ -1,5 +1,5 @@ @@ -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; @@ -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";
}
}

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

@ -1,5 +1,5 @@ @@ -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 @@ @@ -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; @@ -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);
}

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

@ -1,5 +1,5 @@ @@ -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; @@ -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";
}
}

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

@ -1,5 +1,5 @@ @@ -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; @@ -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

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

@ -1,9 +1,10 @@ @@ -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 @@ @@ -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,42 +60,19 @@ @@ -59,42 +60,19 @@
</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 binding name used by this marshaller.</xsd:documentation>
<xsd:documentation>The target class to be bound with JiBX.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="xmlbeans-marshaller">
<xsd:complexType>
<xsd:annotation>
<xsd:documentation source="java:org.springframework.oxm.xmlbeans.XmlBeansMarshaller">
Defines a XMLBeans Marshaller.
</xsd:documentation>
<xsd:appinfo>
<tool:annotation>
<tool:exports type="org.springframework.oxm.xmlbeans.XmlBeansMarshaller"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="beans:identifiedType">
<xsd:attribute name="options" type="xsd:string">
<xsd:attribute name="target-package" type="xsd:string">
<xsd:annotation>
<xsd:documentation source="java:org.apache.xmlbeans.XmlOptions">
The bean name of the XmlOptions that is to be used for this marshaller. Typically a
XmlOptionsFactoryBean definition.
</xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.apache.xmlbeans.XmlOptions"/>
</tool:annotation>
</xsd:appinfo>
<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>
</xsd:attribute>
</xsd:extension>
@ -124,7 +102,7 @@ @@ -124,7 +102,7 @@
</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: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">
@ -134,7 +112,39 @@ @@ -134,7 +112,39 @@
</xsd:attribute>
<xsd:attribute name="mapping-location" type="xsd:string">
<xsd:annotation>
<xsd:documentation>The path to Castor mapping file.</xsd:documentation>
<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>
<xsd:documentation source="java:org.springframework.oxm.xmlbeans.XmlBeansMarshaller">
Defines a XMLBeans Marshaller.
</xsd:documentation>
<xsd:appinfo>
<tool:annotation>
<tool:exports type="org.springframework.oxm.xmlbeans.XmlBeansMarshaller"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="beans:identifiedType">
<xsd:attribute name="options" type="xsd:string">
<xsd:annotation>
<xsd:documentation source="java:org.apache.xmlbeans.XmlOptions">
The bean name of the XmlOptions that is to be used for this marshaller. Typically a
XmlOptionsFactoryBean definition.
</xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.apache.xmlbeans.XmlOptions"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
@ -148,7 +158,7 @@ @@ -148,7 +158,7 @@
<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>

Loading…
Cancel
Save