Polish "Add support for Spring WS auto WSDL/XSD exposure"

Closes gh-9635
This commit is contained in:
Stephane Nicoll 2017-09-25 15:20:55 +02:00
parent bb72a4abe1
commit 15de6531a5
2 changed files with 24 additions and 19 deletions

View File

@ -106,6 +106,11 @@ public class WebServicesAutoConfiguration {
private ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
@Override
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry)
throws BeansException {
@ -125,33 +130,29 @@ public class WebServicesAutoConfiguration {
throws BeansException {
}
@Override
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
this.applicationContext = applicationContext;
}
private void registerBeans(String location, String pattern, Class<?> type,
BeanDefinitionRegistry registry) {
Resource[] resources = new Resource[] {};
try {
resources = this.applicationContext
.getResources(ensureTrailingSlash(location) + pattern);
}
catch (IOException ignored) {
}
for (Resource resource : resources) {
for (Resource resource : getResources(location, pattern)) {
RootBeanDefinition beanDefinition = new RootBeanDefinition(type);
ConstructorArgumentValues constructorArguments = new ConstructorArgumentValues();
constructorArguments.addIndexedArgumentValue(0, resource);
beanDefinition.setConstructorArgumentValues(constructorArguments);
registry.registerBeanDefinition(
StringUtils.stripFilenameExtension(resource.getFilename()),
beanDefinition);
}
}
private Resource[] getResources(String location, String pattern) {
try {
return this.applicationContext
.getResources(ensureTrailingSlash(location) + pattern);
}
catch (IOException e) {
return new Resource[0];
}
}
private static String ensureTrailingSlash(String path) {
if (!path.endsWith("/")) {
return path + "/";

View File

@ -6560,10 +6560,14 @@ your `Endpoints`.
The {spring-webservices-reference}[Spring Web Services features] can be easily accessed
via the `spring-boot-starter-webservices` module.
Spring Boot can also automatically expose your WSDLs and XSDs using
`spring.webservices.wsdl-locations` configuration property. For the detected WSDL and XSD
files Boot will register beans of type `SimpleWsdl11Definition` and `SimpleXsdSchema`,
respectively.
`SimpleWsdl11Definition` and `SimpleXsdSchema` beans can be automatically created for your
WSDLs and XSDs respectively. To do so, configure their location:
[source,properties,indent=0]
----
spring.webservices.wsdl-locations=classpath:/wsdl
----