You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2007/04/13 20:52:46 UTC
svn commit: r528590 - in /incubator/cxf/trunk:
rt/core/src/main/java/org/apache/cxf/binding/
rt/core/src/main/java/org/apache/cxf/wsdl11/
rt/core/src/test/java/org/apache/cxf/wsdl11/
rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ rt/frontend/sim...
Author: dkulp
Date: Fri Apr 13 11:52:45 2007
New Revision: 528590
URL: http://svn.apache.org/viewvc?view=rev&rev=528590
Log:
Add support for standard Endpoint properties (service name/port name)
Add support for setting WSDL location for Endpoint prior to publish
Use first port extensor that has a DestinationFactory registered instead of just the first port extensor.
Don't force addresses to have "://" in them (which then forces them to be http)
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/binding/AbstractBindingFactory.java
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/ServiceWSDLBuilderTest.java
incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/WSDLServiceBuilderTest.java
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/binding/AbstractBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/binding/AbstractBindingFactory.java?view=diff&rev=528590&r1=528589&r2=528590
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/binding/AbstractBindingFactory.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/binding/AbstractBindingFactory.java Fri Apr 13 11:52:45 2007
@@ -76,7 +76,12 @@
* creates it for the first ServiceInfo in the service
*/
public BindingInfo createBindingInfo(Service service, String namespace, Object config) {
- return createBindingInfo(service.getServiceInfos().get(0), namespace, config);
+ BindingInfo bi = createBindingInfo(service.getServiceInfos().get(0), namespace, config);
+ if (bi.getName() == null) {
+ bi.setName(new QName(service.getName().getNamespaceURI(),
+ service.getName().getLocalPart() + "Binding"));
+ }
+ return bi;
}
@@ -89,7 +94,6 @@
public BindingInfo createBindingInfo(ServiceInfo service, Binding binding, String ns) {
BindingInfo bi = createBindingInfo(service, ns, null);
-
return initializeBindingInfo(service, binding, bi);
}
Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java?view=diff&rev=528590&r1=528589&r2=528590
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java Fri Apr 13 11:52:45 2007
@@ -401,27 +401,48 @@
public EndpointInfo buildEndpoint(ServiceInfo service, BindingInfo bi, Port port) {
List elements = port.getExtensibilityElements();
String ns = null;
+
+ DestinationFactory factory = null;
+ EndpointInfo ei = null;
+
if (null != elements && elements.size() > 0) {
- ns = ((ExtensibilityElement)elements.get(0)).getElementType().getNamespaceURI();
- } else { // get the transport id from bindingInfo
- ExtensibilityElement extElem = (ExtensibilityElement)port.getBinding().getExtensibilityElements()
- .get(0);
- if (extElem instanceof SOAPBindingImpl) {
- ns = (String)((SOAPBindingImpl)extElem).getTransportURI();
+ for (ExtensibilityElement el : CastUtils.cast(elements, ExtensibilityElement.class)) {
+ ns = el.getElementType().getNamespaceURI();
+ try {
+ factory = bus.getExtension(DestinationFactoryManager.class)
+ .getDestinationFactory(ns);
+ } catch (BusException e) {
+ // do nothing
+ }
+ if (factory != null) {
+ break;
+ }
+ }
+ if (factory == null) {
+ ns = ((ExtensibilityElement)elements.get(0)).getElementType().getNamespaceURI();
}
}
- EndpointInfo ei = null;
-
- try {
- DestinationFactory factory = bus.getExtension(DestinationFactoryManager.class)
- .getDestinationFactory(ns);
- if (factory instanceof WSDLEndpointFactory) {
- WSDLEndpointFactory wFactory = (WSDLEndpointFactory)factory;
- ei = wFactory.createEndpointInfo(service, bi, port);
+
+ if (factory == null) { // get the transport id from bindingInfo
+ elements = port.getBinding().getExtensibilityElements();
+ for (ExtensibilityElement el : CastUtils.cast(elements, ExtensibilityElement.class)) {
+ if (el instanceof SOAPBindingImpl) {
+ ns = (String)((SOAPBindingImpl)el).getTransportURI();
+ break;
+ }
+ }
+ try {
+ factory = bus.getExtension(DestinationFactoryManager.class)
+ .getDestinationFactory(ns);
+ } catch (BusException e) {
+ // do nothing
}
- } catch (BusException e) {
- // do nothing
}
+ if (factory instanceof WSDLEndpointFactory) {
+ WSDLEndpointFactory wFactory = (WSDLEndpointFactory)factory;
+ ei = wFactory.createEndpointInfo(service, bi, port);
+ }
+
if (ei == null) {
ei = new EndpointInfo(service, ns);
Modified: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/ServiceWSDLBuilderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/ServiceWSDLBuilderTest.java?view=diff&rev=528590&r1=528589&r2=528590
==============================================================================
--- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/ServiceWSDLBuilderTest.java (original)
+++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/ServiceWSDLBuilderTest.java Fri Apr 13 11:52:45 2007
@@ -46,6 +46,7 @@
import org.apache.cxf.binding.BindingFactoryManager;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.transport.DestinationFactory;
import org.apache.cxf.transport.DestinationFactoryManager;
import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.easymock.classextension.EasyMock;
@@ -67,6 +68,7 @@
private Bus bus;
private BindingFactoryManager bindingFactoryManager;
private DestinationFactoryManager destinationFactoryManager;
+ private DestinationFactory destinationFactory;
public void setUp() throws Exception {
@@ -81,6 +83,7 @@
bus = control.createMock(Bus.class);
bindingFactoryManager = control.createMock(BindingFactoryManager.class);
destinationFactoryManager = control.createMock(DestinationFactoryManager.class);
+ destinationFactory = control.createMock(DestinationFactory.class);
wsdlServiceBuilder = new WSDLServiceBuilder(bus);
for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
@@ -93,6 +96,10 @@
EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager);
EasyMock.expect(bus.getExtension(DestinationFactoryManager.class))
.andReturn(destinationFactoryManager);
+
+ EasyMock.expect(destinationFactoryManager
+ .getDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/"))
+ .andReturn(destinationFactory);
control.replay();
Modified: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/WSDLServiceBuilderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/WSDLServiceBuilderTest.java?view=diff&rev=528590&r1=528589&r2=528590
==============================================================================
--- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/WSDLServiceBuilderTest.java (original)
+++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/wsdl11/WSDLServiceBuilderTest.java Fri Apr 13 11:52:45 2007
@@ -58,6 +58,7 @@
import org.apache.cxf.service.model.OperationInfo;
import org.apache.cxf.service.model.SchemaInfo;
import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.transport.DestinationFactory;
import org.apache.cxf.transport.DestinationFactoryManager;
import org.apache.cxf.wsdl.EndpointReferenceUtils;
import org.apache.ws.commons.schema.XmlSchemaCollection;
@@ -128,6 +129,8 @@
bus = control.createMock(Bus.class);
bindingFactoryManager = control.createMock(BindingFactoryManager.class);
destinationFactoryManager = control.createMock(DestinationFactoryManager.class);
+ DestinationFactory destinationFactory = control.createMock(DestinationFactory.class);
+
WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
EasyMock.expect(bus.getExtension(BindingFactoryManager.class))
@@ -135,6 +138,11 @@
EasyMock.expect(bus.getExtension(DestinationFactoryManager.class))
.andReturn(destinationFactoryManager).atLeastOnce();
+
+ EasyMock.expect(destinationFactoryManager
+ .getDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/"))
+ .andReturn(destinationFactory).anyTimes();
+
control.replay();
serviceInfos = wsdlServiceBuilder.buildServices(def, service);
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java?view=diff&rev=528590&r1=528589&r2=528590
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java Fri Apr 13 11:52:45 2007
@@ -78,7 +78,7 @@
private List<Source> metadata;
private Executor executor;
- private String binding;
+ private String bindingUri;
private String wsdlLocation;
private String address;
private QName endpointName;
@@ -110,7 +110,7 @@
public EndpointImpl(Bus b, Object implementor,
JaxWsServiceFactoryBean serviceFactory, String bindingUri) {
this.bus = b;
- this.binding = bindingUri;
+ this.bindingUri = bindingUri;
this.serverFactory = new JaxWsServerFactoryBean(serviceFactory);
this.implementor = implementor;
@@ -137,7 +137,7 @@
public EndpointImpl(Bus b, Object i, String bindingUri, String wsdl) {
bus = b;
implementor = i;
- binding = bindingUri;
+ this.bindingUri = bindingUri;
wsdlLocation = wsdl;
serverFactory = new JaxWsServerFactoryBean();
@@ -249,8 +249,23 @@
return endpointName.toString();
}
+ protected void checkProperties() {
+ if (properties != null) {
+ if (properties.containsKey("javax.xml.ws.wsdl.description")) {
+ wsdlLocation = properties.get("javax.xml.ws.wsdl.description").toString();
+ }
+ if (properties.containsKey(javax.xml.ws.Endpoint.WSDL_PORT)) {
+ endpointName = (QName)properties.get(javax.xml.ws.Endpoint.WSDL_PORT);
+ }
+ if (properties.containsKey(javax.xml.ws.Endpoint.WSDL_SERVICE)) {
+ serviceName = (QName)properties.get(javax.xml.ws.Endpoint.WSDL_SERVICE);
+ }
+ }
+ }
+
protected void doPublish(String addr) {
checkPublishPermission();
+ checkProperties();
// Initialize the endpointName so we can do configureObject
if (endpointName == null) {
@@ -273,8 +288,8 @@
serverFactory.setWsdlURL(getWsdlLocation());
}
- if (binding != null) {
- serverFactory.setBindingId(binding);
+ if (bindingUri != null) {
+ serverFactory.setBindingId(bindingUri);
}
if (serviceName != null) {
@@ -399,8 +414,11 @@
this.wsdlLocation = wsdlLocation;
}
- public void setBinding(String binding) {
- this.binding = binding;
+ public void setBindingUri(String binding) {
+ this.bindingUri = binding;
+ }
+ public String getBindingUri() {
+ return this.bindingUri;
}
public List<Interceptor> getOutFaultInterceptors() {
Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java?view=diff&rev=528590&r1=528589&r2=528590
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java (original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java Fri Apr 13 11:52:45 2007
@@ -231,15 +231,6 @@
}
public String getAddress() {
- if (address != null && address.indexOf("://") == -1) {
- String a2 = "http://localhost";
- if (!address.startsWith("/")) {
- a2 += "/";
- }
-
- a2 += address;
- return a2;
- }
return address;
}
Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java?view=diff&rev=528590&r1=528589&r2=528590
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java (original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java Fri Apr 13 11:52:45 2007
@@ -20,7 +20,6 @@
package org.apache.cxf.transport.servlet;
import java.io.IOException;
-import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -42,7 +41,6 @@
private static final long serialVersionUID = 1L;
protected String name;
- protected URL nurl;
/**
@@ -59,7 +57,20 @@
EndpointInfo ei)
throws IOException {
// would add the default port to the address
- super(b, ci, ei, false);
+ super(b, ci, updateEndpointAddress(ei), false);
+ }
+
+ private static EndpointInfo updateEndpointAddress(EndpointInfo ei) {
+ String ad = ei.getAddress();
+ if (ad != null && ad.indexOf("://") == -1) {
+ if (ad.startsWith("/")) {
+ ad = "http://localhost" + ad;
+ } else {
+ ad = "http://localhost/" + ad;
+ }
+ ei.setAddress(ad);
+ }
+ return ei;
}
protected Logger getLogger() {
Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java?view=diff&rev=528590&r1=528589&r2=528590
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java (original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java Fri Apr 13 11:52:45 2007
@@ -60,9 +60,11 @@
public Destination getDestination(EndpointInfo endpointInfo)
throws IOException {
+ //String origAddress = endpointInfo.getAddress();
ServletDestination d = destinations.get(endpointInfo.getAddress());
if (d == null) {
d = new ServletDestination(bus, null, endpointInfo);
+ //destinations.put(origAddress, d);
destinations.put(endpointInfo.getAddress(), d);
}
return d;
Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java?view=diff&rev=528590&r1=528589&r2=528590
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java Fri Apr 13 11:52:45 2007
@@ -91,7 +91,7 @@
assertNotNull("cannot find test resource", url);
defaultConfigFileName = url.toString();
- assertTrue("server did not launch correctly", launchServer(Server.class, true));
+ assertTrue("server did not launch correctly", launchServer(Server.class));
}