cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1374415 - in /cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery: WSDiscoveryClient.java WSDiscoveryService.java
Date Fri, 17 Aug 2012 19:54:11 GMT
Author: dkulp
Date: Fri Aug 17 19:54:10 2012
New Revision: 1374415

URL: http://svn.apache.org/viewvc?rev=1374415&view=rev
Log:
Update service to auto flip back/forth between managed and adHoc

Modified:
    cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryClient.java
    cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryService.java

Modified: cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryClient.java?rev=1374415&r1=1374414&r2=1374415&view=diff
==============================================================================
--- cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryClient.java
(original)
+++ cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryClient.java
Fri Aug 17 19:54:10 2012
@@ -66,7 +66,7 @@ import org.apache.cxf.wsdl.EndpointRefer
  * 
  */
 public class WSDiscoveryClient implements Closeable {
-    private static final QName SERVICE_QNAME 
+    static final QName SERVICE_QNAME 
         = new QName("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01", "DiscoveryProxy");
     private static final QName PORT_QNAME 
         = new QName("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01", "DiscoveryProxy");
@@ -223,10 +223,7 @@ public class WSDiscoveryClient implement
                                 || h.getTypes().contains(new QName("", SERVICE_QNAME.getLocalPart())))
{
                                 // A DiscoveryProxy wants us to flip to managed mode
                                 resetDispatch(h.getXAddrs().get(0));
-                            } else {
-                                System.out.println(h.getTypes());
                             }
-                            
                         }
                     } catch (InterruptedException e) {
                         // TODO Auto-generated catch block

Modified: cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryService.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryService.java?rev=1374415&r1=1374414&r2=1374415&view=diff
==============================================================================
--- cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryService.java
(original)
+++ cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryService.java
Fri Aug 17 19:54:10 2012
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.ws.discovery;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -27,6 +28,7 @@ import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.annotation.XmlSeeAlso;
 import javax.xml.bind.util.JAXBSource;
+import javax.xml.namespace.QName;
 import javax.xml.transform.Source;
 import javax.xml.ws.Endpoint;
 import javax.xml.ws.EndpointReference;
@@ -36,6 +38,7 @@ import javax.xml.ws.soap.Addressing;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.jaxb.JAXBContextCache;
+import org.apache.cxf.ws.discovery.wsdl.ByeType;
 import org.apache.cxf.ws.discovery.wsdl.HelloType;
 import org.apache.cxf.ws.discovery.wsdl.ObjectFactory;
 import org.apache.cxf.ws.discovery.wsdl.ProbeMatchType;
@@ -106,6 +109,33 @@ public class WSDiscoveryService {
                         pmt.getProbeMatch().add(m);
                     }
                     return new JAXBSource(context, factory.createProbeMatches(pmt));
+                } else if (obj instanceof HelloType) {
+                    //check if it's a DiscoveryProxy
+                    HelloType h = (HelloType)obj;
+                    if (h.getTypes().contains(WSDiscoveryClient.SERVICE_QNAME)
+                        || h.getTypes().contains(new QName("", WSDiscoveryClient.SERVICE_QNAME.getLocalPart())))
{
+                        // A DiscoveryProxy wants us to flip to managed mode
+                        try {
+                            client.close();
+                            client = new WSDiscoveryClient(h.getXAddrs().get(0));
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                } else if (obj instanceof ByeType) {
+                    ByeType h = (ByeType)obj;
+                    if (h.getTypes().contains(WSDiscoveryClient.SERVICE_QNAME)
+                        || h.getTypes().contains(new QName("", WSDiscoveryClient.SERVICE_QNAME.getLocalPart())))
{
+                        // Our proxy has gone away, flip to ad-hoc
+                        try {
+                            if (client.address.equals(h.getXAddrs().get(0))) {
+                                client.close();
+                                client = new WSDiscoveryClient();
+                            }
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+                    }
                 }
             } catch (JAXBException e) {
                 // TODO Auto-generated catch block



Mime
View raw message