cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1298966 - in /cxf/branches/2.5.x-fixes/services/wsn: wsn-api/src/main/java/org/apache/cxf/wsn/client/ wsn-core/src/main/java/org/apache/cxf/wsn/ wsn-core/src/test/java/org/apache/cxf/wsn/
Date Fri, 09 Mar 2012 18:34:33 GMT
Author: dkulp
Date: Fri Mar  9 18:34:32 2012
New Revision: 1298966

URL: http://svn.apache.org/viewvc?rev=1298966&view=rev
Log:
Merged revisions 1298957 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1298957 | dkulp | 2012-03-09 13:18:09 -0500 (Fri, 09 Mar 2012) | 2 lines

  [CXF-4140] Make registerPublisher compliant with the spec

........

Modified:
    cxf/branches/2.5.x-fixes/services/wsn/wsn-api/src/main/java/org/apache/cxf/wsn/client/Publisher.java
    cxf/branches/2.5.x-fixes/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/AbstractNotificationBroker.java
    cxf/branches/2.5.x-fixes/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/AbstractPublisher.java
    cxf/branches/2.5.x-fixes/services/wsn/wsn-core/src/test/java/org/apache/cxf/wsn/WsnBrokerTest.java

Modified: cxf/branches/2.5.x-fixes/services/wsn/wsn-api/src/main/java/org/apache/cxf/wsn/client/Publisher.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/services/wsn/wsn-api/src/main/java/org/apache/cxf/wsn/client/Publisher.java?rev=1298966&r1=1298965&r2=1298966&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/services/wsn/wsn-api/src/main/java/org/apache/cxf/wsn/client/Publisher.java
(original)
+++ cxf/branches/2.5.x-fixes/services/wsn/wsn-api/src/main/java/org/apache/cxf/wsn/client/Publisher.java
Fri Mar  9 18:34:32 2012
@@ -79,15 +79,24 @@ public class Publisher implements Notifi
     public Publisher(Callback callback, String address) {
         this.callback = callback;
         this.address = address;
-        this.endpoint = Endpoint.create(this);
-        this.endpoint.publish(address);
+        if (callback == null || address == null) {
+            this.endpoint = null;
+        } else {
+            this.endpoint = Endpoint.create(this);
+            this.endpoint.publish(address);
+        }
     }
 
     public void stop() {
-        this.endpoint.stop();
+        if (endpoint != null) {
+            this.endpoint.stop();
+        }
     }
 
     public W3CEndpointReference getEpr() {
+        if (this.endpoint == null) {
+            return null;
+        }
         return this.endpoint.getEndpointReference(W3CEndpointReference.class);
     }
 

Modified: cxf/branches/2.5.x-fixes/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/AbstractNotificationBroker.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/AbstractNotificationBroker.java?rev=1298966&r1=1298965&r2=1298966&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/AbstractNotificationBroker.java
(original)
+++ cxf/branches/2.5.x-fixes/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/AbstractNotificationBroker.java
Fri Mar  9 18:34:32 2012
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -91,6 +92,8 @@ public abstract class AbstractNotificati
     private AbstractPublisher anonymousPublisher;
 
     private Map<String, AbstractPublisher> publishers;
+    
+    private List<AbstractPublisher> nonContactPublishers;
 
     private Map<String, AbstractSubscription> subscriptions;
 
@@ -99,6 +102,7 @@ public abstract class AbstractNotificati
         idGenerator = new IdGenerator();
         subscriptions = new ConcurrentHashMap<String, AbstractSubscription>();
         publishers = new ConcurrentHashMap<String, AbstractPublisher>();
+        nonContactPublishers = new CopyOnWriteArrayList<AbstractPublisher>();
     }
 
     public void init() throws Exception {
@@ -322,7 +326,11 @@ public abstract class AbstractNotificati
             publisher.create(registerPublisherRequest);
             RegisterPublisherResponse response = new RegisterPublisherResponse();
             response.setPublisherRegistrationReference(publisher.getEpr());
-            publishers.put(WSNHelper.getWSAAddress(publisher.getPublisherReference()), publisher);
+            if (publisher.getPublisherReference() != null) {
+                publishers.put(WSNHelper.getWSAAddress(publisher.getPublisherReference()),
publisher);
+            } else {
+                nonContactPublishers.add(publisher);
+            }
             success = true;
             return response;
         } catch (EndpointRegistrationException e) {

Modified: cxf/branches/2.5.x-fixes/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/AbstractPublisher.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/AbstractPublisher.java?rev=1298966&r1=1298965&r2=1298966&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/AbstractPublisher.java
(original)
+++ cxf/branches/2.5.x-fixes/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/AbstractPublisher.java
Fri Mar  9 18:34:32 2012
@@ -112,7 +112,7 @@ public abstract class AbstractPublisher 
             ? registerPublisherRequest.isDemand().booleanValue()
                 : false;
         // Check all parameters
-        if (publisherReference == null) {
+        if (publisherReference == null && demand) {
             PublisherRegistrationFailedFaultType fault = new PublisherRegistrationFailedFaultType();
             throw new PublisherRegistrationFailedFault("Invalid PublisherReference: null",
fault);
         }

Modified: cxf/branches/2.5.x-fixes/services/wsn/wsn-core/src/test/java/org/apache/cxf/wsn/WsnBrokerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/services/wsn/wsn-core/src/test/java/org/apache/cxf/wsn/WsnBrokerTest.java?rev=1298966&r1=1298965&r2=1298966&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/services/wsn/wsn-core/src/test/java/org/apache/cxf/wsn/WsnBrokerTest.java
(original)
+++ cxf/branches/2.5.x-fixes/services/wsn/wsn-core/src/test/java/org/apache/cxf/wsn/WsnBrokerTest.java
Fri Mar  9 18:34:32 2012
@@ -179,7 +179,31 @@ public abstract class WsnBrokerTest exte
         publisher.stop();
         consumer.stop();
     }
+    public void testNullPublisherReference() throws Exception {
+        TestConsumer consumerCallback = new TestConsumer();
+        Consumer consumer = new Consumer(consumerCallback, "http://localhost:" + port2 +
"/test/consumer");
+
+        Subscription subscription = notificationBroker.subscribe(consumer, "myTopicNullEPR");
+
+        Publisher publisher = new Publisher(null, null);
+        Registration registration = notificationBroker.registerPublisher(publisher, "myTopicNullEPR",
false);
 
+        synchronized (consumerCallback.notifications) {
+            notificationBroker.notify(publisher, "myTopicNullEPR",
+                                      new JAXBElement<String>(new QName("urn:test:org",
"foo"),
+                                                      String.class, "bar"));
+            consumerCallback.notifications.wait(1000000);
+        }
+        assertEquals(1, consumerCallback.notifications.size());
+        NotificationMessageHolderType message = consumerCallback.notifications.get(0);
+        assertEquals(WSNHelper.getWSAAddress(subscription.getEpr()),
+                     WSNHelper.getWSAAddress(message.getSubscriptionReference()));
+
+        subscription.unsubscribe();
+        registration.destroy();
+        publisher.stop();
+        consumer.stop();
+    }
     public void testPublisherOnDemand() throws Exception {
         TestConsumer consumerCallback = new TestConsumer();
         Consumer consumer = new Consumer(consumerCallback, "http://localhost:" + port2 +
"/test/consumer");



Mime
View raw message