SPR-8309 - Spring OXM schema improvement for CastorMarshaller

This commit is contained in:
Arjen Poutsma
2011-06-14 13:46:32 +00:00
parent ac7d48e5a8
commit 9765fefeac
6 changed files with 159 additions and 34 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2011 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.
@@ -176,7 +176,14 @@ public class CastorMarshaller extends AbstractMarshaller implements Initializing
}
/**
* Set the package names of packages with the Castor descriptor classes.
* Set the names of package with the Castor descriptor classes.
*/
public void setTargetPackage(String targetPackage) {
this.targetPackages = new String[] {targetPackage};
}
/**
* Set the names of packages with the Castor descriptor classes.
*/
public void setTargetPackages(String[] targetPackages) {
this.targetPackages = targetPackages;

View File

@@ -0,0 +1,37 @@
/*
* Copyright 2002-2011 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.oxm.config;
import org.w3c.dom.Element;
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
/**
* Parser for the <code>&lt;oxm:castor-marshaller/&gt;</code> element.
*
* @author Jakub Narloch
* @since 3.1
*/
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;
}
}

View File

@@ -1,6 +1,6 @@
/*
* Copyright 2002-2009 the original author or authors.
*
* Copyright 2002-2011 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.
* You may obtain a copy of the License at
@@ -31,6 +31,7 @@ public class OxmNamespaceHandler extends NamespaceHandlerSupport {
registerBeanDefinitionParser("jaxb2-marshaller", new Jaxb2MarshallerBeanDefinitionParser());
registerBeanDefinitionParser("jibx-marshaller", new JibxMarshallerBeanDefinitionParser());
registerBeanDefinitionParser("xmlbeans-marshaller", new XmlBeansMarshallerBeanDefinitionParser());
registerBeanDefinitionParser("castor-marshaller", new CastorMarshallerBeanDefinitionParser());
}
}

View File

@@ -102,6 +102,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 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>