tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r529699 - in /incubator/tuscany/java/sca/modules/binding-ws-axis2/src: main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java test/resources/org/apache/tuscany/binding/axis2/itests/endpoints/endpoint1.composite
Date Tue, 17 Apr 2007 18:14:23 GMT
Author: antelder
Date: Tue Apr 17 11:14:22 2007
New Revision: 529699

URL: http://svn.apache.org/viewvc?view=rev&rev=529699
Log:
Axis2 binidng, more fixes for endpoint URIs

Modified:
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/binding/axis2/itests/endpoints/endpoint1.composite

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java?view=diff&rev=529699&r1=529698&r2=529699
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2BindingBuilder.java
Tue Apr 17 11:14:22 2007
@@ -27,8 +27,10 @@
 import org.apache.axiom.om.OMElement;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.ConfigurationContext;
+import org.apache.tuscany.assembly.Component;
 import org.apache.tuscany.assembly.CompositeReference;
 import org.apache.tuscany.assembly.CompositeService;
+import org.apache.tuscany.assembly.SCABinding;
 import org.apache.tuscany.binding.axis2.util.TuscanyAxisConfigurator;
 import org.apache.tuscany.binding.ws.WebServiceBinding;
 import org.apache.tuscany.http.ServletHostExtensionPoint;
@@ -40,9 +42,8 @@
 import org.apache.tuscany.spi.extension.BindingBuilderExtension;
 
 /**
- * Builds a {@link org.osoa.sca.annotations.Service} or
- * {@link org.apache.tuscany.spi.component.ReferenceBinding} configured with the
- * Axis2 binding
+ * Builds a {@link org.osoa.sca.annotations.Service} or {@link org.apache.tuscany.spi.component.ReferenceBinding}
configured
+ * with the Axis2 binding
  */
 public class Axis2BindingBuilder extends BindingBuilderExtension<WebServiceBinding>
{
 
@@ -52,9 +53,8 @@
     private ServletHostExtensionPoint servletHost;
 
     private ConfigurationContext configContext;
-
-    //
-    // private WorkContext workContext;
+//
+//    private WorkContext workContext;
 
     public Axis2BindingBuilder() {
         initAxis();
@@ -70,17 +70,15 @@
     }
 
     @Override
-    public ReferenceBinding build(CompositeReference compositeReference,
-                                  WebServiceBinding wsBinding,
-                                  DeploymentContext context) throws BuilderException {
+    public ReferenceBinding build(CompositeReference compositeReference, WebServiceBinding
wsBinding, DeploymentContext context) throws BuilderException {
 
-        // Set to use the Axiom data binding
+        // Set to use the Axiom data binding 
         InterfaceContract contract = wsBinding.getBindingInterfaceContract();
         if (contract == null) {
             contract = compositeReference.getInterfaceContract();
             wsBinding.setBindingInterfaceContract(contract);
         }
-        contract.getInterface().setDefaultDataBinding(OMElement.class.getName());
+        contract.getInterface().setDefaultDataBinding(OMElement.class.getName());       

 
         URI targetURI = wsBinding.getURI() != null ? URI.create(wsBinding.getURI()) : URI.create("foo");
         URI name = URI.create(context.getComponentId() + "#" + compositeReference.getName());
@@ -89,18 +87,18 @@
     }
 
     @Override
-    public ServiceBinding build(CompositeService compositeService,
-                                WebServiceBinding wsBinding,
-                                DeploymentContext context) throws BuilderException {
+    public ServiceBinding build(CompositeService compositeService, WebServiceBinding wsBinding,
DeploymentContext context) throws BuilderException {
 
         InterfaceContract contract = wsBinding.getBindingInterfaceContract();
         if (contract == null) {
             contract = compositeService.getInterfaceContract();
             wsBinding.setBindingInterfaceContract(contract);
         }
+
+        // Set to use the Axiom data binding 
         contract.getInterface().setDefaultDataBinding(OMElement.class.getName());
 
-        URI uri = computeActualURI(wsBinding, BASE_URI, compositeService.getName()).normalize();
+        URI uri = computeActualURI(wsBinding, BASE_URI, compositeService).normalize();
 
         ServiceBinding serviceBinding = new Axis2ServiceBinding(uri, wsBinding, servletHost,
configContext, null);
 
@@ -108,8 +106,7 @@
     }
 
     protected void initAxis() {
-        // TODO: consider having a system component wrapping the Axis2
-        // ConfigContext
+        // TODO: consider having a system component wrapping the Axis2 ConfigContext
         try {
             this.configContext = new TuscanyAxisConfigurator().getConfigurationContext();
         } catch (AxisFault e) {
@@ -118,25 +115,22 @@
     }
 
     /**
-     * Compute the endpoint URI based on section 2.1.1 of the WS binding spec 1.
-     * The URIs in the endpoint(s) of the referenced WSDL, which may be relative
-     * 2. The URI specified by the wsa:Address element of the
-     * wsa:EndpointReference, which may be relative 3. The explicitly stated URI
-     * in the "uri" attribute of the binding.ws element, which may be relative,
-     * 4. The implicit URI as defined by in section 1.7 in the SCA Assembly spec
-     * If the <binding.ws> has no wsdlElement but does have a uri attribute then
-     * the uri takes precidence over any implicitly used WSDL.
-     * 
-     * @param parent
+     * Compute the endpoint URI based on section 2.1.1 of the WS binding spec
+     * 1. The URIs in the endpoint(s) of the referenced WSDL, which may be relative
+     * 2. The URI specified by the wsa:Address element of the wsa:EndpointReference, which
may be relative
+     * 3. The explicitly stated URI in the "uri" attribute of the binding.ws element, which
may be relative,
+     * 4. The implicit URI as defined by in section 1.7 in the SCA Assembly spec 
+     * If the <binding.ws> has no wsdlElement but does have a uri attribute then the
uri takes precidence
+     * over any implicitly used WSDL.
+     * @param parent 
      */
-    protected URI computeActualURI(WebServiceBinding wsBinding, String baseURI, String componentName)
{
-
+    protected URI computeActualURI(WebServiceBinding wsBinding, String baseURI, CompositeService
compositeService) {
+        
         // TODO: support wsa:Address
 
-        URI wsdlURI = null;
+        URI wsdlURI = null;         
         if (wsBinding.getServiceName() != null && wsBinding.getBindingName() == null)
{
-            // <binding.ws> explicitly points at a wsdl port, may be a relative
-            // URI
+            // <binding.ws> explicitly points at a wsdl port, may be a relative URI
             wsdlURI = getEndpoint(wsBinding.getPort());
         }
         if (wsdlURI != null && wsdlURI.isAbsolute()) {
@@ -145,78 +139,57 @@
             }
             return URI.create(wsdlURI.toString());
         }
-
+        
         // there is no wsdl port endpoint URI or that URI is relative
-
+        
         URI bindingURI = null;
         if (wsBinding.getURI() != null) {
             bindingURI = URI.create(wsBinding.getURI());
         }
 
         if (bindingURI != null && bindingURI.isAbsolute()) {
-            // there is an absoulte uri specified on the binding: <binding.ws
-            // uri="xxx"
+            // there is an absoulte uri specified on the binding: <binding.ws uri="xxx"
             if (wsdlURI != null) {
+                // there is a relative URI in the wsdl port
                 return URI.create(bindingURI + "/" + wsdlURI);
             } else {
                 return bindingURI;
             }
         }
-
-        // both the WSDL endpoint and binding uri are either unspecified or
-        // relative so
+        
+        // both the WSDL endpoint and binding uri are either unspecified or relative so
         // the endpoint is based on the component uri and service name
-
-        URI componentURI = URI.create(componentName);
-
-        if (componentURI == null) { // null for references
-            wsdlURI = getEndpoint(wsBinding.getPort());
-            if (bindingURI != null) {
-                return URI.create(wsdlURI + "/" + bindingURI);
-            } else {
-                return wsdlURI;
-            }
-        }
-
-        // TODO: TUSCANY-xxx, how to tell if component has multiple services
-        // using <binding.ws>?
-        // boolean singleService = (parent != null) &&
-        // (((Component)parent.getChild(componentURI.toString())).getInboundWires().size()
-        // == 1);
-        // if (bindingURI == null && !singleService) {
-
-        // if (bindingURI == null) {
-        // bindingURI = URI.create(bindingName);
-        // }
-
+ 
+        // TODO: hack to get the component for the service
+        SCABinding scaBinding = compositeService.getPromotedService().getBinding(SCABinding.class);
+        Component component = scaBinding.getComponent();
+        URI componentURI = URI.create(component.getName());
+        
+        String actualURI;
         if (componentURI.isAbsolute()) {
-            if (bindingURI == null && wsdlURI == null) {
-                return componentURI;
-            } else if (wsdlURI == null) {
-                return URI.create(componentURI + "/" + bindingURI);
-            } else if (bindingURI == null) {
-                return URI.create(componentURI + "/" + wsdlURI);
-            } else {
-                return URI.create(componentURI + "/" + bindingURI + "/" + wsdlURI);
-            }
-        }
-
-        String actualURI = "";
-
-        if (bindingURI == null) {
-            actualURI = baseURI + "/" + componentURI + "/";
+            actualURI = componentURI.toString();
         } else {
-            actualURI = baseURI + "/" + componentURI + "/" + bindingURI + "/";
+            actualURI = baseURI + "/" + componentURI;
+        }
+        
+        // with multiple services the default binding URI is the binding name
+        if (bindingURI == null && component.getServices().size() > 1) {
+            bindingURI = URI.create(wsBinding.getName());
         }
 
+        if (bindingURI != null) {
+            actualURI += "/" + bindingURI;
+         }
+
         if (wsdlURI != null) {
-            actualURI = actualURI + wsdlURI.toString();
+            actualURI += "/" + wsdlURI.toString();
         }
 
+        // Axis2 fails if the endpoint has a trailing slash
         if (actualURI.endsWith("/")) {
-            actualURI = actualURI.substring(0, actualURI.length() - 1);
+            actualURI = actualURI.substring(0, actualURI.length() -1);
         }
-
+        
         return URI.create(actualURI);
     }
 
@@ -228,7 +201,7 @@
             final List wsdlPortExtensions = wsdlPort.getExtensibilityElements();
             for (final Object extension : wsdlPortExtensions) {
                 if (extension instanceof SOAPAddress) {
-                    return URI.create(((SOAPAddress)extension).getLocationURI());
+                    return URI.create(((SOAPAddress) extension).getLocationURI());
                 }
             }
         }

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/binding/axis2/itests/endpoints/endpoint1.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/binding/axis2/itests/endpoints/endpoint1.composite?view=diff&rev=529699&r1=529698&r2=529699
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/binding/axis2/itests/endpoints/endpoint1.composite
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/binding/axis2/itests/endpoints/endpoint1.composite
Tue Apr 17 11:14:22 2007
@@ -23,7 +23,8 @@
            
     <!-- 
     exposing a component with a WS binding, endpoint should be <componentURI>/<serviceName>
-    so for this composite: http://localhost:8080/HelloWorldService/helloWorld 
+    unless the component has just a single service in which case its just <componentURI>
+    so for this composite: http://localhost:8080/HelloWorldService 
     -->      
 
     <service name="helloWorld" promote="HelloWorldService">
@@ -43,7 +44,7 @@
     <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS">
         <interface.wsdl interface="http://helloworld-om#wsdl.interface(HelloWorld)" />
         <binding.ws wsdlElement="http://helloworld-om#wsdl.binding(HelloWorldSoapBinding)"
-                    uri="http://localhost:8080/helloWorld"/>
+                    uri="http://localhost:8080/HelloWorldService"/>
     </reference>
 
 </composite>



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message