You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2008/04/18 05:44:16 UTC

svn commit: r649359 - in /servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src: main/java/org/apache/servicemix/cxfbc/ test/java/org/apache/servicemix/cxfbc/ test/resources/org/apache/servicemix/cxfbc/

Author: ffang
Date: Thu Apr 17 20:44:14 2008
New Revision: 649359

URL: http://svn.apache.org/viewvc?rev=649359&view=rev
Log:
[SM-1318]cxf bc provider should load transport according to endpoint from wsdl but not hardcoded

Added:
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/MyJMSServer.java   (with props)
Modified:
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcJmsTest.java
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/jms_transport.xml

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java?rev=649359&r1=649358&r2=649359&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java Thu Apr 17 20:44:14 2008
@@ -22,12 +22,12 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.logging.Logger;
 
 import javax.jbi.management.DeploymentException;
 import javax.jbi.messaging.ExchangeStatus;
 import javax.jbi.messaging.MessageExchange;
 import javax.jbi.messaging.NormalizedMessage;
+import javax.wsdl.WSDLException;
 import javax.wsdl.factory.WSDLFactory;
 import javax.wsdl.xml.WSDLReader;
 import javax.xml.namespace.QName;
@@ -45,7 +45,6 @@
 import org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor;
 import org.apache.cxf.binding.soap.interceptor.SoapPreProtocolOutInterceptor;
 import org.apache.cxf.bus.spring.SpringBusFactory;
-import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointImpl;
 import org.apache.cxf.interceptor.AttachmentOutInterceptor;
@@ -67,6 +66,7 @@
 import org.apache.cxf.transport.ConduitInitiator;
 import org.apache.cxf.transport.ConduitInitiatorManager;
 import org.apache.cxf.transport.jbi.JBIMessageHelper;
+import org.apache.cxf.wsdl.WSDLManager;
 import org.apache.cxf.wsdl11.WSDLServiceFactory;
 import org.apache.servicemix.common.endpoints.ProviderEndpoint;
 import org.apache.servicemix.cxfbc.interceptors.JbiOutInterceptor;
@@ -85,8 +85,7 @@
 public class CxfBcProvider extends ProviderEndpoint implements
         CxfBcEndpointWithInterceptor {
 
-    private static final Logger LOG = LogUtils.getL7dLogger(org.apache.servicemix.cxfbc.CxfBcProvider.class);
-    
+        
     
     List<Interceptor> in = new CopyOnWriteArrayList<Interceptor>();
 
@@ -253,8 +252,13 @@
                 WSDLFactory wsdlFactory = WSDLFactory.newInstance();
                 WSDLReader reader = wsdlFactory.newWSDLReader();
                 reader.setFeature(Constants.FEATURE_VERBOSE, false);
-                definition = reader.readWSDL(wsdl.getURL().toString(),
-                        description);
+                try {
+                    // use wsdl manager to parse wsdl or get cached definition
+                    definition = getBus().getExtension(WSDLManager.class)
+                            .getDefinition(wsdl.getURL());
+                } catch (WSDLException ex) {
+                    // 
+                }
                 WSDLServiceFactory factory = new WSDLServiceFactory(getBus(),
                         definition, service);
                 cxfService = factory.create();
@@ -277,18 +281,16 @@
                 ei.getBinding().setProperty(
                         AbstractBindingFactory.DATABINDING_DISABLED, Boolean.TRUE);
                 
-                if (locationURI == null) {
-                    // if not specify target address, get it from the wsdl
-                    locationURI = new URI(ei.getAddress());
-                    LOG.fine("address is " + locationURI.toString());
-                }
+                
                 ep = new EndpointImpl(getBus(), cxfService, ei);
                 
                 //init transport
-                ei.setAddress(locationURI.toString());
+                if (locationURI != null) {
+                    ei.setAddress(locationURI.toString());
+                }
                 
                 ConduitInitiatorManager conduitMgr = getBus().getExtension(ConduitInitiatorManager.class);
-                conduitInit = conduitMgr.getConduitInitiator("http://schemas.xmlsoap.org/soap/http");
+                conduitInit = conduitMgr.getConduitInitiator(ei.getTransportId());
                 super.validate();
             }
         } catch (DeploymentException e) {

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcJmsTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcJmsTest.java?rev=649359&r1=649358&r2=649359&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcJmsTest.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcJmsTest.java Thu Apr 17 20:44:14 2008
@@ -23,7 +23,6 @@
 import java.util.Map;
 
 import javax.xml.namespace.QName;
-
 import org.apache.cxf.testutil.common.ServerLauncher;
 import org.apache.hello_world_soap_http.BadRecordLitFault;
 import org.apache.hello_world_soap_http.Greeter;
@@ -53,7 +52,8 @@
         
         assertTrue("server did not launch correctly", 
                    launchServer(EmbededJMSBrokerLauncher.class, props, false));
-
+        assertTrue("server did not launch correctly", 
+                launchServer(MyJMSServer.class, null, false));
         
         serversStarted = true;
     }
@@ -80,12 +80,13 @@
     }
 
     public void testJMSTransport() throws Exception {
+        URL wsdl = getWSDLURL("org/apache/servicemix/cxfbc/ws/security/hello_world.wsdl");
 
         QName serviceName = getServiceName(new QName(
                 "http://apache.org/hello_world_soap_http", "HelloWorldService"));
         QName portName = getPortName(new QName(
                 "http://apache.org/hello_world_soap_http", "HelloWorldPort"));
-        URL wsdl = getWSDLURL("org/apache/servicemix/cxfbc/ws/security/hello_world.wsdl");
+        
         assertNotNull(wsdl);
 
         HelloWorldService service = new HelloWorldService(wsdl, serviceName);

Added: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/MyJMSServer.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/MyJMSServer.java?rev=649359&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/MyJMSServer.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/MyJMSServer.java Thu Apr 17 20:44:14 2008
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.cxfbc;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class MyJMSServer extends AbstractBusTestServerBase {
+
+    protected void run() {
+        System.out.println("Starting Server");
+        Object implementor = new GreeterImplTwoWayJMS();
+        String address = "http://localhost:9000/SoapContext/SoapPort";
+        Endpoint.publish(address, implementor);
+    }
+  
+    public static void main(String args[]) throws Exception {
+        try {
+            MyJMSServer s = new MyJMSServer();
+            s.start();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(-1);
+        } finally {
+            System.out.println("Done");
+        }
+    }
+}
\ No newline at end of file

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/MyJMSServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/MyJMSServer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/jms_transport.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/jms_transport.xml?rev=649359&r1=649358&r2=649359&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/jms_transport.xml (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/jms_transport.xml Thu Apr 17 20:44:14 2008
@@ -27,7 +27,7 @@
   <sm:container id="jbi" embedded="true">
     
     <sm:endpoints>
-      <cxfse:endpoint>
+      <!--cxfse:endpoint>
         <cxfse:pojo>
           <bean class="org.apache.servicemix.cxfbc.GreeterImplTwoWayJMS" />
         </cxfse:pojo>
@@ -43,9 +43,9 @@
         <cxfse:outFaultInterceptors>
           <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
         </cxfse:outFaultInterceptors>
-      </cxfse:endpoint>
+      </cxfse:endpoint-->
       <cxfbc:consumer wsdl="org/apache/servicemix/cxfbc/ws/security/hello_world.wsdl"
-                      targetEndpoint="HelloWorldPort"
+                      targetEndpoint="HelloWorldPortProxy"
                       targetService="greeter:HelloWorldService"
                       targetInterface="greeter:Greeter"
                       >
@@ -62,6 +62,24 @@
           <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
         </cxfbc:outFaultInterceptors>
       </cxfbc:consumer>
+      <cxfbc:provider wsdl="org/apache/servicemix/cxfbc/ws/security/hello_world.wsdl"
+                      service="greeter:HelloWorldService"
+                      endpoint="HelloWorldPortProxy"
+                      interfaceName="greeter:Greetr"
+                     >
+          <cxfbc:inInterceptors>
+            <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+          </cxfbc:inInterceptors>
+          <cxfbc:outInterceptors>
+            <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+          </cxfbc:outInterceptors>
+          <cxfbc:inFaultInterceptors>
+            <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+          </cxfbc:inFaultInterceptors>
+          <cxfbc:outFaultInterceptors>
+            <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+          </cxfbc:outFaultInterceptors>
+      </cxfbc:provider>
     </sm:endpoints>
     
   </sm:container>