cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1375179 - in /cxf/trunk: osgi/karaf/features/src/main/resources/ services/ws-discovery/ services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/ services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/w...
Date Mon, 20 Aug 2012 19:34:24 GMT
Author: dkulp
Date: Mon Aug 20 19:34:23 2012
New Revision: 1375179

URL: http://svn.apache.org/viewvc?rev=1375179&view=rev
Log:
Updates to get the discovery stuff working in OSGi

Added:
    cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/internal/
    cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/internal/WSDiscoveryServiceImpl.java
      - copied, changed from r1375153, cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryService.java
    cxf/trunk/services/ws-discovery/ws-discovery-service/src/main/resources/OSGI-INF/
    cxf/trunk/services/ws-discovery/ws-discovery-service/src/main/resources/OSGI-INF/blueprint/
    cxf/trunk/services/ws-discovery/ws-discovery-service/src/main/resources/OSGI-INF/blueprint/cxf-wsdiscovery.xml
Modified:
    cxf/trunk/osgi/karaf/features/src/main/resources/features.xml
    cxf/trunk/services/ws-discovery/pom.xml
    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
    cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/listeners/WSDiscoveryServerListener.java
    cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java
    cxf/trunk/services/ws-discovery/ws-discovery-service/src/main/resources/META-INF/cxf/bus-extensions.txt

Modified: cxf/trunk/osgi/karaf/features/src/main/resources/features.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/osgi/karaf/features/src/main/resources/features.xml?rev=1375179&r1=1375178&r2=1375179&view=diff
==============================================================================
--- cxf/trunk/osgi/karaf/features/src/main/resources/features.xml (original)
+++ cxf/trunk/osgi/karaf/features/src/main/resources/features.xml Mon Aug 20 19:34:23 2012
@@ -28,7 +28,7 @@
         <bundle start-level='10' dependency="true">mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jaxws-api-2.2/${cxf.servicemix.specs.version}</bundle>
         <bundle start-level='10' dependency="true">mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.saaj-api-1.3/${cxf.servicemix.specs.version}</bundle>
         <bundle start-level='10'>mvn:javax.mail/mail/${cxf.javax.mail.version}</bundle>
-        <bundle start-level='10'>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jsr311-api-1.1.1/${cxf.servicemix.specs.version}</bundle>
+        <bundle start-level='10'>mvn:javax.ws.rs/javax.ws.rs-api/${cxf.javax.ws.rs.version}</bundle>
 
         <bundle start-level='20'>mvn:org.codehaus.woodstox/stax2-api/${cxf.woodstox.stax2-api.version}</bundle>
         <bundle start-level='20'>mvn:org.codehaus.woodstox/woodstox-core-asl/${cxf.woodstox.core.version}</bundle>
@@ -235,7 +235,11 @@
         <feature version="${project.version}">cxf-bindings-soap</feature>
         <bundle start-level='40'>mvn:org.apache.cxf/cxf-rt-transports-jms/${project.version}</bundle>
     </feature>
-<feature name="cxf-javascript" version="${project.version}" resolver='(obr)'>
+    <feature name="cxf-transports-udp" version="${project.version}" resolver='(obr)'>
+        <feature version="${project.version}">cxf-core</feature>
+        <bundle start-level='40'>mvn:org.apache.cxf/cxf-rt-transports-udp/${project.version}</bundle>
+    </feature>
+    <feature name="cxf-javascript" version="${project.version}" resolver='(obr)'>
         <feature version="${project.version}">cxf-core</feature>
         <feature version="${project.version}">cxf-bindings-soap</feature>
         <bundle start-level='40'>mvn:org.apache.cxf/cxf-rt-javascript/${project.version}</bundle>
@@ -298,6 +302,7 @@
 
         <feature version="${project.version}">cxf-transports-local</feature>
         <feature version="${project.version}">cxf-transports-jms</feature>
+        <feature version="${project.version}">cxf-transports-udp</feature>
 
 
         <feature version="${project.version}">cxf-xjc-runtime</feature>
@@ -347,4 +352,16 @@
 
         <bundle>mvn:org.apache.cxf.services.wsn/cxf-services-wsn-core/${project.version}</bundle>
     </feature>
+    
+    <feature name="cxf-ws-discovery-api" version="${project.version}" resolver="(obr)">
+        <feature version="${project.version}">cxf-transports-udp</feature>
+        <feature version="${project.version}">cxf-ws-addr</feature>
+        <feature version="${project.version}">cxf-jaxws</feature>
+        <bundle>mvn:org.apache.cxf.services.ws-discovery/cxf-services-ws-discovery-api/${project.version}</bundle>
+    </feature>
+    
+    <feature name="cxf-ws-discovery" version="${project.version}" resolver="(obr)">
+        <feature version="${project.version}">cxf-ws-discovery-api</feature>
+        <bundle>mvn:org.apache.cxf.services.ws-discovery/cxf-services-ws-discovery-service/${project.version}</bundle>
+    </feature>
 </features>

Modified: cxf/trunk/services/ws-discovery/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/pom.xml?rev=1375179&r1=1375178&r2=1375179&view=diff
==============================================================================
--- cxf/trunk/services/ws-discovery/pom.xml (original)
+++ cxf/trunk/services/ws-discovery/pom.xml Mon Aug 20 19:34:23 2012
@@ -22,7 +22,7 @@
     <artifactId>cxf-services-ws-discovery</artifactId>
     <packaging>pom</packaging>
     <version>2.7.0-SNAPSHOT</version>
-    <name>Apache CXF WS-Discovery service</name>
+    <name>Apache CXF WS-Discovery</name>
     <url>http://cxf.apache.org</url>
 
     <parent>

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=1375179&r1=1375178&r2=1375179&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
Mon Aug 20 19:34:23 2012
@@ -42,6 +42,7 @@ import javax.xml.ws.wsaddressing.W3CEndp
 import javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
 import org.apache.cxf.common.jaxb.JAXBContextCache;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.headers.Header;
@@ -67,9 +68,7 @@ import org.apache.cxf.wsdl.EndpointRefer
  * 
  */
 public class WSDiscoveryClient implements Closeable {
-    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 
+    public static final QName SERVICE_QNAME 
         = new QName("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01", "DiscoveryProxy");
     
     
@@ -85,10 +84,18 @@ public class WSDiscoveryClient implement
     
     public WSDiscoveryClient() {
     }
+    public WSDiscoveryClient(Bus bus) {
+        this.bus = bus;
+    }
     public WSDiscoveryClient(String address) {
         this.address = address;
         adHoc = false;
     }
+    
+    public String getAddress() {
+        return address;
+    }
+    
     private synchronized JAXBContext getJAXBContext() {
         if (jaxbContext == null) {
             try {
@@ -101,9 +108,14 @@ public class WSDiscoveryClient implement
     }
     private synchronized Service getService() {
         if (service == null) {
-            service = Service.create(SERVICE_QNAME);
-            service.addPort(PORT_QNAME, SOAPBinding.SOAP12HTTP_BINDING, address);
-        }
+            Bus b = BusFactory.getAndSetThreadDefaultBus(bus);
+            try {
+                service = Service.create(SERVICE_QNAME);
+                service.addPort(SERVICE_QNAME, SOAPBinding.SOAP12HTTP_BINDING, address);
+            } finally {
+                BusFactory.setThreadDefaultBus(b);
+            }
+        } 
         return service;
     }
     private synchronized void resetDispatch(String newad) {
@@ -116,7 +128,7 @@ public class WSDiscoveryClient implement
     private synchronized Dispatch<Object> getDispatchInternal(boolean addSeq) {
         if (dispatch == null) {
             AddressingFeature f = new AddressingFeature(true, true);
-            dispatch = getService().createDispatch(PORT_QNAME, getJAXBContext(), Service.Mode.PAYLOAD,
f);
+            dispatch = getService().createDispatch(SERVICE_QNAME, getJAXBContext(), Service.Mode.PAYLOAD,
f);
             dispatch.getRequestContext().put("thread.local.request.context", Boolean.TRUE);
         }
         addAddressing(dispatch, false);

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=1375179&r1=1375178&r2=1375179&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
Mon Aug 20 19:34:23 2012
@@ -19,261 +19,33 @@
 
 package org.apache.cxf.ws.discovery;
 
-import java.io.IOException;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import javax.xml.bind.JAXBContext;
-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.stream.XMLStreamException;
-import javax.xml.transform.Source;
-import javax.xml.ws.Endpoint;
 import javax.xml.ws.EndpointReference;
-import javax.xml.ws.Provider;
-import javax.xml.ws.WebServiceProvider;
-import javax.xml.ws.soap.Addressing;
-
-import org.w3c.dom.Document;
 
-import org.apache.cxf.Bus;
-import org.apache.cxf.common.jaxb.JAXBContextCache;
 import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.staxutils.StaxUtils;
-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;
-import org.apache.cxf.ws.discovery.wsdl.ProbeMatchesType;
-import org.apache.cxf.ws.discovery.wsdl.ProbeType;
-import org.apache.cxf.ws.discovery.wsdl.ScopesType;
-
-public class WSDiscoveryService {
-    Bus bus;
-    Endpoint udpEndpoint;
-    WSDiscoveryClient client;
-    List<HelloType> registered = new CopyOnWriteArrayList<HelloType>();
-    ObjectFactory factory = new ObjectFactory();
-    boolean started;
-    
-    public WSDiscoveryService(Bus b) {
-        bus = b;
-        client = new WSDiscoveryClient();
-    }
-    
-    public HelloType register(EndpointReference ref) {
-        startup();
-        HelloType ht = client.register(ref); 
-        registered.add(ht);
-        return ht;
-    }
-    
-    public void serverStarted(Server server) {
-        startup();
-        HelloType ht = new HelloType();
-        ht.setScopes(new ScopesType());
-        ht.setMetadataVersion(1);
-        ht.getTypes().add(server.getEndpoint().getEndpointInfo().getInterface().getName());
-        Object o = server.getEndpoint().get("ws-discover.scopes");
-        if (o != null) {
-            setScopes(ht, o);
-        }
-        setXAddrs(ht, server);
-        ht = client.register(ht);
-        registered.add(ht);
-        server.getEndpoint().put(HelloType.class.getName(), ht);
-    }
-
-    private void setXAddrs(HelloType ht, Server server) {
-        String s = server.getEndpoint().getEndpointInfo().getAddress();
-        //FIXME - servlet mode, need all the servlet information to create a full address
-        ht.getXAddrs().add(s);
-    }
-
-    private void setScopes(HelloType ht, Object o) {
-        if (o instanceof List) {
-            List<?> l = (List)o;
-            for (Object o2 : l) {
-                ht.getScopes().getValue().add(o2.toString());
-            }
-        } else {
-            ht.getScopes().getValue().add(o.toString());
-        }
-    }
 
-    public void serverStopped(Server server) {
-        HelloType ht = (HelloType)server.getEndpoint().get(HelloType.class.getName());
-        if (ht != null) {
-            unregister(ht);
-        }
-    }    
-    
-    
-    public void unregister(HelloType ht) {
-        registered.remove(ht);
-        client.unregister(ht); 
-    }
+public interface WSDiscoveryService {
     
+    /** Registers the given EndpointReference with the service.  Also sends the UDP "Hello"
+     * @param ref
+     * @return the HelloType that was sent so it can be used to call unregister
+     */
+    HelloType register(EndpointReference ref);  
+
+    void register(HelloType ht);
+    void unregister(HelloType ht);
+
+    /**
+     * Utility methods to aid in calling the register/unregister for the appropriate CXF
server
+     * @param server
+     */
+    void serverStarted(Server server);
+    void serverStopped(Server server);
+    
+    /**
+     * The service requires a WSDiscoveryClient in order to interact with a DiscoveryProxy,
send Hello/Bye/etc..
+     * @return the client being used
+     */
+    WSDiscoveryClient getClient();
     
-    
-    public synchronized void startup() {
-        if (!started) {
-            udpEndpoint = Endpoint.create(new WSDiscoveryProvider());
-            udpEndpoint.publish("soap.udp://239.255.255.250:3702");
-            started = true;
-        }
-    }
-    
-    
-    public ProbeMatchesType handleProbe(ProbeType pt) {
-        List<HelloType> consider = new LinkedList<HelloType>(registered);
-        //step one, consider the "types"
-        //ALL types in the probe must be in the registered type
-        if (pt.getTypes() != null && !pt.getTypes().isEmpty()) {
-            ListIterator<HelloType> cit = consider.listIterator();
-            while (cit.hasNext()) {
-                HelloType ht = cit.next();
-                boolean matches = true;
-                for (QName qn : pt.getTypes()) {
-                    if (!ht.getTypes().contains(qn)) {
-                        matches = false;
-                    }
-                }
-                if (!matches) {
-                    cit.remove();
-                }
-            }
-        }
-        //next, consider the scopes
-        matchScopes(pt, consider);
-
-        if (consider.isEmpty()) {
-            return null;
-        }
-        ProbeMatchesType pmt = new ProbeMatchesType();
-        for (HelloType ht : consider) {
-            ProbeMatchType m = new ProbeMatchType();
-            m.setEndpointReference(ht.getEndpointReference());
-            m.setScopes(ht.getScopes());
-            m.setMetadataVersion(ht.getMetadataVersion());
-            m.getTypes().addAll(ht.getTypes());
-            m.getXAddrs().addAll(ht.getXAddrs());
-            pmt.getProbeMatch().add(m);
-        }
-        return pmt;
-    }
-    
-    private void matchScopes(ProbeType pt, List<HelloType> consider) {
-        if (pt.getScopes() == null || pt.getScopes().getValue().isEmpty()) {
-            return;
-        }
-        String mb = pt.getScopes().getMatchBy();
-        if (mb == null) {
-            mb = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/rfc3986";
-        }
-        
-        ListIterator<HelloType> cit = consider.listIterator();
-        while (cit.hasNext()) {
-            HelloType ht = cit.next();
-            boolean matches = false;
-            
-            if ("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/rfc3986".equals(mb))
{
-                //FIXME
-            } else if ("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/uuid".equals(mb))
{
-                //FIXME
-            } else if ("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/ldap".equals(mb))
{
-                //FIXME
-            } else if ("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/strcmp0".equals(mb))
{
-                //FIXME
-            } else if ("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/none".equals(mb)
-                && (ht.getScopes() == null || ht.getScopes().getValue().isEmpty()))
{
-                matches = true;
-            }
-            if (!matches) {
-                cit.remove();
-            }
-        }
-    }
-    
-
-    @WebServiceProvider(wsdlLocation = "classpath:/org/apache/cxf/ws/discovery/wsdl/wsdd-discovery-1.1-wsdl-os.wsdl",
-        targetNamespace = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01",
-        serviceName = "Discovery",
-        portName = "DiscoveryUDP")
-    @XmlSeeAlso(ObjectFactory.class)
-    @Addressing(required = true)
-    class WSDiscoveryProvider implements Provider<Source> {
-        
-        JAXBContext context;
-        public WSDiscoveryProvider() {
-            try {
-                context = JAXBContextCache.getCachedContextAndSchemas(ObjectFactory.class).getContext();
-            } catch (JAXBException e) {
-                e.printStackTrace();
-            }
-        }
-        
-
-        public Source invoke(Source request) {
-            try {
-                //Bug in JAXB - if you pass the StaxSource or SaxSource into unmarshall,
-                //the namespaces for the QNames for the Types elements are lost.
-                //Since WS-Discovery messages are small (UDP datagram size), parsing to DOM
-                //is not a HUGE deal
-                Document doc = StaxUtils.read(request);
-                
-                Object obj = context.createUnmarshaller().unmarshal(doc.getDocumentElement());
-                if (obj instanceof JAXBElement) {
-                    obj = ((JAXBElement)obj).getValue();
-                }
-                if (obj instanceof ProbeType) {
-                    ProbeMatchesType pmt = handleProbe((ProbeType)obj);
-                    if (pmt == null) {
-                        return null;
-                    }
-                    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
-                e.printStackTrace();
-            } catch (XMLStreamException e1) {
-                // TODO Auto-generated catch block
-                e1.printStackTrace();
-            }
-            return null;
-        }
-    }
-
 }

Copied: cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/internal/WSDiscoveryServiceImpl.java
(from r1375153, 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/internal/WSDiscoveryServiceImpl.java?p2=cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/internal/WSDiscoveryServiceImpl.java&p1=cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryService.java&r1=1375153&r2=1375179&rev=1375179&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/internal/WSDiscoveryServiceImpl.java
Mon Aug 20 19:34:23 2012
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.cxf.ws.discovery;
+package org.apache.cxf.ws.discovery.internal;
 
 import java.io.IOException;
 import java.util.LinkedList;
@@ -42,9 +42,12 @@ import javax.xml.ws.soap.Addressing;
 import org.w3c.dom.Document;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
 import org.apache.cxf.common.jaxb.JAXBContextCache;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.cxf.ws.discovery.WSDiscoveryClient;
+import org.apache.cxf.ws.discovery.WSDiscoveryService;
 import org.apache.cxf.ws.discovery.wsdl.ByeType;
 import org.apache.cxf.ws.discovery.wsdl.HelloType;
 import org.apache.cxf.ws.discovery.wsdl.ObjectFactory;
@@ -53,7 +56,7 @@ import org.apache.cxf.ws.discovery.wsdl.
 import org.apache.cxf.ws.discovery.wsdl.ProbeType;
 import org.apache.cxf.ws.discovery.wsdl.ScopesType;
 
-public class WSDiscoveryService {
+public class WSDiscoveryServiceImpl implements WSDiscoveryService {
     Bus bus;
     Endpoint udpEndpoint;
     WSDiscoveryClient client;
@@ -61,10 +64,18 @@ public class WSDiscoveryService {
     ObjectFactory factory = new ObjectFactory();
     boolean started;
     
-    public WSDiscoveryService(Bus b) {
+    public WSDiscoveryServiceImpl(Bus b) {
         bus = b;
         client = new WSDiscoveryClient();
     }
+    public WSDiscoveryServiceImpl() {
+        bus = BusFactory.newInstance().createBus();
+        client = new WSDiscoveryClient();
+    }
+    
+    public WSDiscoveryClient getClient() {
+        return client;
+    }
     
     public HelloType register(EndpointReference ref) {
         startup();
@@ -72,6 +83,11 @@ public class WSDiscoveryService {
         registered.add(ht);
         return ht;
     }
+    public void register(HelloType ht) {
+        startup();
+        client.register(ht); 
+        registered.add(ht);
+    }
     
     public void serverStarted(Server server) {
         startup();
@@ -256,7 +272,7 @@ public class WSDiscoveryService {
                         || 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))) {
+                            if (client.getAddress().equals(h.getXAddrs().get(0))) {
                                 client.close();
                                 client = new WSDiscoveryClient();
                             }

Modified: cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/listeners/WSDiscoveryServerListener.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/listeners/WSDiscoveryServerListener.java?rev=1375179&r1=1375178&r2=1375179&view=diff
==============================================================================
--- cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/listeners/WSDiscoveryServerListener.java
(original)
+++ cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/listeners/WSDiscoveryServerListener.java
Mon Aug 20 19:34:23 2012
@@ -22,22 +22,33 @@ package org.apache.cxf.ws.discovery.list
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.endpoint.ServerLifeCycleListener;
-import org.apache.cxf.ws.discovery.WSDiscoveryService;
+import org.apache.cxf.ws.discovery.internal.WSDiscoveryServiceImpl;
 
 /**
  * 
  */
 public class WSDiscoveryServerListener implements ServerLifeCycleListener {
-    WSDiscoveryService service;
+    static WSDiscoveryServiceImpl staticService;
+    
+    WSDiscoveryServiceImpl service;
     
     public WSDiscoveryServerListener(Bus bus) {
-        service = bus.getExtension(WSDiscoveryService.class);
+        service = bus.getExtension(WSDiscoveryServiceImpl.class);
         if (service == null) {
-            service = new WSDiscoveryService(bus);
-            bus.setExtension(service, WSDiscoveryService.class);
+            service = getStaticService();
+            bus.setExtension(service, WSDiscoveryServiceImpl.class);
+        }
+    }
+
+    private WSDiscoveryServiceImpl getStaticService() {
+        if (staticService == null) {
+            Bus bus = BusFactory.newInstance().createBus();
+            staticService = new WSDiscoveryServiceImpl(bus);
         }
+        return staticService;
     }
 
     public void startServer(Server server) {

Modified: cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java?rev=1375179&r1=1375178&r2=1375179&view=diff
==============================================================================
--- cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java
(original)
+++ cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java
Mon Aug 20 19:34:23 2012
@@ -23,6 +23,7 @@ import javax.jws.WebMethod;
 import javax.jws.WebService;
 import javax.xml.ws.Endpoint;
 
+import org.apache.cxf.ws.discovery.internal.WSDiscoveryServiceImpl;
 import org.apache.cxf.ws.discovery.wsdl.HelloType;
 import org.apache.cxf.ws.discovery.wsdl.ProbeMatchType;
 import org.apache.cxf.ws.discovery.wsdl.ProbeMatchesType;
@@ -42,7 +43,7 @@ public final class WSDiscoveryClientTest
     public static void main(String[] arg) throws Exception {
         try {
             Endpoint ep = Endpoint.publish("http://localhost:51919/Foo/Snarf", new FooImpl());
-            WSDiscoveryService service = new WSDiscoveryService(null);
+            WSDiscoveryServiceImpl service = new WSDiscoveryServiceImpl(null);
             service.startup();
             
             

Modified: cxf/trunk/services/ws-discovery/ws-discovery-service/src/main/resources/META-INF/cxf/bus-extensions.txt
URL: http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/ws-discovery-service/src/main/resources/META-INF/cxf/bus-extensions.txt?rev=1375179&r1=1375178&r2=1375179&view=diff
==============================================================================
--- cxf/trunk/services/ws-discovery/ws-discovery-service/src/main/resources/META-INF/cxf/bus-extensions.txt
(original)
+++ cxf/trunk/services/ws-discovery/ws-discovery-service/src/main/resources/META-INF/cxf/bus-extensions.txt
Mon Aug 20 19:34:23 2012
@@ -1,2 +1,2 @@
-org.apache.cxf.ws.discovery.listeners.WSDiscoveryServerListener::true
 org.apache.cxf.ws.discovery.WSDiscoveryService::true
+

Added: cxf/trunk/services/ws-discovery/ws-discovery-service/src/main/resources/OSGI-INF/blueprint/cxf-wsdiscovery.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/ws-discovery-service/src/main/resources/OSGI-INF/blueprint/cxf-wsdiscovery.xml?rev=1375179&view=auto
==============================================================================
--- cxf/trunk/services/ws-discovery/ws-discovery-service/src/main/resources/OSGI-INF/blueprint/cxf-wsdiscovery.xml
(added)
+++ cxf/trunk/services/ws-discovery/ws-discovery-service/src/main/resources/OSGI-INF/blueprint/cxf-wsdiscovery.xml
Mon Aug 20 19:34:23 2012
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0">
+
+    <!-- Single discovery service to avoid lots of UDP packets, particularly on probes
-->
+    <bean id="discoveryService" class="org.apache.cxf.ws.discovery.internal.WSDiscoveryServiceImpl"/>
+
+    <service ref="discoveryService" interface="org.apache.cxf.ws.discovery.WSDiscoveryService"
/>
+
+</blueprint>
\ No newline at end of file



Mime
View raw message