added support for @WebServiceProvider annotation to Spring's JaxWsServiceExporters (SPR-5988)
This commit is contained in:
parent
2cd71758ed
commit
9a0108ac6a
|
|
@ -22,6 +22,7 @@ import java.util.Set;
|
|||
import java.util.concurrent.Executor;
|
||||
import javax.jws.WebService;
|
||||
import javax.xml.ws.Endpoint;
|
||||
import javax.xml.ws.WebServiceProvider;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
|
|
@ -101,8 +102,9 @@ public abstract class AbstractJaxWsServiceExporter implements BeanFactoryAware,
|
|||
String[] beanNames = this.beanFactory.getBeanNamesForType(Object.class, false, false);
|
||||
for (String beanName : beanNames) {
|
||||
Class<?> type = this.beanFactory.getType(beanName);
|
||||
WebService annotation = type.getAnnotation(WebService.class);
|
||||
if (annotation != null) {
|
||||
WebService wsAnnotation = type.getAnnotation(WebService.class);
|
||||
WebServiceProvider wsProviderAnnotation = type.getAnnotation(WebServiceProvider.class);
|
||||
if (wsAnnotation != null || wsProviderAnnotation != null) {
|
||||
Endpoint endpoint = Endpoint.create(this.beanFactory.getBean(beanName));
|
||||
if (this.endpointProperties != null) {
|
||||
endpoint.setProperties(this.endpointProperties);
|
||||
|
|
@ -110,7 +112,12 @@ public abstract class AbstractJaxWsServiceExporter implements BeanFactoryAware,
|
|||
if (this.executor != null) {
|
||||
endpoint.setExecutor(this.executor);
|
||||
}
|
||||
publishEndpoint(endpoint, annotation);
|
||||
if (wsAnnotation != null) {
|
||||
publishEndpoint(endpoint, wsAnnotation);
|
||||
}
|
||||
else {
|
||||
publishEndpoint(endpoint, wsProviderAnnotation);
|
||||
}
|
||||
this.publishedEndpoints.add(endpoint);
|
||||
}
|
||||
}
|
||||
|
|
@ -123,6 +130,13 @@ public abstract class AbstractJaxWsServiceExporter implements BeanFactoryAware,
|
|||
*/
|
||||
protected abstract void publishEndpoint(Endpoint endpoint, WebService annotation);
|
||||
|
||||
/**
|
||||
* Actually publish the given provider endpoint. To be implemented by subclasses.
|
||||
* @param endpoint the JAX-WS Provider Endpoint object
|
||||
* @param annotation the service bean's WebServiceProvider annotation
|
||||
*/
|
||||
protected abstract void publishEndpoint(Endpoint endpoint, WebServiceProvider annotation);
|
||||
|
||||
|
||||
/**
|
||||
* Stops all published endpoints, taking the web services offline.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2009 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.
|
||||
|
|
@ -18,9 +18,9 @@ package org.springframework.remoting.jaxws;
|
|||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.List;
|
||||
|
||||
import javax.jws.WebService;
|
||||
import javax.xml.ws.Endpoint;
|
||||
import javax.xml.ws.WebServiceProvider;
|
||||
|
||||
import com.sun.net.httpserver.Authenticator;
|
||||
import com.sun.net.httpserver.Filter;
|
||||
|
|
@ -166,7 +166,22 @@ public class SimpleHttpServerJaxWsServiceExporter extends AbstractJaxWsServiceEx
|
|||
|
||||
@Override
|
||||
protected void publishEndpoint(Endpoint endpoint, WebService annotation) {
|
||||
String fullPath = this.basePath + annotation.serviceName();
|
||||
endpoint.publish(buildHttpContext(endpoint, annotation.serviceName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishEndpoint(Endpoint endpoint, WebServiceProvider annotation) {
|
||||
endpoint.publish(buildHttpContext(endpoint, annotation.serviceName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the HttpContext for the given endpoint.
|
||||
* @param endpoint the JAX-WS Provider Endpoint object
|
||||
* @param serviceName the given service name
|
||||
* @return the fully populated HttpContext
|
||||
*/
|
||||
protected HttpContext buildHttpContext(Endpoint endpoint, String serviceName) {
|
||||
String fullPath = calculateEndpointPath(endpoint, serviceName);
|
||||
HttpContext httpContext = this.server.createContext(fullPath);
|
||||
if (this.filters != null) {
|
||||
httpContext.getFilters().addAll(this.filters);
|
||||
|
|
@ -174,9 +189,20 @@ public class SimpleHttpServerJaxWsServiceExporter extends AbstractJaxWsServiceEx
|
|||
if (this.authenticator != null) {
|
||||
httpContext.setAuthenticator(this.authenticator);
|
||||
}
|
||||
endpoint.publish(httpContext);
|
||||
return httpContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the full endpoint path for the given endpoint.
|
||||
* @param endpoint the JAX-WS Provider Endpoint object
|
||||
* @param serviceName the given service name
|
||||
* @return the full endpoint path
|
||||
*/
|
||||
protected String calculateEndpointPath(Endpoint endpoint, String serviceName) {
|
||||
return this.basePath + serviceName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
super.destroy();
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package org.springframework.remoting.jaxws;
|
|||
|
||||
import javax.jws.WebService;
|
||||
import javax.xml.ws.Endpoint;
|
||||
import javax.xml.ws.WebServiceProvider;
|
||||
|
||||
/**
|
||||
* Simple exporter for JAX-WS services, autodetecting annotated service beans
|
||||
|
|
@ -64,12 +65,27 @@ public class SimpleJaxWsServiceExporter extends AbstractJaxWsServiceExporter {
|
|||
|
||||
@Override
|
||||
protected void publishEndpoint(Endpoint endpoint, WebService annotation) {
|
||||
String fullAddress = this.baseAddress + annotation.serviceName();
|
||||
endpoint.publish(calculateEndpointAddress(endpoint, annotation.serviceName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishEndpoint(Endpoint endpoint, WebServiceProvider annotation) {
|
||||
endpoint.publish(calculateEndpointAddress(endpoint, annotation.serviceName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the full endpoint address for the given endpoint.
|
||||
* @param endpoint the JAX-WS Provider Endpoint object
|
||||
* @param serviceName the given service name
|
||||
* @return the full endpoint address
|
||||
*/
|
||||
protected String calculateEndpointAddress(Endpoint endpoint, String serviceName) {
|
||||
String fullAddress = this.baseAddress + serviceName;
|
||||
if (endpoint.getClass().getName().startsWith("weblogic.")) {
|
||||
// Workaround for WebLogic 10.3
|
||||
fullAddress = fullAddress + "/";
|
||||
}
|
||||
endpoint.publish(fullAddress);
|
||||
return fullAddress;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue