Introduced @Configuration support for Spring-WS

Introduced support for Java @Configuration classes in the form of the
@EnableWS annotation, WsConfigurationSupport and WsConfigurer.
Overall solution is quite similar to Spring-MVC's @EnableMvc.

Also added/uopdated reference documentation for the various
@Configuration options.

Issue: SWS-836
This commit is contained in:
Arjen Poutsma
2014-01-30 14:24:01 +01:00
parent 3522effaea
commit 160907a6e1
21 changed files with 1314 additions and 94 deletions

View File

@@ -24,6 +24,10 @@ import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.io.Resource;
import org.springframework.util.Assert;
@@ -32,10 +36,6 @@ import org.springframework.xml.sax.SaxUtils;
import org.springframework.xml.validation.XmlValidator;
import org.springframework.xml.validation.XmlValidatorFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
/**
* The default {@link XsdSchema} implementation.
* <p/>
@@ -98,8 +98,13 @@ public class SimpleXsdSchema implements XsdSchema, InitializingBean {
return new DOMSource(schemaElement);
}
public XmlValidator createValidator() throws IOException {
return XmlValidatorFactory.createValidator(xsdResource, XmlValidatorFactory.SCHEMA_W3C_XML);
public XmlValidator createValidator() {
try {
return XmlValidatorFactory.createValidator(xsdResource, XmlValidatorFactory.SCHEMA_W3C_XML);
}
catch (IOException ex) {
throw new XsdSchemaException(ex.getMessage(), ex);
}
}
public void afterPropertiesSet() throws ParserConfigurationException, IOException, SAXException {

View File

@@ -16,7 +16,6 @@
package org.springframework.xml.xsd;
import java.io.IOException;
import javax.xml.transform.Source;
import org.springframework.xml.validation.XmlValidator;
@@ -48,7 +47,6 @@ public interface XsdSchema {
* Creates a {@link XmlValidator} based on the schema.
*
* @return a validator for this schema
* @throws IOException in case of I/O errors
*/
XmlValidator createValidator() throws IOException;
XmlValidator createValidator();
}

View File

@@ -16,8 +16,6 @@
package org.springframework.xml.xsd;
import java.io.IOException;
import org.springframework.xml.validation.XmlValidator;
/**
@@ -39,8 +37,7 @@ public interface XsdSchemaCollection {
* Creates a {@link XmlValidator} based on the schemas contained in this collection.
*
* @return a validator for this collection
* @throws IOException in case of I/O errors
*/
XmlValidator createValidator() throws IOException;
XmlValidator createValidator();
}

View File

@@ -27,6 +27,11 @@ import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamSource;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.XmlSchemaSerializer;
import org.w3c.dom.Document;
import org.springframework.beans.BeanInstantiationException;
import org.springframework.beans.BeanUtils;
import org.springframework.core.io.Resource;
@@ -36,11 +41,6 @@ import org.springframework.xml.validation.XmlValidator;
import org.springframework.xml.validation.XmlValidatorFactory;
import org.springframework.xml.xsd.XsdSchema;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.XmlSchemaSerializer;
import org.w3c.dom.Document;
/**
* Implementation of the {@link XsdSchema} interface that uses Apache WS-Commons XML Schema.
*
@@ -114,12 +114,18 @@ public class CommonsXsdSchema implements XsdSchema {
return new StreamSource(bis);
}
public XmlValidator createValidator() throws IOException {
Resource resource = new UrlResource(schema.getSourceURI());
return XmlValidatorFactory.createValidator(resource, XmlValidatorFactory.SCHEMA_W3C_XML);
public XmlValidator createValidator() {
try {
Resource resource = new UrlResource(schema.getSourceURI());
return XmlValidatorFactory
.createValidator(resource, XmlValidatorFactory.SCHEMA_W3C_XML);
}
catch (IOException ex) {
throw new CommonsXsdSchemaException(ex.getMessage(), ex);
}
}
/** Returns the wrapped Commons <code>XmlSchema</code> object. */
/** Returns the wrapped Commons <code>XmlSchema</code> object. */
public XmlSchema getSchema() {
return schema;
}

View File

@@ -22,6 +22,18 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.XmlSchemaExternal;
import org.apache.ws.commons.schema.XmlSchemaImport;
import org.apache.ws.commons.schema.XmlSchemaInclude;
import org.apache.ws.commons.schema.XmlSchemaObject;
import org.apache.ws.commons.schema.resolver.DefaultURIResolver;
import org.apache.ws.commons.schema.resolver.URIResolver;
import org.xml.sax.InputSource;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.io.Resource;
@@ -35,18 +47,6 @@ import org.springframework.xml.validation.XmlValidatorFactory;
import org.springframework.xml.xsd.XsdSchema;
import org.springframework.xml.xsd.XsdSchemaCollection;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.XmlSchemaExternal;
import org.apache.ws.commons.schema.XmlSchemaImport;
import org.apache.ws.commons.schema.XmlSchemaInclude;
import org.apache.ws.commons.schema.XmlSchemaObject;
import org.apache.ws.commons.schema.resolver.DefaultURIResolver;
import org.apache.ws.commons.schema.resolver.URIResolver;
import org.xml.sax.InputSource;
/**
* Implementation of the {@link XsdSchemaCollection} that uses Apache WS-Commons XML Schema.
* <p/>
@@ -162,16 +162,21 @@ public class CommonsXsdSchemaCollection implements XsdSchemaCollection, Initiali
return result;
}
public XmlValidator createValidator() throws IOException {
Resource[] resources = new Resource[xmlSchemas.size()];
for (int i = xmlSchemas.size() - 1; i >= 0; i--) {
XmlSchema xmlSchema = xmlSchemas.get(i);
String sourceUri = xmlSchema.getSourceURI();
if (StringUtils.hasLength(sourceUri)) {
resources[i] = new UrlResource(sourceUri);
}
}
return XmlValidatorFactory.createValidator(resources, XmlValidatorFactory.SCHEMA_W3C_XML);
public XmlValidator createValidator() {
try {
Resource[] resources = new Resource[xmlSchemas.size()];
for (int i = xmlSchemas.size() - 1; i >= 0; i--) {
XmlSchema xmlSchema = xmlSchemas.get(i);
String sourceUri = xmlSchema.getSourceURI();
if (StringUtils.hasLength(sourceUri)) {
resources[i] = new UrlResource(sourceUri);
}
}
return XmlValidatorFactory
.createValidator(resources, XmlValidatorFactory.SCHEMA_W3C_XML);
} catch (IOException ex) {
throw new CommonsXsdSchemaException(ex.getMessage(), ex);
}
}
private void inlineIncludes(XmlSchema schema, Set<XmlSchema> processedIncludes, Set<XmlSchema> processedImports) {