Author: richard.opalka(a)jboss.com
Date: 2009-09-21 08:36:40 -0400 (Mon, 21 Sep 2009)
New Revision: 10722
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/EndpointImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ProviderImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java
Log:
[JBWS-2674][JBWS-2754] providing JAX-WS 2.2 methods
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/EndpointImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/EndpointImpl.java 2009-09-21
07:37:56 UTC (rev 10721)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/EndpointImpl.java 2009-09-21
12:36:40 UTC (rev 10722)
@@ -34,6 +34,7 @@
import javax.xml.ws.Endpoint;
import javax.xml.ws.EndpointReference;
import javax.xml.ws.WebServiceException;
+import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.WebServicePermission;
import javax.xml.ws.http.HTTPBinding;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
@@ -67,6 +68,7 @@
private Object implementor;
private Executor executor;
+ private WebServiceFeature[] features; // TODO: use features
private List<Source> metadata;
private BindingProviderImpl bindingProvider;
private Map<String, Object> properties = new HashMap<String, Object>();
@@ -75,15 +77,14 @@
private boolean isDestroyed;
private URI address;
- public EndpointImpl(String bindingId, Object implementor)
+ public EndpointImpl(String bindingId, Object implementor, WebServiceFeature[]
features)
{
- log.debug("new EndpointImpl(bindingId=" + bindingId +
",implementor=" + implementor + ")");
-
if (implementor == null)
throw new IllegalArgumentException("Implementor cannot be null");
this.implementor = implementor;
this.bindingProvider = new BindingProviderImpl(bindingId);
+ this.features = features;
}
@Override
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ProviderImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ProviderImpl.java 2009-09-21
07:37:56 UTC (rev 10721)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ProviderImpl.java 2009-09-21
12:36:40 UTC (rev 10722)
@@ -24,6 +24,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
+import java.util.Map;
import javax.xml.namespace.QName;
import javax.xml.transform.Source;
@@ -47,107 +48,112 @@
* Service provider for ServiceDelegate and Endpoint objects.
*
* @author Thomas.Diesler(a)jboss.com
- * @since 03-May-2006
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ * @see javax.xml.ws.spi.Provider
*/
-public class ProviderImpl extends Provider
+public final class ProviderImpl extends Provider
{
- // 6.2 Conformance (Concrete javax.xml.ws.spi.Provider required): An implementation
MUST provide
- // a concrete class that extends javax.xml.ws.spi.Provider. Such a class MUST have a
public constructor
- // which takes no arguments.
+
public ProviderImpl()
{
}
@Override
- public ServiceDelegate createServiceDelegate(URL wsdlLocation, QName serviceName,
Class serviceClass)
+ public Endpoint createAndPublishEndpoint(final String address, final Object
implementor)
{
- ServiceDelegateImpl delegate = new ServiceDelegateImpl(wsdlLocation, serviceName,
serviceClass);
- DOMUtils.clearThreadLocals();
- return delegate;
+ return this.createAndPublishEndpoint(address, implementor,
(WebServiceFeature[])null);
}
+ // @Override TODO: comment out override on switch to JAX-WS 2.2
+ public Endpoint createAndPublishEndpoint(final String address, final Object
implementor, final WebServiceFeature... features)
+ {
+ final String bindingId = getBindingFromAddress(address);
+ final EndpointImpl endpoint = (EndpointImpl)createEndpoint(bindingId, implementor,
features);
+ endpoint.publish(address);
+
+ return endpoint;
+ }
+
@Override
- public Endpoint createEndpoint(String bindingId, Object implementor)
+ public Endpoint createEndpoint(final String bindingId, final Object implementor)
{
- String realBindingId = bindingId;
- if (realBindingId == null)
- {
- BindingType anBindingType =
implementor.getClass().getAnnotation(BindingType.class);
- realBindingId = (anBindingType != null) ? anBindingType.value() :
SOAPBinding.SOAP11HTTP_BINDING;
- }
+ return this.createEndpoint(bindingId, implementor, (WebServiceFeature[])null);
+ }
+
+ // @Override TODO: comment out override on switch to JAX-WS 2.2
+ public Endpoint createEndpoint(final String bindingId, final Object implementor, final
WebServiceFeature... features)
+ {
+ final String nonNullBindingId = this.getBindingId(bindingId,
implementor.getClass());
- return new EndpointImpl(realBindingId, implementor);
+ return new EndpointImpl(nonNullBindingId, implementor, features);
}
+ /* TODO: comment out on switch to JAX-WS 2.2
+ @SuppressWarnings("unchecked")
@Override
- public Endpoint createAndPublishEndpoint(String address, Object implementor)
+ public Endpoint createEndpoint(final String bindingId, final Class implementorClass,
final Invoker invoker,
+ final WebServiceFeature... features)
{
- // 6.3 Conformance (Provider createAndPublishEndpoint Method): The effect of
invoking the createAnd-
- // PublishEndpoint method on a Provider MUST be the same as first invoking the
createEndpoint
- // method with the binding ID appropriate to the URL scheme used by the address,
then invoking the
- // publish(String address) method on the resulting endpoint.
+ throw new UnsupportedOperationException("This method is not portable across
JAX-WS implementations");
+ }
+ */
+
+ @Override
+ public ServiceDelegate createServiceDelegate(final URL wsdlLocation, final QName
serviceName, final Class serviceClass)
+ {
+ return this.createServiceDelegate(wsdlLocation, serviceName, serviceClass,
(WebServiceFeature[])null);
+ }
- String bindingId = getBindingFromAddress(address);
- EndpointImpl endpoint = (EndpointImpl)createEndpoint(bindingId, implementor);
- endpoint.publish(address);
- return endpoint;
+ // @Override TODO: comment out override on switch to JAX-WS 2.2
+ public ServiceDelegate createServiceDelegate(final URL wsdlLocation, final QName
serviceName, final Class serviceClass,
+ final WebServiceFeature... features)
+ {
+ ServiceDelegateImpl delegate = new ServiceDelegateImpl(wsdlLocation, serviceName,
serviceClass, features);
+ DOMUtils.clearThreadLocals();
+ return delegate;
}
- private String getBindingFromAddress(String address)
+ // @Override TODO: comment out override on switch to JAX-WS 2.2
+ public W3CEndpointReference createW3CEndpointReference(final String address, final
QName interfaceName,
+ final QName serviceName, final QName portName, final List<Element>
metadata, final String wsdlDocumentLocation,
+ final List<Element> referenceParameters, final List<Element>
elements, final Map<QName, String> attributes)
{
- String bindingId;
- try
- {
- URL url = new URL(address);
- String protocol = url.getProtocol();
- if (protocol.startsWith("http"))
- {
- bindingId = SOAPBinding.SOAP11HTTP_BINDING;
- }
- else
- {
- throw new IllegalArgumentException("Unsupported protocol: " +
address);
- }
- }
- catch (MalformedURLException e)
- {
- throw new IllegalArgumentException("Invalid endpoint address: " +
address);
- }
- return bindingId;
+ throw new UnsupportedOperationException(); // TODO
}
@Override
- public W3CEndpointReference createW3CEndpointReference(String address, QName
serviceName, QName portName, List<Element> metadata, String wsdlDocumentLocation,
- List<Element> referenceParameters)
+ public W3CEndpointReference createW3CEndpointReference(final String address, final
QName serviceName,
+ final QName portName, final List<Element> metadata, final String
wsdlDocumentLocation,
+ final List<Element> referenceParameters)
{
- NativeEndpointReference epr = new NativeEndpointReference();
+ final NativeEndpointReference epr = new NativeEndpointReference();
epr.setAddress(address);
epr.setServiceName(serviceName);
epr.setEndpointName(portName);
epr.setMetadata(metadata);
epr.setWsdlLocation(wsdlDocumentLocation);
epr.setReferenceParameters(referenceParameters);
+
return EndpointReferenceUtil.transform(W3CEndpointReference.class, epr);
}
@Override
- public <T> T getPort(EndpointReference epr, Class<T> sei,
WebServiceFeature... features)
+ public <T> T getPort(final EndpointReference epr, final Class<T> sei,
final WebServiceFeature... features)
{
- URL wsdlLocation = null;
- QName serviceName = null;
- NativeEndpointReference nepr =
EndpointReferenceUtil.transform(NativeEndpointReference.class, epr);
-
- wsdlLocation = nepr.getWsdlLocation();
- serviceName = nepr.getServiceName();
- ServiceDelegate delegate = createServiceDelegate(wsdlLocation, serviceName,
Service.class);
+ final NativeEndpointReference nepr =
EndpointReferenceUtil.transform(NativeEndpointReference.class, epr);
+ final URL wsdlLocation = nepr.getWsdlLocation();
+ final QName serviceName = nepr.getServiceName();
+ final ServiceDelegate delegate = createServiceDelegate(wsdlLocation, serviceName,
Service.class);
+
return delegate.getPort(epr, sei, features);
}
@Override
- public EndpointReference readEndpointReference(Source eprInfoset)
+ public EndpointReference readEndpointReference(final Source eprInfoset)
{
if (eprInfoset == null)
throw new NullPointerException("Provided eprInfoset cannot be null");
+
try
{
//we currently support W3CEndpointReference only
@@ -158,4 +164,38 @@
throw new WebServiceException(e);
}
}
+
+ private String getBindingFromAddress(final String address)
+ {
+ try
+ {
+ final URL url = new URL(address);
+ final String protocol = url.getProtocol();
+
+ if (protocol.toLowerCase().startsWith("http"))
+ {
+ return SOAPBinding.SOAP11HTTP_BINDING;
+ }
+ }
+ catch (MalformedURLException e)
+ {
+ throw new IllegalArgumentException("Invalid endpoint address: " +
address);
+ }
+
+ throw new IllegalArgumentException("Unsupported protocol: " + address);
+ }
+
+ private String getBindingId(final String bindingId, final Class<?>
implementorClass)
+ {
+ if (bindingId != null)
+ {
+ return bindingId;
+ }
+ else
+ {
+ final BindingType bindingType =
implementorClass.getAnnotation(BindingType.class);
+ return (bindingType != null) ? bindingType.value() :
SOAPBinding.SOAP11HTTP_BINDING;
+ }
+ }
+
}
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java 2009-09-21
07:37:56 UTC (rev 10721)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java 2009-09-21
12:36:40 UTC (rev 10722)
@@ -106,10 +106,18 @@
private HandlerResolver handlerResolver;
// The executor service
private ExecutorService executor;
+ // The features
+ private WebServiceFeature[] features;
// A list of annotated ports
private List<QName> annotatedPorts = new ArrayList<QName>();
+ public ServiceDelegateImpl(URL wsdlURL, QName serviceName, Class serviceClass,
WebServiceFeature[] features)
+ {
+ this(wsdlURL, serviceName, serviceClass);
+ this.features = features;
+ }
+
public ServiceDelegateImpl(URL wsdlURL, QName serviceName, Class serviceClass)
{
// If this Service was constructed through the ServiceObjectFactory
@@ -470,6 +478,7 @@
public <T> Dispatch<T> createDispatch(QName portName, Class<T> type,
Mode mode, WebServiceFeature... features)
{
Dispatch<T> dispatch = createDispatch(portName, type, mode);
+ initWebserviceFeatures(dispatch, this.features);
initWebserviceFeatures(dispatch, features);
return dispatch;
}
@@ -483,6 +492,7 @@
Dispatch<T> dispatch = createDispatch(portName, type, mode);
initAddressingProperties(dispatch, epr);
+ initWebserviceFeatures(dispatch, this.features);
initWebserviceFeatures(dispatch, features);
return dispatch;
}
@@ -491,6 +501,7 @@
public Dispatch<Object> createDispatch(QName portName, JAXBContext context, Mode
mode, WebServiceFeature... features)
{
Dispatch<Object> dispatch = createDispatch(portName, context, mode);
+ initWebserviceFeatures(dispatch, this.features);
initWebserviceFeatures(dispatch, features);
return dispatch;
}
@@ -504,6 +515,7 @@
Dispatch<Object> dispatch = createDispatch(portName, context, mode);
initAddressingProperties(dispatch, epr);
+ initWebserviceFeatures(dispatch, this.features);
initWebserviceFeatures(dispatch, features);
return dispatch;
}
@@ -512,6 +524,7 @@
public <T> T getPort(QName portName, Class<T> sei, WebServiceFeature...
features)
{
T port = getPort(portName, sei);
+ initWebserviceFeatures(port, this.features);
initWebserviceFeatures(port, features);
return port;
}
@@ -521,6 +534,7 @@
{
T port = getPort(sei);
initAddressingProperties((BindingProvider)port, epr);
+ initWebserviceFeatures(port, this.features);
initWebserviceFeatures(port, features);
return port;
}
@@ -529,6 +543,7 @@
public <T> T getPort(Class<T> sei, WebServiceFeature... features)
{
T port = getPort(sei);
+ initWebserviceFeatures(port, this.features);
initWebserviceFeatures(port, features);
return port;
}